1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2008 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
14 static char MTEST_Descrip[] = "Locks with no RMA operations";
17 int main( int argc, char *argv[] )
25 MTest_Init( &argc, &argv );
27 comm = MPI_COMM_WORLD;
29 MPI_Comm_rank( comm, &rank );
30 MPI_Comm_size( comm, &size );
32 /* Allocate and initialize buf */
35 MPI_Alloc_mem( count*sizeof(int), MPI_INFO_NULL, &winbuf );
37 MPI_Win_create( winbuf, count * sizeof(int), sizeof(int), MPI_INFO_NULL,
41 memset( winbuf, 0, count*sizeof(int) );
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 );
51 for (i=0; i<size; i++) {
52 MPI_Win_lock( MPI_LOCK_SHARED, i, 0, win );
53 MPI_Win_unlock( i, win );
57 MPI_Free_mem( winbuf );
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 );