2 * (C) 2016 by Argonne National Laboratory.
3 * See COPYRIGHT in top-level directory.
5 * Portions of this code were written by Intel Corporation.
6 * Copyright (C) 2011-2016 Intel Corporation. Intel provides this material
7 * to Argonne National Laboratory subject to Software Grant and Corporate
8 * Contributor License Agreement dated February 8, 2012.
11 * This is a test case to make sure synchronization in unlock works correctly.
13 * Essentially this program does the following:
21 * This program is valid but if unlock_all does not implement the synchronization
22 * semantics correctly reusing the buffer would race with outstanding rgets.
33 #define N_BLOCKS (N_ELMS/BLOCKSIZE)
35 int main(int argc, char *argv[])
44 MPI_Init(&argc, &argv);
46 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
47 MPI_Comm_size(MPI_COMM_WORLD, &size);
49 trg = (rank + 1) % size;
51 rbuf = malloc(sizeof(int) * N_ELMS);
52 for (i = 0; i < N_ELMS; i++)
55 lbuf = malloc(sizeof(int) * N_ELMS);
56 memset(lbuf, -1, sizeof(int) * N_ELMS);
58 reqs = malloc(sizeof(MPI_Request) * N_BLOCKS);
60 MPI_Win_create(rbuf, sizeof(int) * N_ELMS, sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
61 MPI_Win_lock_all(MPI_MODE_NOCHECK, win);
62 for (i = 0; i < N_BLOCKS; i++)
63 MPI_Rget(lbuf+i*BLOCKSIZE, BLOCKSIZE, MPI_INT, trg, i*BLOCKSIZE, BLOCKSIZE, MPI_INT, win, &reqs[i]);
64 MPI_Win_unlock_all(win);
65 for (i = 0; i < N_ELMS; i++)
68 MPI_Waitall(N_BLOCKS, reqs, MPI_STATUSES_IGNORE);
69 for (i = 0; i < N_ELMS; i++) {
72 printf("lbuf[%d]=%d, expected -2\n", i, v);
82 if (rank == 0 && n_errors == 0)
83 printf(" No Errors\n");