Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Upgrade coll mpich testlist to new mpich
[simgrid.git] / teshsuite / smpi / mpich3-test / coll / allgather2.c
index 66a21ec..01cf4ab 100644 (file)
 
 /* Gather data from a vector to contiguous.  Use IN_PLACE */
 
-int main( int argc, char **argv )
+int main(int argc, char **argv)
 {
     double *vecout;
     MPI_Comm comm;
-    int    count, minsize = 2;
-    int    i, errs = 0;
-    int    rank, size;
+    int count, minsize = 2;
+    int i, errs = 0;
+    int rank, size;
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
+
+    while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+        if (comm == MPI_COMM_NULL)
+            continue;
+        /* Determine the sender and receiver */
+        MPI_Comm_rank(comm, &rank);
+        MPI_Comm_size(comm, &size);
 
-    while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
-       if (comm == MPI_COMM_NULL) continue;
-       /* Determine the sender and receiver */
-       MPI_Comm_rank( comm, &rank );
-       MPI_Comm_size( comm, &size );
-       
         for (count = 1; count < 9000; count = count * 2) {
-            vecout = (double *)malloc( size * count * sizeof(double) );
-            
-            for (i=0; i<count; i++) {
-                vecout[rank*count+i] = rank*count+i;
+            vecout = (double *) malloc(size * count * sizeof(double));
+
+            for (i = 0; i < count; i++) {
+                vecout[rank * count + i] = rank * count + i;
             }
-            MPI_Allgather( MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, 
-                           vecout, count, MPI_DOUBLE, comm );
-            for (i=0; i<count*size; i++) {
+            MPI_Allgather(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, vecout, count, MPI_DOUBLE, comm);
+            for (i = 0; i < count * size; i++) {
                 if (vecout[i] != i) {
                     errs++;
                     if (errs < 10) {
-                        fprintf( stderr, "vecout[%d]=%d\n",
-                                 i, (int)vecout[i] );
+                        fprintf(stderr, "vecout[%d]=%d\n", i, (int) vecout[i]);
                     }
                 }
             }
-            free( vecout );
+            free(vecout);
         }
 
-       MTestFreeComm( &comm );
+        MTestFreeComm(&comm);
     }
 
-#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
-    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
-    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-    MPI_Comm_size(MPI_COMM_WORLD, &size);
-    vecout = (double *) malloc(size * sizeof(double));
-    if (MPI_SUCCESS == MPI_Allgather(&vecout[rank], 1, MPI_DOUBLE,
-                                      vecout, 1, MPI_DOUBLE, MPI_COMM_WORLD))
-        errs++;
-    free(vecout);
-#endif
-
-    MTest_Finalize( errs );
+    MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
 }
-
-