Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add MPICH3 rma tests (15 out of 88 should be passing now)
[simgrid.git] / teshsuite / smpi / mpich3-test / rma / locknull.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2008 by Argonne National Laboratory.
5  *      See COPYRIGHT in top-level directory.
6  */
7 #include "mpi.h"
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include "mpitest.h"
11 #include <string.h>
12
13 /*
14 static char MTEST_Descrip[] = "Locks with no RMA operations";
15 */
16
17 int main( int argc, char *argv[] )
18 {
19     int errs = 0;
20     int rank, size, i;
21     MPI_Comm      comm;
22     MPI_Win       win;
23     int           *winbuf, count;
24
25     MTest_Init( &argc, &argv );
26
27     comm = MPI_COMM_WORLD;
28
29     MPI_Comm_rank( comm, &rank );
30     MPI_Comm_size( comm, &size );
31
32     /* Allocate and initialize buf */
33     count  = 1000;
34
35     MPI_Alloc_mem( count*sizeof(int), MPI_INFO_NULL, &winbuf );
36
37     MPI_Win_create( winbuf, count * sizeof(int), sizeof(int), MPI_INFO_NULL, 
38                     comm, &win );
39
40     /* Clear winbuf */
41     memset( winbuf, 0, count*sizeof(int) );
42
43     /* Note that for i == rank, this is a useful operation - it allows 
44        the programmer to use direct loads and stores, rather than 
45        put/get/accumulate, to access the local memory window. */
46     for (i=0; i<size; i++) {
47         MPI_Win_lock( MPI_LOCK_EXCLUSIVE, i, 0, win );
48         MPI_Win_unlock( i, win );
49     }
50
51     for (i=0; i<size; i++) {
52         MPI_Win_lock( MPI_LOCK_SHARED, i, 0, win );
53         MPI_Win_unlock( i, win );
54     }
55
56     MPI_Win_free( &win );
57     MPI_Free_mem( winbuf );
58
59     /* If this test completes, no error has been found */
60     /* A more complete test may ensure that local locks in fact block
61        remote, exclusive locks */
62     MTest_Finalize( errs );
63
64     MPI_Finalize();
65     return 0;
66 }