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)
{
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;
}
}
}
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);
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;
}
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;
}
}
- 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. */
if (dupcomm != MPI_COMM_NULL)
MPI_Comm_free(&dupcomm);
+ free(sources);
+ free(sweights);
+ free(destinations);
+ free(dweights);
return local_errs;
}
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;
/* 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;
/* 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++) {
/* 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++) {
* 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++) {
/* 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,
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);
/* 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,
/* 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,
/* 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;
}
}
/* 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");
}
/* 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);
/* 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) {
/* 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;
}
}
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);