Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove warning with mc
[simgrid.git] / teshsuite / smpi / mpich3-test / coll / allgatherv4.c
index 60bf0a4..19f91c9 100644 (file)
 #define MAX_BUF   (32 * 1024 * 1024)
 #define LOOPS 10
 
-SMPI_VARINIT_GLOBAL(sbuf, char*);
-SMPI_VARINIT_GLOBAL(rbuf, char*);
-SMPI_VARINIT_GLOBAL(recvcounts, int*);
-SMPI_VARINIT_GLOBAL(displs, int*);
-SMPI_VARINIT_GLOBAL_AND_SET(errs, int, 0);
+char * sbuf, * rbuf;
+int * recvcounts, * displs;
+int errs = 0;
 
 /* #define dprintf printf */
 #define dprintf(...)
@@ -59,19 +57,19 @@ int main(int argc, char ** argv)
     if (LARGE_BUF * comm_size > MAX_BUF)
         goto fn_exit;
 
-    SMPI_VARGET_GLOBAL(sbuf) = (void *) calloc(MAX_BUF, 1);
-    SMPI_VARGET_GLOBAL(rbuf) = (void *) calloc(MAX_BUF, 1);
+    sbuf = (void *) calloc(MAX_BUF, 1);
+    rbuf = (void *) calloc(MAX_BUF, 1);
 
     srand(time(NULL));
 
