2 This test checks for possible interference between
3 successive calls to MPI_Allreduce. Some users, on some MPI implementations
4 and platforms, have had to add MPI_Barrier before MPI_Allreduce calls.
11 int main( int argc, char *argv[] )
13 int i, in_val, out_val;
15 int errs = 0, toterrs;
17 MPI_Init( &argc, &argv );
19 MPI_Comm_size( MPI_COMM_WORLD, &size );
20 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
21 for (i=0; i<MAX_LOOP; i++) {
22 in_val = (i & 0x1) ? 10 : -10;
23 MPI_Allreduce( &in_val, &out_val, 1, MPI_INT, MPI_SUM,
26 if (out_val != 10 * size) {
28 printf( "[%d] Error in out_val = %d\n", rank, out_val );
32 if (-out_val != 10 * size) {
34 printf( "[%d] Error in out_val = %d\n", rank, out_val );
38 MPI_Barrier( MPI_COMM_WORLD );
39 MPI_Allreduce( &errs, &toterrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
43 printf( " Found %d errors\n", toterrs );
45 printf( " No Errors\n" );