Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
change some tests to avoid useless global variables
[simgrid.git] / teshsuite / smpi / mpich3-test / rma / window_creation.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
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
18 int main(int argc, char **argv)
19 {
20     int rank, nproc, i;
21     void *base_ptrs[NUM_WIN];
22     MPI_Win windows[NUM_WIN];
23
24     MPI_Init(&argc, &argv);
25
26     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
27     MPI_Comm_size(MPI_COMM_WORLD, &nproc);
28
29     if (rank == 0)
30         if (verbose)
31             printf("Starting MPI window creation test with %d processes\n", nproc);
32
33     /* Perform a pile of window creations */
34     for (i = 0; i < NUM_WIN; i++) {
35         if (rank == 0)
36             if (verbose)
37                 printf(" + Creating window %d\n", i);
38
39         MPI_Alloc_mem(DATA_SZ, MPI_INFO_NULL, &base_ptrs[i]);
40         MPI_Win_create(base_ptrs[i], DATA_SZ, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &windows[i]);
41     }
42
43     MPI_Barrier(MPI_COMM_WORLD);
44
45     /* Free all the windows */
46     for (i = 0; i < NUM_WIN; i++) {
47         if (rank == 0)
48             if (verbose)
49                 printf(" + Freeing window %d\n", i);
50
51         MPI_Win_free(&windows[i]);
52         MPI_Free_mem(base_ptrs[i]);
53     }
54
55     if (rank == 0)
56         printf(" No Errors\n");
57
58     MPI_Finalize();
59
60     return 0;
61 }