Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
update collectives teshsuite from mpich git (only minor changes)
[simgrid.git] / teshsuite / smpi / mpich3-test / coll / redscat3.c
index d2ed7ec..3ebf0be 100644 (file)
@@ -39,6 +39,7 @@ int main( int argc, char **argv )
        fprintf( stderr, "Could not allocate %d ints for recvcounts\n", 
                 size );
        MPI_Abort( MPI_COMM_WORLD, 1 );
+        exit(1);
     }
     mycount = (1024 * 1024) / size;
     for (i=0; i<size; i++) 
@@ -48,6 +49,7 @@ int main( int argc, char **argv )
        fprintf( stderr, "Could not allocate %d ints for sendbuf\n", 
                 mycount * size );
        MPI_Abort( MPI_COMM_WORLD, 1 );
+        exit(1);
     }
     idx = 0;
     for (i=0; i<size; i++) {
@@ -60,6 +62,7 @@ int main( int argc, char **argv )
        fprintf( stderr, "Could not allocate %d ints for recvbuf\n", 
                 mycount );
        MPI_Abort( MPI_COMM_WORLD, 1 );
+        exit(1);
     }
     for (i=0; i<mycount; i++) {
        recvbuf[i] = -1;
@@ -80,22 +83,28 @@ int main( int argc, char **argv )
        }
     }
 
+#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
     MPI_Reduce_scatter( MPI_IN_PLACE, sendbuf, recvcounts, MPI_INT, MPI_SUM, 
                        comm );
 
     sumval = size * rank + ((size - 1) * size)/2;
     /* recv'ed values for my process should be size * (rank + i) */
     for (i=0; i<mycount; i++) {
-       if (sendbuf[i] != sumval) {
-           err++;
-           if (err < MAX_ERRORS) {
-               fprintf( stdout, "Did not get expected value for reduce scatter (in place)\n" );
-               fprintf( stdout, "[%d] Got buf[%d] = %d expected %d\n", 
-                        rank, i, sendbuf[rank*mycount+i], sumval );
-           }
-       }
+        if (sendbuf[i] != sumval) {
+            err++;
+            if (err < MAX_ERRORS) {
+                fprintf( stdout, "Did not get expected value for reduce scatter (in place)\n" );
+                fprintf( stdout, "[%d] Got buf[%d] = %d expected %d\n",
+                    rank, i, sendbuf[i], sumval );
+            }
+        }
     }
 
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+    if (MPI_SUCCESS == MPI_Reduce_scatter(sendbuf, sendbuf, recvcounts, MPI_INT, MPI_SUM, comm))
+        err++;
+#endif
+
     free(sendbuf);
     free(recvbuf);
     free(recvcounts);