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 for streaming ACC-like operations with lock_all";
16 int main(int argc, char *argv[])
20 int minsize = 2, count;
24 MTestDatatype sendtype, recvtype;
26 MTest_Init(&argc, &argv);
28 while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
29 if (comm == MPI_COMM_NULL)
32 MPI_Comm_rank(comm, &rank);
33 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);
46 sendtype.InitBuf(&sendtype);
48 MPI_Win_lock_all(0, win);
49 for (dest = 0; dest < size; dest++)
51 MPI_Accumulate(sendtype.buf, sendtype.count,
52 sendtype.datatype, dest, 0,
53 recvtype.count, recvtype.datatype, MPI_REPLACE, win);
55 MPI_Win_unlock_all(win);
58 char *resbuf = (char *) calloc(lb + extent * recvtype.count, sizeof(char));
60 /*wait for the destinations to finish checking and reinitializing the buffers */
63 MPI_Win_lock_all(0, win);
64 for (dest = 0; dest < size; dest++)
66 MPI_Get_accumulate(sendtype.buf, sendtype.count,
67 sendtype.datatype, resbuf, recvtype.count,
68 recvtype.datatype, dest, 0, recvtype.count,
69 recvtype.datatype, MPI_REPLACE, win);
72 MPI_Win_unlock_all(win);
79 MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
80 err = MTestCheckRecv(0, &recvtype);
83 recvtype.InitBuf(&recvtype);
84 MPI_Win_unlock(rank, win);
86 /*signal the source that checking and reinitialization is done */
90 MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
91 err = MTestCheckRecv(0, &recvtype);
94 MPI_Win_unlock(rank, win);
98 MTestFreeDatatype(&sendtype);
99 MTestFreeDatatype(&recvtype);
102 MTestFreeComm(&comm);
104 MTest_Finalize(errs);