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.
14 static char MTEST_Descrip[] = "Test for streaming ACC-like operations with lock_all+flush_local_all";
17 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);
37 MTEST_DATATYPE_FOR_EACH_COUNT(count) {
38 while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
39 recvtype.printErrors = 1;
40 recvtype.InitBuf(&recvtype);
41 MPI_Type_get_extent(recvtype.datatype, &lb, &extent);
43 MPI_Win_create(recvtype.buf, lb + recvtype.count * extent,
44 (int) extent, MPI_INFO_NULL, comm, &win);
47 MPI_Aint slb, sextent;
48 MPI_Type_get_extent(sendtype.datatype, &slb, &sextent);
49 sendtype.InitBuf(&sendtype);
51 MPI_Win_lock_all(0, win);
52 for (dest = 0; dest < size; dest++)
54 MPI_Accumulate(sendtype.buf, sendtype.count,
55 sendtype.datatype, dest, 0,
56 recvtype.count, recvtype.datatype, MPI_REPLACE, win);
59 MPI_Win_flush_local_all(win);
60 /* reset the send buffer to test local completion */
61 memset(sendtype.buf, 0, slb + sextent * sendtype.count);
62 MPI_Win_unlock_all(win);
65 sendtype.InitBuf(&sendtype);
66 char *resbuf = (char *) calloc(lb + extent * recvtype.count, sizeof(char));
68 /*wait for the destination to finish checking and reinitializing the buffer */
71 MPI_Win_lock_all(0, win);
72 for (dest = 0; dest < size; dest++)
74 MPI_Get_accumulate(sendtype.buf, sendtype.count,
75 sendtype.datatype, resbuf, recvtype.count,
76 recvtype.datatype, dest, 0, recvtype.count,
77 recvtype.datatype, MPI_REPLACE, win);
80 MPI_Win_flush_local_all(win);
81 /* reset the send buffer to test local completion */
82 memset(sendtype.buf, 0, slb + sextent * sendtype.count);
83 MPI_Win_unlock_all(win);
90 MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
91 err = MTestCheckRecv(0, &recvtype);
94 recvtype.InitBuf(&recvtype);
95 MPI_Win_unlock(rank, win);
97 /*signal the source that checking and reinitialization is done */
101 MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
102 err = MTestCheckRecv(0, &recvtype);
105 MPI_Win_unlock(rank, win);
109 MTestFreeDatatype(&sendtype);
110 MTestFreeDatatype(&recvtype);
113 MTestFreeComm(&comm);
115 MTest_Finalize(errs);