Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update group
authordegomme <augustin.degomme@unibas.ch>
Sat, 11 Feb 2017 20:15:28 +0000 (21:15 +0100)
committerdegomme <augustin.degomme@unibas.ch>
Sun, 12 Feb 2017 01:08:28 +0000 (02:08 +0100)
teshsuite/smpi/mpich3-test/group/CMakeLists.txt
teshsuite/smpi/mpich3-test/group/glpid.c [new file with mode: 0644]
teshsuite/smpi/mpich3-test/group/groupcreate.c
teshsuite/smpi/mpich3-test/group/groupnullincl.c
teshsuite/smpi/mpich3-test/group/grouptest.c
teshsuite/smpi/mpich3-test/group/grouptest2.c
teshsuite/smpi/mpich3-test/group/gtranks.c
teshsuite/smpi/mpich3-test/group/gtranksperf.c

index 4025562..1da613a 100644 (file)
@@ -9,7 +9,7 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
   include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi")
   include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../include/")
 
-  foreach(file groupcreate grouptest2 grouptest gtranks gtranksperf) #groupnullincl
+  foreach(file groupcreate grouptest2 grouptest gtranks gtranksperf) #groupnullincl glpid
     add_executable(${file} ${file}.c)
     target_link_libraries(${file} simgrid mtest_c)
   endforeach()
