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, comm, &win);
40 memset(winbuf, 0, count * sizeof(int));
42 /* Note that for i == rank, this is a useful operation - it allows
43 * the programmer to use direct loads and stores, rather than
44 * put/get/accumulate, to access the local memory window. */
45 for (i = 0; i < size; i++) {
46 MPI_Win_lock(MPI_LOCK_EXCLUSIVE, i, 0, win);
47 MPI_Win_unlock(i, win);
50 for (i = 0; i < size; i++) {
51 MPI_Win_lock(MPI_LOCK_SHARED, i, 0, win);
52 MPI_Win_unlock(i, win);
58 /* If this test completes, no error has been found */
59 /* A more complete test may ensure that local locks in fact block
60 * remote, exclusive locks */