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+flush_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);
56 MPI_Win_flush_all(win);
57 /*signal to dest that the ops are flushed so that it starts checking the result */
59 /*make sure dest finishes checking the result before issuing unlock */
61 MPI_Win_unlock_all(win);
63 char *resbuf = (char *) calloc(lb + extent * recvtype.count, sizeof(char));
65 /*wait for the destination to finish checking and reinitializing the buffer */
68 MPI_Win_lock_all(0, win);
69 for (dest = 0; dest < size; dest++)
71 MPI_Get_accumulate(sendtype.buf, sendtype.count,
72 sendtype.datatype, resbuf, recvtype.count,
73 recvtype.datatype, dest, 0, recvtype.count,
74 recvtype.datatype, MPI_REPLACE, win);
77 MPI_Win_flush_all(win);
78 /*signal to dest that the ops are flushed so that it starts checking the result */
80 /*make sure dest finishes checking the result before issuing unlock */
82 MPI_Win_unlock_all(win);
88 MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
89 err = MTestCheckRecv(0, &recvtype);
92 recvtype.InitBuf(&recvtype);
94 MPI_Win_unlock(rank, win);
96 /*signal the source that checking and reinitialization is done */
100 MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
101 err = MTestCheckRecv(0, &recvtype);
105 MPI_Win_unlock(rank, win);
109 MTestFreeDatatype(&sendtype);
110 MTestFreeDatatype(&recvtype);
113 MTestFreeComm(&comm);
115 MTest_Finalize(errs);