Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'clean_events' of github.com:Takishipp/simgrid into clean_events
[simgrid.git] / teshsuite / smpi / mpich3-test / datatype / lots-of-types.c
index 418ff0b..c3f6e66 100644 (file)
@@ -10,7 +10,7 @@
 #include "mpi.h"
 #include "mpitest.h"
 
-/* 
+/*
    The default behavior of the test routines should be to briefly indicate
    the cause of any errors - in this test, that means that verbose needs
    to be set. Verbose should turn on output that is independent of error
 */
 static int verbose = 1;
 
+int main(int argc, char *argv[]);
 int parse_args(int argc, char **argv);
 int lots_of_types_test(void);
 
 struct test_struct_1 {
-    int a,b,c,d;
+    int a, b, c, d;
 };
 
 int main(int argc, char *argv[])
@@ -34,15 +35,16 @@ int main(int argc, char *argv[])
     parse_args(argc, argv);
 
     /* To improve reporting of problems about operations, we
-       change the error handler to errors return */
-    MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+     * change the error handler to errors return */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
 
     err = lots_of_types_test();
-    if (verbose && err) fprintf(stderr, "error in lots_of_types_test\n");
+    if (verbose && err)
+        fprintf(stderr, "error in lots_of_types_test\n");
     errs += err;
 
     /* print message and exit */
-    MTest_Finalize( errs );
+    MTest_Finalize(errs);
 
     MPI_Finalize();
     return 0;
@@ -71,107 +73,104 @@ int lots_of_types_test(void)
     int disps[NUM_BLOCKS];
     int blks[NUM_BLOCKS];
 
-    for (i=0; i < NUM_DTYPES; i++)
+    for (i = 0; i < NUM_DTYPES; i++)
         mytypes[i] = MPI_DATATYPE_NULL;
 
-    for (i=0; i < NUM_DTYPES; i++) {
-       int j;
-
-       disps[0] = 0;
-       blks[0]  = 4;
-       
-       for (j=1; j < NUM_BLOCKS; j++) {
-           disps[j] = 4 * j;
-           blks[j]  = (j % 3) + 1;
-       }
-
-       err = MPI_Type_indexed(NUM_BLOCKS, blks, disps, MPI_INT, &mytypes[i]);
-       if (err != MPI_SUCCESS) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "MPI_Type_indexed returned error on type %d\n",
-                       i);
-           }
+    for (i = 0; i < NUM_DTYPES; i++) {
+        int j;
+
+        disps[0] = 0;
+        blks[0] = 4;
+
+        for (j = 1; j < NUM_BLOCKS; j++) {
+            disps[j] = 4 * j;
+            blks[j] = (j % 3) + 1;
+        }
+
+        err = MPI_Type_indexed(NUM_BLOCKS, blks, disps, MPI_INT, &mytypes[i]);
+        if (err != MPI_SUCCESS) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "MPI_Type_indexed returned error on type %d\n", i);
+            }
             mytypes[i] = MPI_DATATYPE_NULL;
             goto fn_exit;
-       }
-       
-       MPI_Type_commit(&mytypes[i]);
+        }
+
+        MPI_Type_commit(&mytypes[i]);
     }
 
