X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/4c7a3670bc8e56e4f0fcdf46389c6aedc4b7b383..8808ddeb7a75657834c56da86b1a1e62a635957c:/teshsuite/smpi/mpich3-test/topo/distgraph1.c diff --git a/teshsuite/smpi/mpich3-test/topo/distgraph1.c b/teshsuite/smpi/mpich3-test/topo/distgraph1.c index de425868eb..20c66714a7 100644 --- a/teshsuite/smpi/mpich3-test/topo/distgraph1.c +++ b/teshsuite/smpi/mpich3-test/topo/distgraph1.c @@ -25,7 +25,7 @@ int size, rank; int **layout; #define MAX_LAYOUT_NAME_LEN 256 -char graph_layout_name[MAX_LAYOUT_NAME_LEN] = {'\0'}; +char graph_layout_name[MAX_LAYOUT_NAME_LEN] = { '\0' }; static void create_graph_layout(int graph_num) { @@ -33,51 +33,51 @@ static void create_graph_layout(int graph_num) if (rank == 0) { switch (graph_num) { - case 0: - strncpy(graph_layout_name, "deterministic complete graph", MAX_LAYOUT_NAME_LEN); - for (i = 0; i < size; i++) - for (j = 0; j < size; j++) - layout[i][j] = (i + 2) * (j + 1); - break; - case 1: - strncpy(graph_layout_name, "every other edge deleted", MAX_LAYOUT_NAME_LEN); - for (i = 0; i < size; i++) - for (j = 0; j < size; j++) - layout[i][j] = (j % 2 ? (i + 2) * (j + 1) : 0); - break; - case 2: - strncpy(graph_layout_name, "only self-edges", MAX_LAYOUT_NAME_LEN); - for (i = 0; i < size; i++) { - for (j = 0; j < size; j++) { - if (i == rank && j == rank) - layout[i][j] = 10 * (i + 1); - else - layout[i][j] = 0; - } + case 0: + strncpy(graph_layout_name, "deterministic complete graph", MAX_LAYOUT_NAME_LEN); + for (i = 0; i < size; i++) + for (j = 0; j < size; j++) + layout[i][j] = (i + 2) * (j + 1); + break; + case 1: + strncpy(graph_layout_name, "every other edge deleted", MAX_LAYOUT_NAME_LEN); + for (i = 0; i < size; i++) + for (j = 0; j < size; j++) + layout[i][j] = (j % 2 ? (i + 2) * (j + 1) : 0); + break; + case 2: + strncpy(graph_layout_name, "only self-edges", MAX_LAYOUT_NAME_LEN); + for (i = 0; i < size; i++) { + for (j = 0; j < size; j++) { + if (i == rank && j == rank) + layout[i][j] = 10 * (i + 1); + else + layout[i][j] = 0; } - break; - case 3: - strncpy(graph_layout_name, "no edges", MAX_LAYOUT_NAME_LEN); - for (i = 0; i < size; i++) - for (j = 0; j < size; j++) + } + break; + case 3: + strncpy(graph_layout_name, "no edges", MAX_LAYOUT_NAME_LEN); + for (i = 0; i < size; i++) + for (j = 0; j < size; j++) + layout[i][j] = 0; + break; + default: + strncpy(graph_layout_name, "a random incomplete graph", MAX_LAYOUT_NAME_LEN); + srand(graph_num); + + /* Create a connectivity graph; layout[i,j]==w represents an outward + * connectivity from i to j with weight w, w==0 is no edge. */ + for (i = 0; i < size; i++) { + for (j = 0; j < size; j++) { + /* disable about a third of the edges */ + if (((rand() * 1.0) / RAND_MAX) < 0.33) layout[i][j] = 0; - break; - default: - strncpy(graph_layout_name, "a random incomplete graph", MAX_LAYOUT_NAME_LEN); - srand(graph_num); - - /* Create a connectivity graph; layout[i,j]==w represents an outward - * connectivity from i to j with weight w, w==0 is no edge. */ - for (i = 0; i < size; i++) { - for (j = 0; j < size; j++) { - /* disable about a third of the edges */ - if (((rand() * 1.0) / RAND_MAX) < 0.33) - layout[i][j] = 0; - else - layout[i][j] = rand() % MAX_WEIGHT; - } + else + layout[i][j] = rand() % MAX_WEIGHT; } - break; + } + break; } } @@ -110,7 +110,7 @@ static int verify_comm(MPI_Comm comm) } else { MPI_Comm_dup(comm, &dupcomm); - comm = dupcomm; /* caller retains original comm value */ + comm = dupcomm; /* caller retains original comm value */ } MPI_Topo_test(comm, &topo_type); @@ -124,7 +124,8 @@ static int verify_comm(MPI_Comm comm) if (layout[i][rank]) j++; if (j != indegree) { - fprintf(stderr, "indegree does not match, expected=%d got=%d, layout='%s'\n", indegree, j, graph_layout_name); + fprintf(stderr, "indegree does not match, expected=%d got=%d, layout='%s'\n", indegree, + j, graph_layout_name); ++local_errs; } @@ -133,7 +134,8 @@ static int verify_comm(MPI_Comm comm) if (layout[rank][i]) j++; if (j != outdegree) { - fprintf(stderr, "outdegree does not match, expected=%d got=%d, layout='%s'\n", outdegree, j, graph_layout_name); + fprintf(stderr, "outdegree does not match, expected=%d got=%d, layout='%s'\n", + outdegree, j, graph_layout_name); ++local_errs; } @@ -143,7 +145,8 @@ static int verify_comm(MPI_Comm comm) } - MPI_Dist_graph_neighbors(comm, indegree, sources, sweights, outdegree, destinations, dweights); + MPI_Dist_graph_neighbors(comm, indegree, sources, sweights, outdegree, destinations, + dweights); /* For each incoming and outgoing edge in the matrix, search if * the query function listed it in the sources. */ @@ -210,6 +213,10 @@ static int verify_comm(MPI_Comm comm) if (dupcomm != MPI_COMM_NULL) MPI_Comm_free(&dupcomm); + free(sources); + free(sweights); + free(destinations); + free(dweights); return local_errs; } @@ -246,12 +253,12 @@ int main(int argc, char *argv[]) for (i = 0; i < NUM_GRAPHS; i++) { create_graph_layout(i); if (rank == 0) { - MTestPrintfMsg( 1, "using graph layout '%s'\n", graph_layout_name ); + MTestPrintfMsg(1, "using graph layout '%s'\n", graph_layout_name); } /* MPI_Dist_graph_create_adjacent */ if (rank == 0) { - MTestPrintfMsg( 1, "testing MPI_Dist_graph_create_adjacent\n" ); + MTestPrintfMsg(1, "testing MPI_Dist_graph_create_adjacent\n"); } indegree = 0; k = 0; @@ -295,8 +302,7 @@ int main(int argc, char *argv[]) /* MPI_Dist_graph_create() where each process specifies its * outgoing edges */ if (rank == 0) { - MTestPrintfMsg( 1, - "testing MPI_Dist_graph_create w/ outgoing only\n" ); + MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ outgoing only\n"); } sources[0] = rank; k = 0; @@ -319,8 +325,7 @@ int main(int argc, char *argv[]) /* MPI_Dist_graph_create() where each process specifies its * incoming edges */ if (rank == 0) { - MTestPrintfMsg( 1, - "testing MPI_Dist_graph_create w/ incoming only\n" ); + MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ incoming only\n"); } k = 0; for (j = 0; j < size; j++) { @@ -343,8 +348,7 @@ int main(int argc, char *argv[]) /* MPI_Dist_graph_create() where rank 0 specifies the entire * graph */ if (rank == 0) { - MTestPrintfMsg( 1, - "testing MPI_Dist_graph_create w/ rank 0 specifies only\n" ); + MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ rank 0 specifies only\n"); } p = 0; for (j = 0; j < size; j++) { @@ -369,8 +373,7 @@ int main(int argc, char *argv[]) * graph and all other ranks pass NULL. Can catch implementation * problems when MPI_UNWEIGHTED==NULL. */ if (rank == 0) { - MTestPrintfMsg( 1, - "testing MPI_Dist_graph_create w/ rank 0 specifies only -- NULLs\n"); + MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ rank 0 specifies only -- NULLs\n"); } p = 0; for (j = 0; j < size; j++) { @@ -412,7 +415,7 @@ int main(int argc, char *argv[]) /* MPI_Dist_graph_create() with no graph */ if (rank == 0) { - MTestPrintfMsg( 1, "testing MPI_Dist_graph_create w/ no graph\n" ); + MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ no graph\n"); } for (reorder = 0; reorder <= 1; reorder++) { MPI_Dist_graph_create(MPI_COMM_WORLD, 0, sources, degrees, @@ -425,21 +428,22 @@ int main(int argc, char *argv[]) MPI_Comm_free(&comm); } - /* MPI_Dist_graph_create() with no graph -- passing MPI_WEIGHTS_EMPTY - instead */ - /* NOTE that MPI_WEIGHTS_EMPTY was added in MPI-3 and does not - appear before then. This part of the test thus requires a check - on the MPI major version */ + /* MPI_Dist_graph_create() with no graph -- passing MPI_WEIGHTS_EMPTY + * instead */ + /* NOTE that MPI_WEIGHTS_EMPTY was added in MPI-3 and does not + * appear before then. This part of the test thus requires a check + * on the MPI major version */ #if MPI_VERSION >= 3 if (rank == 0) { - MTestPrintfMsg( 1, "testing MPI_Dist_graph_create w/ no graph\n" ); + MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ no graph\n"); } for (reorder = 0; reorder <= 1; reorder++) { MPI_Dist_graph_create(MPI_COMM_WORLD, 0, sources, degrees, destinations, MPI_WEIGHTS_EMPTY, MPI_INFO_NULL, reorder, &comm); MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted); if (!check_weighted) { - fprintf(stderr, "expected weighted == TRUE for the \"no graph -- MPI_WEIGHTS_EMPTY\" case\n"); + fprintf(stderr, + "expected weighted == TRUE for the \"no graph -- MPI_WEIGHTS_EMPTY\" case\n"); ++errs; } MPI_Comm_free(&comm); @@ -448,8 +452,7 @@ int main(int argc, char *argv[]) /* MPI_Dist_graph_create() with no graph -- passing NULLs instead */ if (rank == 0) { - MTestPrintfMsg( 1, - "testing MPI_Dist_graph_create w/ no graph -- NULLs\n" ); + MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ no graph -- NULLs\n"); } for (reorder = 0; reorder <= 1; reorder++) { MPI_Dist_graph_create(MPI_COMM_WORLD, 0, NULL, NULL, @@ -467,8 +470,7 @@ int main(int argc, char *argv[]) /* MPI_Dist_graph_create() with no graph -- passing NULLs+MPI_UNWEIGHTED instead */ if (rank == 0) { - MTestPrintfMsg( 1, - "testing MPI_Dist_graph_create w/ no graph -- NULLs+MPI_UNWEIGHTED\n" ); + MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ no graph -- NULLs+MPI_UNWEIGHTED\n"); } for (reorder = 0; reorder <= 1; reorder++) { MPI_Dist_graph_create(MPI_COMM_WORLD, 0, NULL, NULL, @@ -477,7 +479,8 @@ int main(int argc, char *argv[]) /* ambiguous if they are equal, only check when they are distinct values. */ if (MPI_UNWEIGHTED != NULL) { if (check_weighted) { - fprintf(stderr, "expected weighted == FALSE for the \"no graph -- NULLs+MPI_UNWEIGHTED\" case\n"); + fprintf(stderr, + "expected weighted == FALSE for the \"no graph -- NULLs+MPI_UNWEIGHTED\" case\n"); ++errs; } } @@ -486,12 +489,11 @@ int main(int argc, char *argv[]) /* MPI_Dist_graph_create_adjacent() with no graph */ if (rank == 0) { - MTestPrintfMsg( 1, - "testing MPI_Dist_graph_create_adjacent w/ no graph\n" ); + MTestPrintfMsg(1, "testing MPI_Dist_graph_create_adjacent w/ no graph\n"); } for (reorder = 0; reorder <= 1; reorder++) { MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, 0, sources, sweights, - 0, destinations, dweights, MPI_INFO_NULL, reorder, &comm); + 0, destinations, dweights, MPI_INFO_NULL, reorder, &comm); MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted); if (!check_weighted) { fprintf(stderr, "expected weighted == TRUE for the \"no graph\" case\n"); @@ -501,20 +503,22 @@ int main(int argc, char *argv[]) } /* MPI_Dist_graph_create_adjacent() with no graph -- passing MPI_WEIGHTS_EMPTY instead */ - /* NOTE that MPI_WEIGHTS_EMPTY was added in MPI-3 and does not - appear before then. This part of the test thus requires a check - on the MPI major version */ + /* NOTE that MPI_WEIGHTS_EMPTY was added in MPI-3 and does not + * appear before then. This part of the test thus requires a check + * on the MPI major version */ #if MPI_VERSION >= 3 if (rank == 0) { - MTestPrintfMsg( 1, - "testing MPI_Dist_graph_create_adjacent w/ no graph -- MPI_WEIGHTS_EMPTY\n" ); + MTestPrintfMsg(1, + "testing MPI_Dist_graph_create_adjacent w/ no graph -- MPI_WEIGHTS_EMPTY\n"); } for (reorder = 0; reorder <= 1; reorder++) { MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, 0, sources, MPI_WEIGHTS_EMPTY, - 0, destinations, MPI_WEIGHTS_EMPTY, MPI_INFO_NULL, reorder, &comm); + 0, destinations, MPI_WEIGHTS_EMPTY, MPI_INFO_NULL, reorder, + &comm); MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted); if (!check_weighted) { - fprintf(stderr, "expected weighted == TRUE for the \"no graph -- MPI_WEIGHTS_EMPTY\" case\n"); + fprintf(stderr, + "expected weighted == TRUE for the \"no graph -- MPI_WEIGHTS_EMPTY\" case\n"); ++errs; } MPI_Comm_free(&comm); @@ -523,12 +527,11 @@ int main(int argc, char *argv[]) /* MPI_Dist_graph_create_adjacent() with no graph -- passing NULLs instead */ if (rank == 0) { - MTestPrintfMsg( 1, - "testing MPI_Dist_graph_create_adjacent w/ no graph -- NULLs\n" ); + MTestPrintfMsg(1, "testing MPI_Dist_graph_create_adjacent w/ no graph -- NULLs\n"); } for (reorder = 0; reorder <= 1; reorder++) { MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, 0, NULL, NULL, - 0, NULL, NULL, MPI_INFO_NULL, reorder, &comm); + 0, NULL, NULL, MPI_INFO_NULL, reorder, &comm); MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted); /* ambiguous if they are equal, only check when they are distinct values. */ if (MPI_UNWEIGHTED != NULL) { @@ -542,17 +545,18 @@ int main(int argc, char *argv[]) /* MPI_Dist_graph_create_adjacent() with no graph -- passing NULLs+MPI_UNWEIGHTED instead */ if (rank == 0) { - MTestPrintfMsg( 1, -"testing MPI_Dist_graph_create_adjacent w/ no graph -- NULLs+MPI_UNWEIGHTED\n"); + MTestPrintfMsg(1, + "testing MPI_Dist_graph_create_adjacent w/ no graph -- NULLs+MPI_UNWEIGHTED\n"); } for (reorder = 0; reorder <= 1; reorder++) { MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, 0, NULL, MPI_UNWEIGHTED, - 0, NULL, MPI_UNWEIGHTED, MPI_INFO_NULL, reorder, &comm); + 0, NULL, MPI_UNWEIGHTED, MPI_INFO_NULL, reorder, &comm); MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted); /* ambiguous if they are equal, only check when they are distinct values. */ if (MPI_UNWEIGHTED != NULL) { if (check_weighted) { - fprintf(stderr, "expected weighted == FALSE for the \"no graph -- NULLs+MPI_UNWEIGHTED\" case\n"); + fprintf(stderr, + "expected weighted == FALSE for the \"no graph -- NULLs+MPI_UNWEIGHTED\" case\n"); ++errs; } } @@ -563,6 +567,11 @@ int main(int argc, char *argv[]) for (i = 0; i < size; i++) free(layout[i]); free(layout); + free(sources); + free(sweights); + free(destinations); + free(dweights); + free(degrees); #endif MTest_Finalize(errs);