1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2010 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
12 /* Test the given operation within a Fence epoch */
13 #define TEST_FENCE_OP(op_name_, fcn_call_) \
19 MTestPrintErrorMsg("PROC_NULL to " op_name_, err); \
22 err = MPI_Win_fence(0, win); \
26 MTestPrintErrorMsg("Fence after " op_name_, err); \
32 /* Test the given operation within a passive target epoch */
33 #define TEST_PT_OP(op_name_, fcn_call_) \
35 err = MPI_Win_lock(MPI_LOCK_EXCLUSIVE, MPI_PROC_NULL, 0, win); \
39 MTestPrintErrorMsg("Lock before" op_name_, err); \
46 MTestPrintErrorMsg("PROC_NULL to " op_name_, err); \
49 err = MPI_Win_unlock(MPI_PROC_NULL, win); \
53 MTestPrintErrorMsg("Unlock after " op_name_, err); \
59 /* Test the given request-based operation within a passive target epoch */
60 #define TEST_REQ_OP(op_name_, req_, fcn_call_) \
62 err = MPI_Win_lock(MPI_LOCK_EXCLUSIVE, MPI_PROC_NULL, 0, win); \
66 MTestPrintErrorMsg("Lock before" op_name_, err); \
73 MTestPrintErrorMsg("PROC_NULL to " op_name_, err); \
76 err = MPI_Win_unlock(MPI_PROC_NULL, win); \
80 MTestPrintErrorMsg("Unlock after " op_name_, err); \
83 err = MPI_Wait(&req_, MPI_STATUS_IGNORE); \
87 MTestPrintErrorMsg("Wait after " op_name_, err); \
93 static char MTEST_Descrip[] = "Test the MPI_PROC_NULL is a valid target";
96 int main(int argc, char *argv[])
102 int *rmabuf, rsize, rcount;
107 MTest_Init(&argc, &argv);
109 bufsize = 256 * sizeof(int);
110 buf = (int *) malloc(bufsize);
112 fprintf(stderr, "Unable to allocated %d bytes\n", bufsize);
113 MPI_Abort(MPI_COMM_WORLD, 1);
115 result = (int *) malloc(bufsize);
117 fprintf(stderr, "Unable to allocated %d bytes\n", bufsize);
118 MPI_Abort(MPI_COMM_WORLD, 1);
121 rsize = rcount * sizeof(int);
122 rmabuf = (int *) malloc(rsize);
124 fprintf(stderr, "Unable to allocated %d bytes\n", rsize);
125 MPI_Abort(MPI_COMM_WORLD, 1);
128 /* The following illustrates the use of the routines to
129 * run through a selection of communicators and datatypes.
130 * Use subsets of these for tests that do not involve combinations
131 * of communicators, datatypes, and counts of datatypes */
132 while (MTestGetIntracommGeneral(&comm, 1, 1)) {
133 if (comm == MPI_COMM_NULL)
135 /* Determine the sender and receiver */
136 MPI_Comm_rank(comm, &rank);
137 MPI_Comm_size(comm, &size);
139 MPI_Win_create(buf, bufsize, sizeof(int), MPI_INFO_NULL, comm, &win);
140 /* To improve reporting of problems about operations, we
141 * change the error handler to errors return */
142 MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
144 /** TEST OPERATIONS USING ACTIVE TARGET (FENCE) SYNCHRONIZATION **/
145 MPI_Win_fence(0, win);
148 MPI_Put(rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount, MPI_INT, win);
152 MPI_Get(rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount, MPI_INT, win);
154 TEST_FENCE_OP("Accumulate",
155 MPI_Accumulate(rmabuf, rcount, MPI_INT, MPI_PROC_NULL,
156 0, rcount, MPI_INT, MPI_SUM, win);
158 TEST_FENCE_OP("Get accumulate",
159 MPI_Get_accumulate(rmabuf, rcount, MPI_INT, result,
160 rcount, MPI_INT, MPI_PROC_NULL, 0,
161 rcount, MPI_INT, MPI_SUM, win);
163 TEST_FENCE_OP("Fetch and op",
164 MPI_Fetch_and_op(rmabuf, result, MPI_INT, MPI_PROC_NULL, 0, MPI_SUM, win);
166 TEST_FENCE_OP("Compare and swap",
167 MPI_Compare_and_swap(rmabuf, &rank, result, MPI_INT, MPI_PROC_NULL, 0, win);
170 /** TEST OPERATIONS USING PASSIVE TARGET SYNCHRONIZATION **/
172 TEST_PT_OP("Put", MPI_Put(rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount, MPI_INT, win);
174 TEST_PT_OP("Get", MPI_Get(rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount, MPI_INT, win);
176 TEST_PT_OP("Accumulate",
177 MPI_Accumulate(rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0,
178 rcount, MPI_INT, MPI_SUM, win);
180 TEST_PT_OP("Get accumulate",
181 MPI_Get_accumulate(rmabuf, rcount, MPI_INT, result, rcount,
182 MPI_INT, MPI_PROC_NULL, 0, rcount, MPI_INT, MPI_SUM, win);
184 TEST_PT_OP("Fetch and op",
185 MPI_Fetch_and_op(rmabuf, result, MPI_INT, MPI_PROC_NULL, 0, MPI_SUM, win);
187 TEST_PT_OP("Compare and swap",
188 MPI_Compare_and_swap(rmabuf, &rank, result, MPI_INT, MPI_PROC_NULL, 0, win);
191 /** TEST REQUEST-BASED OPERATIONS (PASSIVE TARGET ONLY) **/
193 TEST_REQ_OP("Rput", req,
194 MPI_Rput(rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount, MPI_INT, win, &req);
196 TEST_REQ_OP("Rget", req,
197 MPI_Rget(rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount, MPI_INT, win, &req);
199 TEST_REQ_OP("Raccumulate", req,
200 MPI_Raccumulate(rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0,
201 rcount, MPI_INT, MPI_SUM, win, &req);
203 TEST_REQ_OP("Rget_accumulate", req,
204 MPI_Rget_accumulate(rmabuf, rcount, MPI_INT, result,
205 rcount, MPI_INT, MPI_PROC_NULL, 0,
206 rcount, MPI_INT, MPI_SUM, win, &req);
210 MTestFreeComm(&comm);
216 MTest_Finalize(errs);