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) continue;
134 /* Determine the sender and receiver */
135 MPI_Comm_rank( comm, &rank );
136 MPI_Comm_size( comm, &size );
138 MPI_Win_create( buf, bufsize, sizeof(int), MPI_INFO_NULL, comm, &win );
139 /* To improve reporting of problems about operations, we
140 change the error handler to errors return */
141 MPI_Win_set_errhandler( win, MPI_ERRORS_RETURN );
143 /** TEST OPERATIONS USING ACTIVE TARGET (FENCE) SYNCHRONIZATION **/
144 MPI_Win_fence( 0, win );
147 MPI_Put( rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0,
148 rcount, MPI_INT, win );
152 MPI_Get( rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0,
153 rcount, MPI_INT, win );
155 TEST_FENCE_OP("Accumulate",
156 MPI_Accumulate( rmabuf, rcount, MPI_INT, MPI_PROC_NULL,
157 0, rcount, MPI_INT, MPI_SUM, win );
159 TEST_FENCE_OP("Get accumulate",
160 MPI_Get_accumulate( rmabuf, rcount, MPI_INT, result,
161 rcount, MPI_INT, MPI_PROC_NULL, 0,
162 rcount, MPI_INT, MPI_SUM, win );
164 TEST_FENCE_OP("Fetch and op",
165 MPI_Fetch_and_op( rmabuf, result, MPI_INT, MPI_PROC_NULL,
168 TEST_FENCE_OP("Compare and swap",
169 MPI_Compare_and_swap( rmabuf, &rank, result, MPI_INT,
170 MPI_PROC_NULL, 0, win );
173 /** TEST OPERATIONS USING PASSIVE TARGET SYNCHRONIZATION **/
176 MPI_Put( rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount,
180 MPI_Get( rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount,
183 TEST_PT_OP("Accumulate",
184 MPI_Accumulate( rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0,
185 rcount, MPI_INT, MPI_SUM, win );
187 TEST_PT_OP("Get accumulate",
188 MPI_Get_accumulate( rmabuf, rcount, MPI_INT, result, rcount,
189 MPI_INT, MPI_PROC_NULL, 0, rcount,
190 MPI_INT, MPI_SUM, win );
192 TEST_PT_OP("Fetch and op",
193 MPI_Fetch_and_op( rmabuf, result, MPI_INT, MPI_PROC_NULL, 0,
196 TEST_PT_OP("Compare and swap",
197 MPI_Compare_and_swap( rmabuf, &rank, result, MPI_INT,
198 MPI_PROC_NULL, 0, win );
201 /** TEST REQUEST-BASED OPERATIONS (PASSIVE TARGET ONLY) **/
203 TEST_REQ_OP("Rput", req,
204 MPI_Rput( rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount,
205 MPI_INT, win, &req );
207 TEST_REQ_OP("Rget", req,
208 MPI_Rget( rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount,
209 MPI_INT, win, &req );
211 TEST_REQ_OP("Raccumulate", req,
212 MPI_Raccumulate( rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0,
213 rcount, MPI_INT, MPI_SUM, win, &req );
215 TEST_REQ_OP("Rget_accumulate", req,
216 MPI_Rget_accumulate( rmabuf, rcount, MPI_INT, result,
217 rcount, MPI_INT, MPI_PROC_NULL, 0,
218 rcount, MPI_INT, MPI_SUM, win, &req );
221 MPI_Win_free( &win );
222 MTestFreeComm(&comm);
228 MTest_Finalize( errs );