1 /* -*- Mode: C; c-basic-offset:4 ; -*- */
2 /*
3  *  (C) 2001 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6 
7 #include <stdio.h>
8 #include <stdlib.h>
9 
10 #include <mpi.h>
11 
12 #define DATA_NELTS  1000
13 #define NUM_WIN     1000
14 #define DATA_SZ     (DATA_NELTS*sizeof(int))
15 
16 static int verbose = 0;
17 
main(int argc,char ** argv)18 int main(int argc, char ** argv) {
19   int      rank, nproc, i;
20   void    *base_ptrs[NUM_WIN];
21   MPI_Win  windows[NUM_WIN];
22 
23   MPI_Init(&argc, &argv);
24 
25   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
26   MPI_Comm_size(MPI_COMM_WORLD, &nproc);
27 
28   if (rank == 0) if (verbose) printf("Starting MPI window creation test with %d processes\n", nproc);
29 
30   /* Perform a pile of window creations */
31   for (i = 0; i < NUM_WIN; i++) {
32     if (rank == 0) if (verbose) printf(" + Creating window %d\n", i);
33 
34     MPI_Alloc_mem(DATA_SZ, MPI_INFO_NULL, &base_ptrs[i]);
35     MPI_Win_create(base_ptrs[i], DATA_SZ, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &windows[i]);
36   }
37 
38   MPI_Barrier(MPI_COMM_WORLD);
39 
40   /* Free all the windows */
41   for (i = 0; i < NUM_WIN; i++) {
42     if (rank == 0) if (verbose) printf(" + Freeing window %d\n", i);
43 
44     MPI_Win_free(&windows[i]);
45     MPI_Free_mem(base_ptrs[i]);
46   }
47 
48   if (rank == 0) printf(" No Errors\n");
49 
50   MPI_Finalize();
51 
52   return 0;
53 }
54