-    SMPI_VARGET_GLOBAL(recvcounts) = (void *) malloc(comm_size * sizeof(int));
-    SMPI_VARGET_GLOBAL(displs) = (void *) malloc(comm_size * sizeof(int));
-    if (!SMPI_VARGET_GLOBAL(recvcounts) || !SMPI_VARGET_GLOBAL(displs) || !SMPI_VARGET_GLOBAL(sbuf) || !SMPI_VARGET_GLOBAL(rbuf)) {
+    recvcounts = (void *) malloc(comm_size * sizeof(int));
+    displs = (void *) malloc(comm_size * sizeof(int));
+    if (!recvcounts || !displs || !sbuf || !rbuf) {
         fprintf(stderr, "Unable to allocate memory:\n");
-       if (!SMPI_VARGET_GLOBAL(sbuf)) fprintf(stderr,"\tsbuf of %d bytes\n", MAX_BUF );
-       if (!SMPI_VARGET_GLOBAL(rbuf)) fprintf(stderr,"\trbuf of %d bytes\n", MAX_BUF );
-       if (!SMPI_VARGET_GLOBAL(recvcounts)) fprintf(stderr,"\trecvcounts of %zd bytes\n", comm_size * sizeof(int) );
-       if (!SMPI_VARGET_GLOBAL(displs)) fprintf(stderr,"\tdispls of %zd bytes\n", comm_size * sizeof(int) );
+       if (!sbuf) fprintf(stderr,"\tsbuf of %d bytes\n", MAX_BUF );
+       if (!rbuf) fprintf(stderr,"\trbuf of %d bytes\n", MAX_BUF );
+       if (!recvcounts) fprintf(stderr,"\trecvcounts of %zd bytes\n", comm_size * sizeof(int) );
+       if (!displs) fprintf(stderr,"\tdispls of %zd bytes\n", comm_size * sizeof(int) );
         fflush(stderr);
         MPI_Abort(MPI_COMM_WORLD, -1);
         exit(-1);
@@ -112,13 +110,13 @@ int main(int argc, char ** argv)
     comm_tests(comm);
     MPI_Comm_free(&comm);
 
-    //free(SMPI_VARGET_GLOBAL(sbuf));
-    //free(SMPI_VARGET_GLOBAL(rbuf));
-    free(SMPI_VARGET_GLOBAL(recvcounts));
-    free(SMPI_VARGET_GLOBAL(displs));
+    free(sbuf);
+    free(rbuf);
+    free(recvcounts);
+    free(displs);
 
 fn_exit:
-    MTest_Finalize(SMPI_VARGET_GLOBAL(errs));
+    MTest_Finalize(errs);
     MPI_Finalize();
 
     return 0;
@@ -190,16 +188,16 @@ double run_test(long long msg_size, MPI_Comm comm, test_t test_type,
     MPI_Comm_size(comm, &comm_size);
     MPI_Comm_rank(comm, &comm_rank);
 
-    SMPI_VARGET_GLOBAL(displs)[0] = 0;
+    displs[0] = 0;
     for (i = 0; i < comm_size; i++) {
         if (test_type == REGULAR)
-            SMPI_VARGET_GLOBAL(recvcounts)[i] = msg_size;
+            recvcounts[i] = msg_size;
         else if (test_type == BCAST)
-            SMPI_VARGET_GLOBAL(recvcounts)[i] = (!i) ? msg_size : 0;
+            recvcounts[i] = (!i) ? msg_size : 0;
         else if (test_type == SPIKE)
-            SMPI_VARGET_GLOBAL(recvcounts)[i] = (!i) ? (msg_size / 2) : (msg_size / (2 * (comm_size - 1)));
+            recvcounts[i] = (!i) ? (msg_size / 2) : (msg_size / (2 * (comm_size - 1)));
         else if (test_type == HALF_FULL)
-            SMPI_VARGET_GLOBAL(recvcounts)[i] = (i < (comm_size / 2)) ? (2 * msg_size) : 0;
+            recvcounts[i] = (i < (comm_size / 2)) ? (2 * msg_size) : 0;
         else if (test_type == LINEAR_DECREASE) {
             tmp = 2 * msg_size * (comm_size - 1 - i) / (comm_size - 1);
            if (tmp != (int)tmp) {
@@ -207,7 +205,7 @@ double run_test(long long msg_size, MPI_Comm comm, test_t test_type,
                MPI_Abort( MPI_COMM_WORLD, 1 );
                 exit(1);
            }
-            SMPI_VARGET_GLOBAL(recvcounts)[i] = (int) tmp;
+            recvcounts[i] = (int) tmp;
 
             /* If the maximum message size is too large, don't run */
             if (tmp > MAX_BUF) return 0;
@@ -216,8 +214,8 @@ double run_test(long long msg_size, MPI_Comm comm, test_t test_type,
             for (j = 0; j < i; j++) {
                 if (i - 1 + j >= comm_size) continue;
                 tmp = msg_size * comm_size / (log(comm_size) * i);
-                SMPI_VARGET_GLOBAL(recvcounts)[i - 1 + j] = (int) tmp;
-                SMPI_VARGET_GLOBAL(displs)[i - 1 + j] = 0;
+                recvcounts[i - 1 + j] = (int) tmp;
+                displs[i - 1 + j] = 0;
 
                 /* If the maximum message size is too large, don't run */
                 if (tmp > MAX_BUF) return 0;
@@ -225,7 +223,7 @@ double run_test(long long msg_size, MPI_Comm comm, test_t test_type,
         }
 
         if (i < comm_size - 1)
-            SMPI_VARGET_GLOBAL(displs)[i+1] = SMPI_VARGET_GLOBAL(displs)[i] + SMPI_VARGET_GLOBAL(recvcounts)[i];
+            displs[i+1] = displs[i] + recvcounts[i];
     }
 
     /* Test that:
@@ -236,8 +234,8 @@ double run_test(long long msg_size, MPI_Comm comm, test_t test_type,
     MPI_Barrier(comm);
     start = MPI_Wtime();
     for (i = 0; i < LOOPS; i++) {
-        MPI_Allgatherv(SMPI_VARGET_GLOBAL(sbuf), SMPI_VARGET_GLOBAL(recvcounts)[comm_rank], MPI_CHAR,
-                       SMPI_VARGET_GLOBAL(rbuf), SMPI_VARGET_GLOBAL(recvcounts), SMPI_VARGET_GLOBAL(displs), MPI_CHAR, comm);
+        MPI_Allgatherv(sbuf, recvcounts[comm_rank], MPI_CHAR,
+                       rbuf, recvcounts, displs, MPI_CHAR, comm);
     }
     end = MPI_Wtime();
     MPI_Barrier(comm);