@@ -20,7 +20,7 @@ if (enable_smpi_MPICH3_testsuite AND HAVE_RAW_CONTEXTS)
   SET_TESTS_PROPERTIES(test-smpi-mpich3-group-raw PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
 endif()
 
-foreach(file groupcreate grouptest2 grouptest gtranks gtranksperf groupnullincl)
+foreach(file groupcreate grouptest2 grouptest gtranks gtranksperf groupnullincl glpid)
   set(examples_src  ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${file}.c)
 endforeach()
 
diff --git a/teshsuite/smpi/mpich3-test/group/glpid.c b/teshsuite/smpi/mpich3-test/group/glpid.c
new file mode 100644 (file)
index 0000000..d698af5
--- /dev/null
@@ -0,0 +1,45 @@
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *
+ *  (C) 2001 by Argonne National Laboratory.
+ *      See COPYRIGHT in top-level directory.
+ */
+#include <stdio.h>
+#include "mpi.h"
+#include "mpiimpl.h"
+
+int main(int argc, char *argv[])
+{
+    MPIR_Group group, *group_ptr = &group;
+    int i;
+
+    MPI_Init(&argc, &argv);
+
+    /* Setup a sample group */
+    group.handle = 1;
+    group.ref_count = 1;
+    group.size = 4;
+    group.rank = 0;
+    group.idx_of_first_lpid = -1;
+    group.lrank_to_lpid = (MPII_Group_pmap_t *)
+        MPL_malloc(group.size * sizeof(MPII_Group_pmap_t));
+    for (i = 0; i < group.size; i++) {
+        group.lrank_to_lpid[i].lrank = i;
+        group.lrank_to_lpid[i].lpid = group.size - i - 1;
+        group.lrank_to_lpid[i].next_lpid = -1;
+        group.lrank_to_lpid[i].flag = 0;
+    }
+
+    /* Set up the group lpid list */
+    MPII_Group_setup_lpid_list(group_ptr);
+
+    /* Print the group structure */
+    printf("Index of first lpid = %d\n", group.idx_of_first_lpid);
+    for (i = 0; i < group.size; i++) {
+        printf("lrank_to_lpid[%d].next_lpid = %d, .lpid = %d\n",
+               i, group.lrank_to_lpid[i].next_lpid, group.lrank_to_lpid[i].lpid);
+    }
+
+    MPI_Finalize();
+    return 0;
+}
index c8952d8..8079f55 100644 (file)
@@ -8,79 +8,79 @@
 /* stdlib.h Needed for malloc declaration */
 #include <stdlib.h>
 
-int main( int argc, char **argv )
+int main(int argc, char **argv)
 {
     int i, n, n_goal = 2048, n_all, rc, n_ranks, *ranks, rank, size, len;
     int group_size;
     MPI_Group *group_array, world_group;
     char msg[MPI_MAX_ERROR_STRING];
 
-    MPI_Init( &argc, &argv );
-    MPI_Comm_size( MPI_COMM_WORLD, &size );
-    MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+    MPI_Init(&argc, &argv);
+    MPI_Comm_size(MPI_COMM_WORLD, &size);
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
     n = n_goal;
-    
-    group_array = (MPI_Group *)malloc( n * sizeof(MPI_Group) );
 
-    MPI_Comm_group( MPI_COMM_WORLD, &world_group );
+    group_array = (MPI_Group *) malloc(n * sizeof(MPI_Group));
+
+    MPI_Comm_group(MPI_COMM_WORLD, &world_group);
 
     n_ranks = size;
-    ranks = (int *)malloc( size * sizeof(int) );
-    for (i=0; i<size; i++) ranks[i] = i;
+    ranks = (int *) malloc(size * sizeof(int));
+    for (i = 0; i < size; i++)
+        ranks[i] = i;
+
+    MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+    for (i = 0; i < n; i++) {
+        rc = MPI_Group_incl(world_group, n_ranks, ranks, group_array + i);
+        if (rc) {
+            fprintf(stderr, "Error when creating group number %d\n", i);
+            MPI_Error_string(rc, msg, &len);
+            fprintf(stderr, "%s\n", msg);
+            n = i + 1;
+            break;
+        }
+        else {
+            /* Check that the group was created (and that any errors were
+             * caught) */
+            rc = MPI_Group_size(group_array[i], &group_size);
+            if (group_size != size) {
+                fprintf(stderr, "Group number %d not correct (size = %d)\n", i, size);
+                n = i + 1;
+                break;
+            }
+        }
 
-    MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
-    for (i=0; i<n; i++) {
-       rc = MPI_Group_incl( world_group, n_ranks, ranks, group_array + i );
-       if (rc) {
-           fprintf( stderr, "Error when creating group number %d\n", i );
-           MPI_Error_string( rc, msg, &len );
-           fprintf( stderr, "%s\n", msg );
-           n = i + 1;
-           break;
-       }
-       else {
-           /* Check that the group was created (and that any errors were
-              caught) */
-           rc = MPI_Group_size( group_array[i], &group_size );
-           if (group_size != size) {
-               fprintf( stderr, "Group number %d not correct (size = %d)\n", 
-                        i, size );
-               n = i + 1; 
-               break;
-           }
-       }
-       
     }
 
-    for (i=0; i<n; i++) {
-       rc = MPI_Group_free( group_array + i );
-       if (rc) {
-           fprintf( stderr, "Error when freeing group number %d\n", i );
-           MPI_Error_string( rc, msg, &len );
-           fprintf( stderr, "%s\n", msg );
-           break;
-       }
+    for (i = 0; i < n; i++) {
+        rc = MPI_Group_free(group_array + i);
+        if (rc) {
+            fprintf(stderr, "Error when freeing group number %d\n", i);
+            MPI_Error_string(rc, msg, &len);
+            fprintf(stderr, "%s\n", msg);
+            break;
+        }
     }
 
-    MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL );
-    MPI_Group_free( &world_group );
+    MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL);
+    MPI_Group_free(&world_group);
 
-    MPI_Reduce( &n, &n_all, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD );
+    MPI_Reduce(&n, &n_all, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD);
     if (rank == 0) {
-       /* printf( "Completed test of %d type creations\n", n_all ); */
-       if (n_all != n_goal) {
-           printf (
-"This MPI implementation limits the number of groups that can be created\n\
+        /* printf("Completed test of %d type creations\n", n_all); */
+        if (n_all != n_goal) {
+            printf("This MPI implementation limits the number of groups that can be created\n\
 This is allowed by the standard and is not a bug, but is a limit on the\n\
-implementation\n" );
-       }
-       else {
-           printf( " No Errors\n" );
-       }
+implementation\n");
+        }
+        else {
+            printf(" No Errors\n");
+        }
     }
 
-    free( group_array );
+    free(group_array);
+    free(ranks);
 
-    MPI_Finalize( );
+    MPI_Finalize();
     return 0;
 }
index 029471b..0f6224b 100644 (file)
@@ -8,7 +8,7 @@
 #include <stdio.h>
 #include "mpitest.h"
 
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
     int errs = 0;
     int rc, result;
@@ -16,57 +16,58 @@ int main( int argc, char *argv[] )
     MPI_Group group, outgroup;
     MPI_Comm comm;
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&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);
 
-    while (MTestGetComm( &comm, 1 )) {
-       if (comm == MPI_COMM_NULL) continue;
+    while (MTestGetComm(&comm, 1)) {
+        if (comm == MPI_COMM_NULL)
+            continue;
 
-       MPI_Comm_group( comm, &group );
-       rc = MPI_Group_incl( group, 0, 0, &outgroup );
-       if (rc) {
-           errs++;
-           MTestPrintError( rc );
-           printf( "Error in creating an empty group with (0,0)\n" );
-           
-           /* Some MPI implementations may reject a null "ranks" pointer */
-           rc = MPI_Group_incl( group, 0, ranks, &outgroup );
-           if (rc) {
-               errs++;
-               MTestPrintError( rc );
-               printf( "Error in creating an empty group with (0,ranks)\n" );
-           }
-       }
+        MPI_Comm_group(comm, &group);
+        rc = MPI_Group_incl(group, 0, 0, &outgroup);
+        if (rc) {
+            errs++;
+            MTestPrintError(rc);
+            printf("Error in creating an empty group with (0,0)\n");
 
-       if (outgroup != MPI_GROUP_EMPTY) {
-           /* Is the group equivalent to group empty? */
-           rc = MPI_Group_compare( outgroup, MPI_GROUP_EMPTY, &result );
-           if (result != MPI_IDENT) {
-               errs++;
-               MTestPrintError( rc );
-               printf( "Did not create a group equivalent to an empty group\n" );
-           }
-       }
-       rc = MPI_Group_free( &group );
-       if (rc) {
-           errs++;
-           MTestPrintError( rc );
-       }           
-       if (outgroup != MPI_GROUP_NULL) {
-           rc = MPI_Group_free( &outgroup );
-           if (rc) {
-               errs++;
-               MTestPrintError( rc );
-           }
-       }
+            /* Some MPI implementations may reject a null "ranks" pointer */
+            rc = MPI_Group_incl(group, 0, ranks, &outgroup);
+            if (rc) {
+                errs++;
+                MTestPrintError(rc);
+                printf("Error in creating an empty group with (0,ranks)\n");
+            }
+        }
 
-       MTestFreeComm( &comm );
+        if (outgroup != MPI_GROUP_EMPTY) {
+            /* Is the group equivalent to group empty? */
+            rc = MPI_Group_compare(outgroup, MPI_GROUP_EMPTY, &result);
+            if (result != MPI_IDENT) {
+                errs++;
+                MTestPrintError(rc);
+                printf("Did not create a group equivalent to an empty group\n");
+            }
+        }
+        rc = MPI_Group_free(&group);
+        if (rc) {
+            errs++;
+            MTestPrintError(rc);
+        }
+        if (outgroup != MPI_GROUP_NULL) {
+            rc = MPI_Group_free(&outgroup);
+            if (rc) {
+                errs++;
+                MTestPrintError(rc);
+            }
+        }
+
+        MTestFreeComm(&comm);
     }
-    
-    MTest_Finalize( errs );
+
+    MTest_Finalize(errs);
     MPI_Finalize();
     return 0;
-  
+
 }
index e0e2d93..c2904de 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
     MPI_Group g1, g2, g4, g5, g45, selfgroup, g6;
     int ranks[16], size, rank, myrank, range[1][3];
     int errs = 0;
     int i, rin[16], rout[16], result;
 
-    MPI_Init(&argc,&argv);
-
-       MPI_Comm_group( MPI_COMM_WORLD, &g1 );
-       MPI_Comm_rank( MPI_COMM_WORLD, &myrank );
-       MPI_Comm_size( MPI_COMM_WORLD, &size );
-       if (size < 8) {
-           fprintf( stderr, 
-                 "Test requires 8 processes (16 prefered) only %d provided\n",
-                    size );
-           errs++;
-       }
-
-       /* 16 members, this process is rank 0, return in group 1 */
-       ranks[0] = myrank; ranks[1] = 2; ranks[2] = 7;
-       if (myrank == 2) ranks[1] = 3;
-       if (myrank == 7) ranks[2] = 6;
-       MPI_Group_incl( g1, 3, ranks, &g2 );
-       
-       /* Check the resulting group */
-       MPI_Group_size( g2, &size );
-       MPI_Group_rank( g2, &rank );
-       
-       if (size != 3) {
-           fprintf( stderr, "Size should be %d, is %d\n", 3, size );
-           errs++;
-       }
-       if (rank != 0) {
-           fprintf( stderr, "Rank should be %d, is %d\n", 0, rank );
-           errs++;
-       }
-
-       rin[0] = 0; rin[1] = 1; rin[2] = 2;
-       MPI_Group_translate_ranks( g2, 3, rin, g1, rout );
-       for (i=0; i<3; i++) {
-           if (rout[i] != ranks[i]) {
-               fprintf( stderr, "translated rank[%d] %d should be %d\n", 
-                        i, rout[i], ranks[i] );
-               errs++;
-           }
-       }
-       
-       /* Translate the process of the self group against another group */
-       MPI_Comm_group( MPI_COMM_SELF, &selfgroup );
-       rin[0] = 0;
-       MPI_Group_translate_ranks( selfgroup, 1, rin, g1, rout );
-       if (rout[0] != myrank) {
-           fprintf( stderr, "translated of self is %d should be %d\n", 
-                        rout[0], myrank );
-           errs++;
-       }
-
-       for (i=0; i<size; i++) 
-           rin[i] = i;
-       MPI_Group_translate_ranks( g1, size, rin, selfgroup, rout );
-       for (i=0; i<size; i++) {
-           if (i == myrank && rout[i] != 0) {
-               fprintf( stderr, "translated world to self of %d is %d\n",
-                        i, rout[i] );
-               errs++;
-           }
-           else if (i != myrank && rout[i] != MPI_UNDEFINED) {
-               fprintf( stderr, "translated world to self of %d should be undefined, is %d\n",
-                        i, rout[i] );
-               errs++;
-           }
-       }
-       MPI_Group_free( &selfgroup );
-
-       /* Exclude everyone in our group */
-       {
-           int ii, *lranks, g1size;
-
-           MPI_Group_size( g1, &g1size );
-           
-           lranks = (int *)malloc( g1size * sizeof(int) );
-           for (ii=0; ii<g1size; ii++) lranks[ii] = ii;
-           MPI_Group_excl( g1, g1size, lranks, &g6 );
-           if (g6 != MPI_GROUP_EMPTY) {
-               fprintf( stderr, "Group formed by excluding all ranks not empty\n" );
-               errs++;
-               MPI_Group_free( &g6 );
-           }
-           free( lranks );
-       }
-       
-       /* Add tests for additional group operations */
-       /* 
-          g2 = incl 1,3,7
-          g3 = excl 1,3,7
-          intersect ( w, g2 ) => g2
-          intersect ( w, g3 ) => g3
-          intersect ( g2, g3 ) => empty
-          
-          g4 = rincl 1:n-1:2
-          g5 = rexcl 1:n-1:2
-          union( g4, g5 ) => world
-          g6 = rincl n-1:1:-1 
-          g7 = rexcl n-1:1:-1
-          union( g6, g7 ) => concat of entries, similar to world
-          diff( w, g2 ) => g3
-       */
-       MPI_Group_free( &g2 );
-
-       range[0][0] = 1;
-       range[0][1] = size-1;
-       range[0][2] = 2;
-       MPI_Group_range_excl( g1, 1, range, &g5 );
-
-       range[0][0] = 1;
-       range[0][1] = size-1;
-       range[0][2] = 2;
-       MPI_Group_range_incl( g1, 1, range, &g4 );
-       MPI_Group_union( g4, g5, &g45 );
-       MPI_Group_compare( MPI_GROUP_EMPTY, g4, &result );
-       if (result != MPI_UNEQUAL) {
-           errs++;
-           fprintf( stderr, "Comparison with empty group gave %d, not 3\n",
-                    result );
-       }
-       MPI_Group_free( &g4 );
-       MPI_Group_free( &g5 );
-       MPI_Group_free( &g45 );
-
-       /* Now, duplicate the test, but using negative strides */
-       range[0][0] = size-1;
-       range[0][1] = 1;
-       range[0][2] = -2;
-       MPI_Group_range_excl( g1, 1, range, &g5 );
-
-       range[0][0] = size-1;
-       range[0][1] = 1;
-       range[0][2] = -2;
-       MPI_Group_range_incl( g1, 1, range, &g4 );
-
-       MPI_Group_union( g4, g5, &g45 );
-
-       MPI_Group_compare( MPI_GROUP_EMPTY, g4, &result );
-       if (result != MPI_UNEQUAL) {
-           errs++;
-           fprintf( stderr, "Comparison with empty group (formed with negative strides) gave %d, not 3\n",
-                    result );
-       }
-       MPI_Group_free( &g4 );
-       MPI_Group_free( &g5 );
-       MPI_Group_free( &g45 );
-        MPI_Group_free( &g1 );
-
-    if (myrank == 0) 
+    MPI_Init(&argc, &argv);
+
+    MPI_Comm_group(MPI_COMM_WORLD, &g1);
+    MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
+    MPI_Comm_size(MPI_COMM_WORLD, &size);
+    if (size < 8) {
+        fprintf(stderr, "Test requires 8 processes (16 prefered) only %d provided\n", size);
+        errs++;
+    }
+
+    /* 16 members, this process is rank 0, return in group 1 */
+    ranks[0] = myrank;
+    ranks[1] = 2;
+    ranks[2] = 7;
+    if (myrank == 2)
+        ranks[1] = 3;
+    if (myrank == 7)
+        ranks[2] = 6;
+    MPI_Group_incl(g1, 3, ranks, &g2);
+
+    /* Check the resulting group */
+    MPI_Group_size(g2, &size);
+    MPI_Group_rank(g2, &rank);
+
+    if (size != 3) {
+        fprintf(stderr, "Size should be %d, is %d\n", 3, size);
+        errs++;
+    }
+    if (rank != 0) {
+        fprintf(stderr, "Rank should be %d, is %d\n", 0, rank);
+        errs++;
+    }
+
+    rin[0] = 0;
+    rin[1] = 1;
+    rin[2] = 2;
+    MPI_Group_translate_ranks(g2, 3, rin, g1, rout);
+    for (i = 0; i < 3; i++) {
+        if (rout[i] != ranks[i]) {
+            fprintf(stderr, "translated rank[%d] %d should be %d\n", i, rout[i], ranks[i]);
+            errs++;
+        }
+    }
+
+    /* Translate the process of the self group against another group */
+    MPI_Comm_group(MPI_COMM_SELF, &selfgroup);
+    rin[0] = 0;
+    MPI_Group_translate_ranks(selfgroup, 1, rin, g1, rout);
+    if (rout[0] != myrank) {
+        fprintf(stderr, "translated of self is %d should be %d\n", rout[0], myrank);
+        errs++;
+    }
+
+    for (i = 0; i < size; i++)
+        rin[i] = i;
+    MPI_Group_translate_ranks(g1, size, rin, selfgroup, rout);
+    for (i = 0; i < size; i++) {
+        if (i == myrank && rout[i] != 0) {
+            fprintf(stderr, "translated world to self of %d is %d\n", i, rout[i]);
+            errs++;
+        }
+        else if (i != myrank && rout[i] != MPI_UNDEFINED) {
+            fprintf(stderr, "translated world to self of %d should be undefined, is %d\n",
+                    i, rout[i]);
+            errs++;
+        }
+    }
+    MPI_Group_free(&selfgroup);
+
+    /* Exclude everyone in our group */
     {
-       if (errs == 0) {
-           printf( " No Errors\n" );
-       }
-       else {
-           printf( "Found %d errors\n", errs );
-       }
+        int ii, *lranks, g1size;
+
+        MPI_Group_size(g1, &g1size);
+
+        lranks = (int *) malloc(g1size * sizeof(int));
+        for (ii = 0; ii < g1size; ii++)
+            lranks[ii] = ii;
+        MPI_Group_excl(g1, g1size, lranks, &g6);
+        if (g6 != MPI_GROUP_EMPTY) {
+            fprintf(stderr, "Group formed by excluding all ranks not empty\n");
+            errs++;
+            MPI_Group_free(&g6);
+        }
+        free(lranks);
+    }
+
+    /* Add tests for additional group operations */
+    /*
+     * g2 = incl 1,3,7
+     * g3 = excl 1,3,7
+     * intersect (w, g2) => g2
+     * intersect (w, g3) => g3
+     * intersect (g2, g3) => empty
+     *
+     * g4 = rincl 1:n-1:2
+     * g5 = rexcl 1:n-1:2
+     * union(g4, g5) => world
+     * g6 = rincl n-1:1:-1
+     * g7 = rexcl n-1:1:-1
+     * union(g6, g7) => concat of entries, similar to world
+     * diff(w, g2) => g3
+     */
+    MPI_Group_free(&g2);
+
+    range[0][0] = 1;
+    range[0][1] = size - 1;
+    range[0][2] = 2;
+    MPI_Group_range_excl(g1, 1, range, &g5);
+
+    range[0][0] = 1;
+    range[0][1] = size - 1;
+    range[0][2] = 2;
+    MPI_Group_range_incl(g1, 1, range, &g4);
+
+    MPI_Group_union(g4, g5, &g45);
+
+    MPI_Group_compare(MPI_GROUP_EMPTY, g4, &result);
+    if (result != MPI_UNEQUAL) {
+        errs++;
+        fprintf(stderr, "Comparison with empty group gave %d, not 3\n", result);
+    }
+    MPI_Group_free(&g4);
+    MPI_Group_free(&g5);
+    MPI_Group_free(&g45);
+
+    /* Now, duplicate the test, but using negative strides */
+    range[0][0] = size - 1;
+    range[0][1] = 1;
+    range[0][2] = -2;
+    MPI_Group_range_excl(g1, 1, range, &g5);
+
+    range[0][0] = size - 1;
+    range[0][1] = 1;
+    range[0][2] = -2;
+    MPI_Group_range_incl(g1, 1, range, &g4);
+
+    MPI_Group_union(g4, g5, &g45);
+
+    MPI_Group_compare(MPI_GROUP_EMPTY, g4, &result);
+    if (result != MPI_UNEQUAL) {
+        errs++;
+        fprintf(stderr,
+                "Comparison with empty group (formed with negative strides) gave %d, not 3\n",
+                result);
+    }
+    MPI_Group_free(&g4);
+    MPI_Group_free(&g5);
+    MPI_Group_free(&g45);
+    MPI_Group_free(&g1);
+
+    if (myrank == 0) {
+        if (errs == 0) {
+            printf(" No Errors\n");
+        }
+        else {
+            printf("Found %d errors\n", errs);
+        }
     }
 
     MPI_Finalize();
index 7d8fb7e..16bbaab 100644 (file)
@@ -24,190 +24,191 @@ MPI_Group_union
 /* stdlib.h Needed for malloc declaration */
 #include <stdlib.h>
 
-int main( int argc, char **argv )
+int main(int argc, char **argv)
 {
-    int errs=0, toterr;
+    int errs = 0, toterr;
     MPI_Group basegroup;
     MPI_Group g1, g2, g3, g4, g5, g6, g7, g8, g9, g10;
     MPI_Group g3a, g3b;
-    MPI_Comm  comm, newcomm, splitcomm, dupcomm;
-    int       i, grp_rank, rank, grp_size, size, result;
-    int       nranks, *ranks, *ranks_out;
-    int       range[1][3];
-    int       worldrank;
+    MPI_Comm comm, newcomm, splitcomm, dupcomm;
+    int i, grp_rank, rank, grp_size, size, result;
+    int nranks, *ranks, *ranks_out;
+    int range[1][3];
+    int worldrank;
 
-    MPI_Init( &argc, &argv );
-    MPI_Comm_rank( MPI_COMM_WORLD, &worldrank );
+    MPI_Init(&argc, &argv);
+    MPI_Comm_rank(MPI_COMM_WORLD, &worldrank);
 
     comm = MPI_COMM_WORLD;
 
-    MPI_Comm_group( comm, &basegroup );
-    MPI_Comm_rank( comm, &rank );
-    MPI_Comm_size( comm, &size );
+    MPI_Comm_group(comm, &basegroup);
+    MPI_Comm_rank(comm, &rank);
+    MPI_Comm_size(comm, &size);
 
 /* Get the basic information on this group */
-    MPI_Group_rank( basegroup, &grp_rank );
+    MPI_Group_rank(basegroup, &grp_rank);
     if (grp_rank != rank) {
-       errs++;
-       fprintf( stdout, "group rank %d != comm rank %d\n", grp_rank, rank );
+        errs++;
+        fprintf(stdout, "group rank %d != comm rank %d\n", grp_rank, rank);
     }
 
-    MPI_Group_size( basegroup, &grp_size );
+    MPI_Group_size(basegroup, &grp_size);
     if (grp_size != size) {
-       errs++;
-       fprintf( stdout, "group size %d != comm size %d\n", grp_size, size );
+        errs++;
+        fprintf(stdout, "group size %d != comm size %d\n", grp_size, size);
     }
 
 
 /* Form a new communicator with inverted ranking */
-    MPI_Comm_split( comm, 0, size - rank, &newcomm );
-    MPI_Comm_group( newcomm, &g1 );
-    ranks        = (int *)malloc( size * sizeof(int) );
-    ranks_out = (int *)malloc( size * sizeof(int) );
-    for (i=0; i<size; i++) ranks[i] = i;
+    MPI_Comm_split(comm, 0, size - rank, &newcomm);
+    MPI_Comm_group(newcomm, &g1);
+    ranks = (int *) malloc(size * sizeof(int));
+    ranks_out = (int *) malloc(size * sizeof(int));
+    for (i = 0; i < size; i++)
+        ranks[i] = i;
     nranks = size;
-    MPI_Group_translate_ranks( g1, nranks, ranks, basegroup, ranks_out );
-    for (i=0; i<size; i++) {
-       if (ranks_out[i] != (size - 1) - i) {
-           errs++;
-           fprintf( stdout, "Translate ranks got %d expected %d\n", 
-                    ranks_out[i], (size - 1) - i );
-       }
+    MPI_Group_translate_ranks(g1, nranks, ranks, basegroup, ranks_out);
+    for (i = 0; i < size; i++) {
+        if (ranks_out[i] != (size - 1) - i) {
+            errs++;
+            fprintf(stdout, "Translate ranks got %d expected %d\n", ranks_out[i], (size - 1) - i);
+        }
     }
 
 /* Check Compare */
-    MPI_Group_compare( basegroup, g1, &result );
+    MPI_Group_compare(basegroup, g1, &result);
     if (result != MPI_SIMILAR) {
-       errs++;
-       fprintf( stdout, "Group compare should have been similar, was %d\n",
-                result );
+        errs++;
+        fprintf(stdout, "Group compare should have been similar, was %d\n", result);
     }
-    MPI_Comm_dup( comm, &dupcomm );
-    MPI_Comm_group( dupcomm, &g2 );
-    MPI_Group_compare( basegroup, g2, &result );
+    MPI_Comm_dup(comm, &dupcomm);
+    MPI_Comm_group(dupcomm, &g2);
+    MPI_Group_compare(basegroup, g2, &result);
     if (result != MPI_IDENT) {
-       errs++;
-       fprintf( stdout, "Group compare should have been ident, was %d\n",
-                result );
+        errs++;
+        fprintf(stdout, "Group compare should have been ident, was %d\n", result);
     }
-    MPI_Comm_split( comm, rank < size/2, rank, &splitcomm );
-    MPI_Comm_group( splitcomm, &g3 );
-    MPI_Group_compare( basegroup, g3, &result );
+    MPI_Comm_split(comm, rank < size / 2, rank, &splitcomm);
+    MPI_Comm_group(splitcomm, &g3);
+    MPI_Group_compare(basegroup, g3, &result);
     if (result != MPI_UNEQUAL) {
-       errs++;
-       fprintf( stdout, "Group compare should have been unequal, was %d\n",
-                result );
+        errs++;
+        fprintf(stdout, "Group compare should have been unequal, was %d\n", result);
     }
 
     /* Build two groups that have this process and one other, but do not
-       have the same processes */
+     * have the same processes */
     ranks[0] = rank;
     ranks[1] = (rank + 1) % size;
-    MPI_Group_incl( basegroup, 2, ranks, &g3a );
+    MPI_Group_incl(basegroup, 2, ranks, &g3a);
     ranks[1] = (rank + size - 1) % size;
-    MPI_Group_incl( basegroup, 2, ranks, &g3b );
-    MPI_Group_compare( g3a, g3b, &result );
+    MPI_Group_incl(basegroup, 2, ranks, &g3b);
+    MPI_Group_compare(g3a, g3b, &result);
     if (result != MPI_UNEQUAL) {
         errs++;
-       fprintf( stdout, "Group compare of equal sized but different groups should have been unequal, was %d\n", result );
+        fprintf(stdout,
+                "Group compare of equal sized but different groups should have been unequal, was %d\n",
+                result);
     }
-    
+
 
 /* Build two new groups by excluding members; use Union to put them
    together again */
 
 /* Exclude 0 */
-    for (i=0; i<size; i++) ranks[i] = i;
-    MPI_Group_excl( basegroup, 1, ranks, &g4 );
+    for (i = 0; i < size; i++)
+        ranks[i] = i;
+    MPI_Group_excl(basegroup, 1, ranks, &g4);
 /* Exclude 1-(size-1) */
-    MPI_Group_excl( basegroup, size-1, ranks+1, &g5 );
-    MPI_Group_union( g5, g4, &g6 );
-    MPI_Group_compare( basegroup, g6, &result );
+    MPI_Group_excl(basegroup, size - 1, ranks + 1, &g5);
+    MPI_Group_union(g5, g4, &g6);
+    MPI_Group_compare(basegroup, g6, &result);
     if (result != MPI_IDENT) {
-       int usize;
-       errs++;
-       /* See ordering requirements on union */
-       fprintf( stdout, "Group excl and union did not give ident groups\n" );
-       fprintf( stdout, "[%d] result of compare was %d\n", rank, result );
-       MPI_Group_size( g6, &usize );
-       fprintf( stdout, "Size of union is %d, should be %d\n", usize, size );
+        int usize;
+        errs++;
+        /* See ordering requirements on union */
+        fprintf(stdout, "Group excl and union did not give ident groups\n");
+        fprintf(stdout, "[%d] result of compare was %d\n", rank, result);
+        MPI_Group_size(g6, &usize);
+        fprintf(stdout, "Size of union is %d, should be %d\n", usize, size);
     }
-    MPI_Group_union( basegroup, g4, &g7 );
-    MPI_Group_compare( basegroup, g7, &result );
+    MPI_Group_union(basegroup, g4, &g7);
+    MPI_Group_compare(basegroup, g7, &result);
     if (result != MPI_IDENT) {
-       int usize;
-       errs++;
-       fprintf( stdout, "Group union of overlapping groups failed\n" );
-       fprintf( stdout, "[%d] result of compare was %d\n", rank, result );
-       MPI_Group_size( g7, &usize );
-       fprintf( stdout, "Size of union is %d, should be %d\n", usize, size );
+        int usize;
+        errs++;
+        fprintf(stdout, "Group union of overlapping groups failed\n");
+        fprintf(stdout, "[%d] result of compare was %d\n", rank, result);
+        MPI_Group_size(g7, &usize);
+        fprintf(stdout, "Size of union is %d, should be %d\n", usize, size);
     }
 
 /* Use range_excl instead of ranks */
-    /* printf ("range excl\n" ); fflush( stdout ); */
+    /* printf ("range excl\n"); fflush(stdout); */
     range[0][0] = 1;
-    range[0][1] = size-1;
+    range[0][1] = size - 1;
     range[0][2] = 1;
-    MPI_Group_range_excl( basegroup, 1, range, &g8 );
-    /* printf( "out  of range excl\n" ); fflush( stdout ); */
-    MPI_Group_compare( g5, g8, &result );
-    /* printf( "out of compare\n" ); fflush( stdout ); */
+    MPI_Group_range_excl(basegroup, 1, range, &g8);
+    /* printf("out  of range excl\n"); fflush(stdout); */
+    MPI_Group_compare(g5, g8, &result);
+    /* printf("out of compare\n"); fflush(stdout); */
     if (result != MPI_IDENT) {
-       errs++;
-       fprintf( stdout, "Group range excl did not give ident groups\n" );
+        errs++;
+        fprintf(stdout, "Group range excl did not give ident groups\n");
     }
 
-    /* printf( "intersection\n" ); fflush( stdout ); */
-    MPI_Group_intersection( basegroup, g4, &g9 );
-    MPI_Group_compare( g9, g4, &result );
+    /* printf("intersection\n"); fflush(stdout); */
+    MPI_Group_intersection(basegroup, g4, &g9);
+    MPI_Group_compare(g9, g4, &result);
     if (result != MPI_IDENT) {
-       errs++;
-       fprintf( stdout, "Group intersection did not give ident groups\n" );
+        errs++;
+        fprintf(stdout, "Group intersection did not give ident groups\n");
     }
 
 /* Exclude EVERYTHING and check against MPI_GROUP_EMPTY */
-    /* printf( "range excl all\n" ); fflush( stdout ); */
+    /* printf("range excl all\n"); fflush(stdout); */
     range[0][0] = 0;
-    range[0][1] = size-1;
+    range[0][1] = size - 1;
     range[0][2] = 1;
-    MPI_Group_range_excl( basegroup, 1, range, &g10 );
+    MPI_Group_range_excl(basegroup, 1, range, &g10);
 
-    /* printf( "done range excl all\n" ); fflush(stdout); */
-    MPI_Group_compare( g10, MPI_GROUP_EMPTY, &result );
-    /* printf( "done compare to MPI_GROUP_EMPTY\n" ); fflush(stdout); */
+    /* printf("done range excl all\n"); fflush(stdout); */
+    MPI_Group_compare(g10, MPI_GROUP_EMPTY, &result);
+    /* printf("done compare to MPI_GROUP_EMPTY\n"); fflush(stdout); */
 
     if (result != MPI_IDENT) {
-       errs++;
-       fprintf( stdout, 
-                "MPI_GROUP_EMPTY didn't compare against empty group\n");
+        errs++;
+        fprintf(stdout, "MPI_GROUP_EMPTY didn't compare against empty group\n");
     }
 
-    /* printf( "freeing groups\n" ); fflush( stdout ); */
-    MPI_Group_free( &basegroup );
-    MPI_Group_free( &g1 );
-    MPI_Group_free( &g2 );
-    MPI_Group_free( &g3 );
-    MPI_Group_free( &g3a );
-    MPI_Group_free( &g3b );
-    MPI_Group_free( &g4 );
-    MPI_Group_free( &g5 );
-    MPI_Group_free( &g6 );
-    MPI_Group_free( &g7 );
-    MPI_Group_free( &g8 );
-    MPI_Group_free( &g9 );
-    MPI_Group_free( &g10 );
-    MPI_Comm_free( &dupcomm );
-    MPI_Comm_free( &splitcomm );
-    MPI_Comm_free( &newcomm );
-
-    MPI_Allreduce( &errs, &toterr, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
+    /* printf("freeing groups\n"); fflush(stdout); */
+    MPI_Group_free(&basegroup);
+    MPI_Group_free(&g1);
+    MPI_Group_free(&g2);
+    MPI_Group_free(&g3);
+    MPI_Group_free(&g3a);
+    MPI_Group_free(&g3b);
+    MPI_Group_free(&g4);
+    MPI_Group_free(&g5);
+    MPI_Group_free(&g6);
+    MPI_Group_free(&g7);
+    MPI_Group_free(&g8);
+    MPI_Group_free(&g9);
+    MPI_Group_free(&g10);
+    MPI_Comm_free(&dupcomm);
+    MPI_Comm_free(&splitcomm);
+    MPI_Comm_free(&newcomm);
+
+    MPI_Allreduce(&errs, &toterr, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
     if (worldrank == 0) {
-       if (toterr == 0) 
-           printf( " No Errors\n" );
-       else
-           printf( "Found %d errors in MPI Group routines\n", toterr );
+        if (toterr == 0)
+            printf(" No Errors\n");
+        else
+            printf("Found %d errors in MPI Group routines\n", toterr);
     }
 
+    free(ranks);
+    free(ranks_out);
     MPI_Finalize();
     return toterr;
 }
index 3e753a4..5b20967 100644 (file)
@@ -9,62 +9,56 @@
 
 #define MAX_WORLD_SIZE 1024
 
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
     int errs = 0;
-    int ranks[MAX_WORLD_SIZE], ranksout[MAX_WORLD_SIZE], 
-       ranksin[MAX_WORLD_SIZE];
+    int ranks[MAX_WORLD_SIZE], ranksout[MAX_WORLD_SIZE], ranksin[MAX_WORLD_SIZE];
     int range[1][3];
     MPI_Group gworld, gself, ngroup, galt;
-    MPI_Comm  comm;
+    MPI_Comm comm;
     int rank, size, i, nelms;
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
 
-    MPI_Comm_group( MPI_COMM_SELF, &gself );
+    MPI_Comm_group(MPI_COMM_SELF, &gself);
 
     comm = MPI_COMM_WORLD;
 
-    MPI_Comm_size( comm, &size );
-    MPI_Comm_rank( comm, &rank );
+    MPI_Comm_size(comm, &size);
+    MPI_Comm_rank(comm, &rank);
 
     if (size > MAX_WORLD_SIZE) {
-       fprintf( stderr, 
-        "This test requires a comm world with no more than %d processes\n", 
-                MAX_WORLD_SIZE );
-       MPI_Abort( MPI_COMM_WORLD, 1 );
-        exit(1);
+        fprintf(stderr,
+                "This test requires a comm world with no more than %d processes\n", MAX_WORLD_SIZE);
+        MPI_Abort(MPI_COMM_WORLD, 1);
     }
     if (size < 4) {
-       fprintf( stderr, "This test requiers at least 4 processes\n" );
-       MPI_Abort( MPI_COMM_WORLD, 1 );
-        exit(1);
+        fprintf(stderr, "This test requiers at least 4 processes\n");
+        MPI_Abort(MPI_COMM_WORLD, 1);
     }
 
-    MPI_Comm_group( comm, &gworld );
-    for (i=0; i<size; i++) {
-       ranks[i] = i;
-       ranksout[i] = -1;
+    MPI_Comm_group(comm, &gworld);
+    for (i = 0; i < size; i++) {
+        ranks[i] = i;
+        ranksout[i] = -1;
     }
     /* Try translating ranks from comm world compared against
-       comm self, so most will be UNDEFINED */
-    MPI_Group_translate_ranks( gworld, size, ranks, gself, ranksout );
-    
-    for (i=0; i<size; i++) {
-       if (i == rank) {
-           if (ranksout[i] != 0) {
-               printf( "[%d] Rank %d is %d but should be 0\n", rank, 
-                       i, ranksout[i] );
-               errs++;
-           }
-       }
-       else {
-           if (ranksout[i] != MPI_UNDEFINED) {
-               printf( "[%d] Rank %d is %d but should be undefined\n", rank, 
-                       i, ranksout[i] );
-               errs++;
-           }
-       }
+     * comm self, so most will be UNDEFINED */
+    MPI_Group_translate_ranks(gworld, size, ranks, gself, ranksout);
+
+    for (i = 0; i < size; i++) {
+        if (i == rank) {
+            if (ranksout[i] != 0) {
+                printf("[%d] Rank %d is %d but should be 0\n", rank, i, ranksout[i]);
+                errs++;
+            }
+        }
+        else {
+            if (ranksout[i] != MPI_UNDEFINED) {
+                printf("[%d] Rank %d is %d but should be undefined\n", rank, i, ranksout[i]);
+                errs++;
+            }
+        }
     }
 
     /* MPI-2 Errata requires that MPI_PROC_NULL is mapped to MPI_PROC_NULL */
@@ -72,98 +66,94 @@ int main( int argc, char *argv[] )
     ranks[1] = 1;
     ranks[2] = rank;
     ranks[3] = MPI_PROC_NULL;
-    for (i=0; i<4; i++) ranksout[i] = -1;
+    for (i = 0; i < 4; i++)
+        ranksout[i] = -1;
 
-    MPI_Group_translate_ranks( gworld, 4, ranks, gself, ranksout );
+    MPI_Group_translate_ranks(gworld, 4, ranks, gself, ranksout);
     if (ranksout[0] != MPI_PROC_NULL) {
-       printf( "[%d] Rank[0] should be MPI_PROC_NULL but is %d\n",
-               rank, ranksout[0] );
-       errs++;
+        printf("[%d] Rank[0] should be MPI_PROC_NULL but is %d\n", rank, ranksout[0]);
+        errs++;
     }
     if (rank != 1 && ranksout[1] != MPI_UNDEFINED) {
-       printf( "[%d] Rank[1] should be MPI_UNDEFINED but is %d\n",
-               rank, ranksout[1] );
-       errs++;
+        printf("[%d] Rank[1] should be MPI_UNDEFINED but is %d\n", rank, ranksout[1]);
+        errs++;
     }
     if (rank == 1 && ranksout[1] != 0) {
-       printf( "[%d] Rank[1] should be 0 but is %d\n",
-               rank, ranksout[1] );
-       errs++;
+        printf("[%d] Rank[1] should be 0 but is %d\n", rank, ranksout[1]);
+        errs++;
     }
     if (ranksout[2] != 0) {
-       printf( "[%d] Rank[2] should be 0 but is %d\n",
-               rank, ranksout[2] );
-       errs++;
+        printf("[%d] Rank[2] should be 0 but is %d\n", rank, ranksout[2]);
+        errs++;
     }
     if (ranksout[3] != MPI_PROC_NULL) {
-       printf( "[%d] Rank[3] should be MPI_PROC_NULL but is %d\n",
-               rank, ranksout[3] );
-       errs++;
+        printf("[%d] Rank[3] should be MPI_PROC_NULL but is %d\n", rank, ranksout[3]);
+        errs++;
     }
 
     MPI_Group_free(&gself);
 
     /* Now, try comparing small groups against larger groups, and use groups
-       with irregular members (to bypass optimizations in group_translate_ranks
-       for simple groups)
+     * with irregular members (to bypass optimizations in group_translate_ranks
+     * for simple groups)
      */
     nelms = 0;
     ranks[nelms++] = size - 2;
     ranks[nelms++] = 0;
     if (rank != 0 && rank != size - 2) {
-       ranks[nelms++] = rank; 
+        ranks[nelms++] = rank;
     }
 
-    MPI_Group_incl( gworld, nelms, ranks, &ngroup );
+    MPI_Group_incl(gworld, nelms, ranks, &ngroup);
 
-    for (i=0; i<nelms; i++) ranksout[i] = -1;
+    for (i = 0; i < nelms; i++)
+        ranksout[i] = -1;
     ranksin[0] = 1;
     ranksin[1] = 0;
     ranksin[2] = MPI_PROC_NULL;
     ranksin[3] = 2;
-    MPI_Group_translate_ranks( ngroup, nelms+1, ranksin, gworld, ranksout );
-    for (i=0; i<nelms+1; i++) {
-       if (ranksin[i] == MPI_PROC_NULL) {
-           if (ranksout[i] != MPI_PROC_NULL) {
-               fprintf( stderr, "Input rank for proc_null but output was %d\n",
-                        ranksout[i] );
-               errs++;
-           }
-       }
-       else if (ranksout[i] != ranks[ranksin[i]]) {
-           fprintf( stderr, "Expected ranksout[%d] = %d but found %d\n",
-                    i, ranks[ranksin[i]], ranksout[i] );
-           errs++;
-       }
+    MPI_Group_translate_ranks(ngroup, nelms + 1, ranksin, gworld, ranksout);
+    for (i = 0; i < nelms + 1; i++) {
+        if (ranksin[i] == MPI_PROC_NULL) {
+            if (ranksout[i] != MPI_PROC_NULL) {
+                fprintf(stderr, "Input rank for proc_null but output was %d\n", ranksout[i]);
+                errs++;
+            }
+        }
+        else if (ranksout[i] != ranks[ranksin[i]]) {
+            fprintf(stderr, "Expected ranksout[%d] = %d but found %d\n",
+                    i, ranks[ranksin[i]], ranksout[i]);
+            errs++;
+        }
     }
-    
-    range[0][0] = size -;
+
+    range[0][0] = size - 1;
     range[0][1] = 0;
     range[0][2] = -1;
-    MPI_Group_range_incl( gworld, 1, range, &galt);
-    for (i=0; i<nelms+1; i++) ranksout[i] = -1;
-    MPI_Group_translate_ranks( ngroup, nelms+1, ranksin, galt, ranksout );
-    for (i=0; i<nelms+1; i++) {
-       if (ranksin[i] == MPI_PROC_NULL) {
-           if (ranksout[i] != MPI_PROC_NULL) {
-               fprintf( stderr, "Input rank for proc_null but output was %d\n",
-                        ranksout[i] );
-               errs++;
-           }
-       }
-       else if (ranksout[i] != (size-1)-ranks[ranksin[i]]) {
-           fprintf( stderr, "Expected ranksout[%d] = %d but found %d\n",
-                    i, (size-1)-ranks[ranksin[i]], ranksout[i] );
-           errs++;
-       }
+    MPI_Group_range_incl(gworld, 1, range, &galt);
+    for (i = 0; i < nelms + 1; i++)
+        ranksout[i] = -1;
+    MPI_Group_translate_ranks(ngroup, nelms + 1, ranksin, galt, ranksout);
+    for (i = 0; i < nelms + 1; i++) {
+        if (ranksin[i] == MPI_PROC_NULL) {
+            if (ranksout[i] != MPI_PROC_NULL) {
+                fprintf(stderr, "Input rank for proc_null but output was %d\n", ranksout[i]);
+                errs++;
+            }
+        }
+        else if (ranksout[i] != (size - 1) - ranks[ranksin[i]]) {
+            fprintf(stderr, "Expected ranksout[%d] = %d but found %d\n",
+                    i, (size - 1) - ranks[ranksin[i]], ranksout[i]);
+            errs++;
+        }
     }
-    
-    
+
+
     MPI_Group_free(&gworld);
     MPI_Group_free(&galt);
     MPI_Group_free(&ngroup);
 
-    MTest_Finalize( errs );
+    MTest_Finalize(errs);
     MPI_Finalize();
 
     return 0;
index 9900aa3..4ccf58b 100644 (file)
@@ -8,7 +8,7 @@
 #include <stdlib.h>
 #include "mpitest.h"
 
-#include <math.h> /* for fabs(3) */
+#include <math.h>       /* for fabs(3) */
 
 /* Measure and compare the relative performance of MPI_Group_translate_ranks
  * with small and large group2 sizes but a constant number of ranks.  This
 /* number of iterations used for timing */
 #define NUM_LOOPS (1000000)
 
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
     int errs = 0;
     int *ranks;
     int *ranksout;
     MPI_Group gworld, grev, gself;
-    MPI_Comm  comm;
-    MPI_Comm  commrev;
+    MPI_Comm comm;
+    MPI_Comm commrev;
     int rank, size, i;
     double start, end, time1, time2;
 
-    MTest_Init( &argc, &argv );
+    MTest_Init(&argc, &argv);
 
     comm = MPI_COMM_WORLD;
 
-    MPI_Comm_size( comm, &size );
-    MPI_Comm_rank( comm, &rank );
+    MPI_Comm_size(comm, &size);
+    MPI_Comm_rank(comm, &rank);
 
-    ranks    = malloc(size*sizeof(int));
-    ranksout = malloc(size*sizeof(int));
+    ranks = malloc(size * sizeof(int));
+    ranksout = malloc(size * sizeof(int));
     if (!ranks || !ranksout) {
         fprintf(stderr, "out of memory\n");
         MPI_Abort(MPI_COMM_WORLD, 1);
-        exit(1);
     }
 
     /* generate a comm with the rank order reversed */
-    MPI_Comm_split(comm, 0, (size-rank-1), &commrev);
+    MPI_Comm_split(comm, 0, (size - rank - 1), &commrev);
     MPI_Comm_group(commrev, &grev);
     MPI_Comm_group(MPI_COMM_SELF, &gself);
     MPI_Comm_group(comm, &gworld);
 
     /* sanity check correctness first */
-    for (i=0; i < size; i++) {
+    for (i = 0; i < size; i++) {
         ranks[i] = i;
         ranksout[i] = -1;
     }
     MPI_Group_translate_ranks(grev, size, ranks, gworld, ranksout);
-    for (i=0; i < size; i++) {
-        if (ranksout[i] != (size-i-1)) {
+    for (i = 0; i < size; i++) {
+        if (ranksout[i] != (size - i - 1)) {
             if (rank == 0)
-                printf("%d: (gworld) expected ranksout[%d]=%d, got %d\n", rank, i, (size-rank-1), ranksout[i]);
+                printf("%d: (gworld) expected ranksout[%d]=%d, got %d\n", rank, i,
+                       (size - rank - 1), ranksout[i]);
             ++errs;
         }
     }
     MPI_Group_translate_ranks(grev, size, ranks, gself, ranksout);
-    for (i=0; i < size; i++) {
-        int expected = (i == (size-rank-1) ? 0 : MPI_UNDEFINED);
+    for (i = 0; i < size; i++) {
+        int expected = (i == (size - rank - 1) ? 0 : MPI_UNDEFINED);
         if (ranksout[i] != expected) {
             if (rank == 0)
-                printf("%d: (gself) expected ranksout[%d]=%d, got %d\n", rank, i, expected, ranksout[i]);
+                printf("%d: (gself) expected ranksout[%d]=%d, got %d\n", rank, i, expected,
+                       ranksout[i]);
             ++errs;
         }
     }
@@ -89,10 +90,11 @@ int main( int argc, char *argv[] )
     if (rank != 0) {
         MTestSleep(10);
     }
-    else /* rank==0 */ {
-        MTestSleep(1); /* try to avoid timing while everyone else is making syscalls */
+    else {      /* rank==0 */
 
-        MPI_Group_translate_ranks(grev, size, ranks, gworld, ranksout); /*throwaway iter*/
+        MTestSleep(1);  /* try to avoid timing while everyone else is making syscalls */
+
+        MPI_Group_translate_ranks(grev, size, ranks, gworld, ranksout); /*throwaway iter */
         start = MPI_Wtime();
         for (i = 0; i < NUM_LOOPS; ++i) {
             MPI_Group_translate_ranks(grev, size, ranks, gworld, ranksout);
@@ -100,7 +102,7 @@ int main( int argc, char *argv[] )
         end = MPI_Wtime();
         time1 = end - start;
 
-        MPI_Group_translate_ranks(grev, size, ranks, gself, ranksout); /*throwaway iter*/
+        MPI_Group_translate_ranks(grev, size, ranks, gself, ranksout);  /*throwaway iter */
         start = MPI_Wtime();
         for (i = 0; i < NUM_LOOPS; ++i) {
             MPI_Group_translate_ranks(grev, size, ranks, gself, ranksout);
@@ -112,7 +114,7 @@ int main( int argc, char *argv[] )
         if (fabs(time1 - time2) > (2.00 * time2)) {
             printf("too much difference in MPI_Group_translate_ranks performance:\n");
             printf("time1=%f time2=%f\n", time1, time2);
-            printf("(fabs(time1-time2)/time2)=%f\n", (fabs(time1-time2)/time2));
+            printf("(fabs(time1-time2)/time2)=%f\n", (fabs(time1 - time2) / time2));
             if (time1 < time2) {
                 printf("also, (time1<time2) is surprising...\n");
             }