1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2015 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
13 static char MTEST_Descrip[] = "Test lock contention while streaming ACC-like operations";
16 int main(int argc, char *argv[])
21 int minsize = 2, count;
25 MTestDatatype sendtype, recvtype;
27 MTest_Init(&argc, &argv);
29 while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
30 if (comm == MPI_COMM_NULL)
33 MPI_Comm_rank(comm, &rank);
34 MPI_Comm_size(comm, &size);
36 MTEST_DATATYPE_FOR_EACH_COUNT(count) {
37 while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
38 recvtype.printErrors = 1;
39 recvtype.InitBuf(&recvtype);
40 MPI_Type_get_extent(recvtype.datatype, &lb, &extent);
42 MPI_Win_create(recvtype.buf, lb + recvtype.count * extent,
43 (int) extent, MPI_INFO_NULL, comm, &win);
45 sendtype.InitBuf(&sendtype);
47 MPI_Win_lock(MPI_LOCK_EXCLUSIVE, target, 0, win);
48 MPI_Accumulate(sendtype.buf, sendtype.count,
49 sendtype.datatype, target, 0,
50 recvtype.count, recvtype.datatype, MPI_REPLACE, win);
51 MPI_Win_unlock(target, win);
54 char *resbuf = (char *) calloc(lb + extent * recvtype.count, sizeof(char));
56 /*wait for the destination to finish checking and reinitializing the buffer */
59 MPI_Win_lock(MPI_LOCK_EXCLUSIVE, target, 0, win);
60 MPI_Get_accumulate(sendtype.buf, sendtype.count,
61 sendtype.datatype, resbuf, recvtype.count, recvtype.datatype,
62 target, 0, recvtype.count, recvtype.datatype, MPI_REPLACE,
64 MPI_Win_unlock(target, win);
68 else { /* Target checks the result */
71 MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win);
72 err = MTestCheckRecv(0, &recvtype);
75 recvtype.InitBuf(&recvtype);
76 MPI_Win_unlock(rank, win);
78 /*signal the source that checking and reinitialization is done */
82 MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win);
83 err = MTestCheckRecv(0, &recvtype);
86 MPI_Win_unlock(rank, win);
90 MTestFreeDatatype(&sendtype);
91 MTestFreeDatatype(&recvtype);