-    for (i=0; i < NUM_DTYPES; i++) {
-       int j;
-       int recvbuf[4] = { -1, -1, -1, -1 };
-
-       /* we will only receive 4 ints, so short buffer is ok */
-       err = MPI_Irecv(recvbuf, 1, mytypes[i], 0, 0, MPI_COMM_SELF, &request);
-       if (err != MPI_SUCCESS) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "MPI_Irecv returned error\n");
-           }
-       }
-       
-       err = MPI_Send(sendbuf, 4, MPI_INT, 0, 0, MPI_COMM_SELF);
-       if (err != MPI_SUCCESS) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "MPI_Send returned error\n");
-           }
-       }
-       
-       err = MPI_Wait(&request, &status);
-       if (err != MPI_SUCCESS) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "MPI_Wait returned error\n");
-           }
-       }
-       
-       /* verify data */
-       for (j=0; j < 4; j++) {
-           if (recvbuf[j] != sendbuf[j]) {
-               errs++;
-               if (verbose) {
-                   fprintf(stderr, "recvbuf[%d] = %d; should be %d\n",
-                           j, recvbuf[j], sendbuf[j]);
-               }
-           }
-       }
-
-       /* verify count and elements */
-       err = MPI_Get_count(&status, mytypes[i], &count);
-       if (err != MPI_SUCCESS) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "MPI_Get_count returned error\n");
-           }
-       }
-       if (count != MPI_UNDEFINED) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "count = %d; should be MPI_UNDEFINED (%d)\n",
-                       count, MPI_UNDEFINED);
-           }
-       }
-       
-       err = MPI_Get_elements(&status, mytypes[i], &elements);
-       if (err != MPI_SUCCESS) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "MPI_Get_elements returned error\n");
-           }
-       }
-       if (elements != 4) {
-           errs++;
-           if (verbose) {
-               fprintf(stderr, "elements = %d; should be 4\n", elements);
-           }
-       }
+    for (i = 0; i < NUM_DTYPES; i++) {
+        int j;
+        int recvbuf[4] = { -1, -1, -1, -1 };
+
+        /* we will only receive 4 ints, so short buffer is ok */
+        err = MPI_Irecv(recvbuf, 1, mytypes[i], 0, 0, MPI_COMM_SELF, &request);
+        if (err != MPI_SUCCESS) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "MPI_Irecv returned error\n");
+            }
+        }
+
+        err = MPI_Send(sendbuf, 4, MPI_INT, 0, 0, MPI_COMM_SELF);
+        if (err != MPI_SUCCESS) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "MPI_Send returned error\n");
+            }
+        }
+
+        err = MPI_Wait(&request, &status);
+        if (err != MPI_SUCCESS) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "MPI_Wait returned error\n");
+            }
+        }
+
+        /* verify data */
+        for (j = 0; j < 4; j++) {
+            if (recvbuf[j] != sendbuf[j]) {
+                errs++;
+                if (verbose) {
+                    fprintf(stderr, "recvbuf[%d] = %d; should be %d\n", j, recvbuf[j], sendbuf[j]);
+                }
+            }
+        }
+
+        /* verify count and elements */
+        err = MPI_Get_count(&status, mytypes[i], &count);
+        if (err != MPI_SUCCESS) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "MPI_Get_count returned error\n");
+            }
+        }
+        if (count != MPI_UNDEFINED) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "count = %d; should be MPI_UNDEFINED (%d)\n", count, MPI_UNDEFINED);
+            }
+        }
+
+        err = MPI_Get_elements(&status, mytypes[i], &elements);
+        if (err != MPI_SUCCESS) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "MPI_Get_elements returned error\n");
+            }
+        }
+        if (elements != 4) {
+            errs++;
+            if (verbose) {
+                fprintf(stderr, "elements = %d; should be 4\n", elements);
+            }
+        }
     }
 
- fn_exit:
-    for (i=0; i < NUM_DTYPES; i++) {
 fn_exit:
+    for (i = 0; i < NUM_DTYPES; i++) {
         if (mytypes[i] != MPI_DATATYPE_NULL)
             MPI_Type_free(&mytypes[i]);
     }
@@ -183,18 +182,18 @@ int lots_of_types_test(void)
 int parse_args(int argc, char **argv)
 {
     /*
-    int ret;
-
-    while ((ret = getopt(argc, argv, "v")) >= 0)
-    {
-       switch (ret) {
-           case 'v':
-               verbose = 1;
-               break;
-       }
-    }
-    */
+     * int ret;
+     *
+     * while ((ret = getopt(argc, argv, "v")) >= 0)
+     * {
+     * switch (ret) {
+     * case 'v':
+     * verbose = 1;
+     * break;
+     * }
+     * }
+     */
     if (argc > 1 && strcmp(argv[1], "-v") == 0)
-       verbose = 1;
+        verbose = 1;
     return 0;
 }