|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* (C) 2003 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include "mpi.h"
|
|
Packit Service |
c5cf8c |
#include <stdio.h>
|
|
Packit Service |
c5cf8c |
#include <stdlib.h>
|
|
Packit Service |
c5cf8c |
#include <string.h>
|
|
Packit Service |
c5cf8c |
#include <assert.h>
|
|
Packit Service |
c5cf8c |
#include "mpitest.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define NUM_GRAPHS 10
|
|
Packit Service |
c5cf8c |
#define MAX_WEIGHT 100
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* convenience globals */
|
|
Packit Service |
c5cf8c |
int size, rank;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* We need MPI 2.2 to be able to compile the following routines. */
|
|
Packit Service |
c5cf8c |
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Maybe use a bit vector instead? */
|
|
Packit Service |
c5cf8c |
int **layout;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define MAX_LAYOUT_NAME_LEN 256
|
|
Packit Service |
c5cf8c |
char graph_layout_name[MAX_LAYOUT_NAME_LEN] = { '\0' };
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
static void create_graph_layout(int graph_num)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int i, j;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
switch (graph_num) {
|
|
Packit Service |
c5cf8c |
case 0:
|
|
Packit Service |
c5cf8c |
strncpy(graph_layout_name, "deterministic complete graph", MAX_LAYOUT_NAME_LEN);
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; i++)
|
|
Packit Service |
c5cf8c |
for (j = 0; j < size; j++)
|
|
Packit Service |
c5cf8c |
layout[i][j] = (i + 2) * (j + 1);
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
case 1:
|
|
Packit Service |
c5cf8c |
strncpy(graph_layout_name, "every other edge deleted", MAX_LAYOUT_NAME_LEN);
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; i++)
|
|
Packit Service |
c5cf8c |
for (j = 0; j < size; j++)
|
|
Packit Service |
c5cf8c |
layout[i][j] = (j % 2 ? (i + 2) * (j + 1) : 0);
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
case 2:
|
|
Packit Service |
c5cf8c |
strncpy(graph_layout_name, "only self-edges", MAX_LAYOUT_NAME_LEN);
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; i++) {
|
|
Packit Service |
c5cf8c |
for (j = 0; j < size; j++) {
|
|
Packit Service |
c5cf8c |
if (i == rank && j == rank)
|
|
Packit Service |
c5cf8c |
layout[i][j] = 10 * (i + 1);
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
layout[i][j] = 0;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
case 3:
|
|
Packit Service |
c5cf8c |
strncpy(graph_layout_name, "no edges", MAX_LAYOUT_NAME_LEN);
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; i++)
|
|
Packit Service |
c5cf8c |
for (j = 0; j < size; j++)
|
|
Packit Service |
c5cf8c |
layout[i][j] = 0;
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
default:
|
|
Packit Service |
c5cf8c |
strncpy(graph_layout_name, "a random incomplete graph", MAX_LAYOUT_NAME_LEN);
|
|
Packit Service |
c5cf8c |
srand(graph_num);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Create a connectivity graph; layout[i,j]==w represents an outward
|
|
Packit Service |
c5cf8c |
* connectivity from i to j with weight w, w==0 is no edge. */
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; i++) {
|
|
Packit Service |
c5cf8c |
for (j = 0; j < size; j++) {
|
|
Packit Service |
c5cf8c |
/* disable about a third of the edges */
|
|
Packit Service |
c5cf8c |
if (((rand() * 1.0) / RAND_MAX) < 0.33)
|
|
Packit Service |
c5cf8c |
layout[i][j] = 0;
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
layout[i][j] = rand() % MAX_WEIGHT;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* because of the randomization we must determine the graph on rank 0 and
|
|
Packit Service |
c5cf8c |
* send the layout to all other processes */
|
|
Packit Service |
c5cf8c |
MPI_Bcast(graph_layout_name, MAX_LAYOUT_NAME_LEN, MPI_CHAR, 0, MPI_COMM_WORLD);
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; ++i) {
|
|
Packit Service |
c5cf8c |
MPI_Bcast(layout[i], size, MPI_INT, 0, MPI_COMM_WORLD);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
static int verify_comm(MPI_Comm comm)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int local_errs = 0;
|
|
Packit Service |
c5cf8c |
int i, j;
|
|
Packit Service |
c5cf8c |
int indegree, outdegree, weighted;
|
|
Packit Service |
c5cf8c |
int *sources, *sweights, *destinations, *dweights;
|
|
Packit Service |
c5cf8c |
int use_dup;
|
|
Packit Service |
c5cf8c |
int topo_type = MPI_UNDEFINED;
|
|
Packit Service |
c5cf8c |
MPI_Comm dupcomm = MPI_COMM_NULL;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
sources = (int *) malloc(size * sizeof(int));
|
|
Packit Service |
c5cf8c |
sweights = (int *) malloc(size * sizeof(int));
|
|
Packit Service |
c5cf8c |
destinations = (int *) malloc(size * sizeof(int));
|
|
Packit Service |
c5cf8c |
dweights = (int *) malloc(size * sizeof(int));
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
for (use_dup = 0; use_dup <= 1; ++use_dup) {
|
|
Packit Service |
c5cf8c |
if (!use_dup) {
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_neighbors_count(comm, &indegree, &outdegree, &weighted);
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
MPI_Comm_dup(comm, &dupcomm);
|
|
Packit Service |
c5cf8c |
comm = dupcomm; /* caller retains original comm value */
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Topo_test(comm, &topo_type);
|
|
Packit Service |
c5cf8c |
if (topo_type != MPI_DIST_GRAPH) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "topo_type != MPI_DIST_GRAPH\n");
|
|
Packit Service |
c5cf8c |
++local_errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
j = 0;
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; i++)
|
|
Packit Service |
c5cf8c |
if (layout[i][rank])
|
|
Packit Service |
c5cf8c |
j++;
|
|
Packit Service |
c5cf8c |
if (j != indegree) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "indegree does not match, expected=%d got=%d, layout='%s'\n", indegree,
|
|
Packit Service |
c5cf8c |
j, graph_layout_name);
|
|
Packit Service |
c5cf8c |
++local_errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
j = 0;
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; i++)
|
|
Packit Service |
c5cf8c |
if (layout[rank][i])
|
|
Packit Service |
c5cf8c |
j++;
|
|
Packit Service |
c5cf8c |
if (j != outdegree) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "outdegree does not match, expected=%d got=%d, layout='%s'\n",
|
|
Packit Service |
c5cf8c |
outdegree, j, graph_layout_name);
|
|
Packit Service |
c5cf8c |
++local_errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if ((indegree || outdegree) && (weighted == 0)) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "MPI_Dist_graph_neighbors_count thinks the graph is not weighted\n");
|
|
Packit Service |
c5cf8c |
++local_errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_neighbors(comm, indegree, sources, sweights, outdegree, destinations,
|
|
Packit Service |
c5cf8c |
dweights);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* For each incoming and outgoing edge in the matrix, search if
|
|
Packit Service |
c5cf8c |
* the query function listed it in the sources. */
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; i++) {
|
|
Packit Service |
c5cf8c |
if (layout[i][rank]) {
|
|
Packit Service |
c5cf8c |
for (j = 0; j < indegree; j++) {
|
|
Packit Service |
c5cf8c |
assert(sources[j] >= 0);
|
|
Packit Service |
c5cf8c |
assert(sources[j] < size);
|
|
Packit Service |
c5cf8c |
if (sources[j] == i)
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (j == indegree) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "no edge from %d to %d specified\n", i, rank);
|
|
Packit Service |
c5cf8c |
++local_errs;
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
if (sweights[j] != layout[i][rank]) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "incorrect weight for edge (%d,%d): %d instead of %d\n",
|
|
Packit Service |
c5cf8c |
i, rank, sweights[j], layout[i][rank]);
|
|
Packit Service |
c5cf8c |
++local_errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (layout[rank][i]) {
|
|
Packit Service |
c5cf8c |
for (j = 0; j < outdegree; j++) {
|
|
Packit Service |
c5cf8c |
assert(destinations[j] >= 0);
|
|
Packit Service |
c5cf8c |
assert(destinations[j] < size);
|
|
Packit Service |
c5cf8c |
if (destinations[j] == i)
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (j == outdegree) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "no edge from %d to %d specified\n", rank, i);
|
|
Packit Service |
c5cf8c |
++local_errs;
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
if (dweights[j] != layout[rank][i]) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "incorrect weight for edge (%d,%d): %d instead of %d\n",
|
|
Packit Service |
c5cf8c |
rank, i, dweights[j], layout[rank][i]);
|
|
Packit Service |
c5cf8c |
++local_errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* For each incoming and outgoing edge in the sources, we should
|
|
Packit Service |
c5cf8c |
* have an entry in the matrix */
|
|
Packit Service |
c5cf8c |
for (i = 0; i < indegree; i++) {
|
|
Packit Service |
c5cf8c |
if (layout[sources[i]][rank] != sweights[i]) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "edge (%d,%d) has a weight %d instead of %d\n", i, rank,
|
|
Packit Service |
c5cf8c |
sweights[i], layout[sources[i]][rank]);
|
|
Packit Service |
c5cf8c |
++local_errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
for (i = 0; i < outdegree; i++) {
|
|
Packit Service |
c5cf8c |
if (layout[rank][destinations[i]] != dweights[i]) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "edge (%d,%d) has a weight %d instead of %d\n", rank, i,
|
|
Packit Service |
c5cf8c |
dweights[i], layout[rank][destinations[i]]);
|
|
Packit Service |
c5cf8c |
++local_errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (dupcomm != MPI_COMM_NULL)
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&dupcomm);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
free(sources);
|
|
Packit Service |
c5cf8c |
free(sweights);
|
|
Packit Service |
c5cf8c |
free(destinations);
|
|
Packit Service |
c5cf8c |
free(dweights);
|
|
Packit Service |
c5cf8c |
return local_errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#endif /* At least MPI 2.2 */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int main(int argc, char *argv[])
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int errs = 0;
|
|
Packit Service |
c5cf8c |
int i, j, k, p;
|
|
Packit Service |
c5cf8c |
int indegree, outdegree, reorder;
|
|
Packit Service |
c5cf8c |
int check_indegree, check_outdegree, check_weighted;
|
|
Packit Service |
c5cf8c |
int *sources, *sweights, *destinations, *dweights, *degrees;
|
|
Packit Service |
c5cf8c |
MPI_Comm comm;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|
Packit Service |
c5cf8c |
MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
|
|
Packit Service |
c5cf8c |
layout = (int **) malloc(size * sizeof(int *));
|
|
Packit Service |
c5cf8c |
assert(layout);
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; i++) {
|
|
Packit Service |
c5cf8c |
layout[i] = (int *) malloc(size * sizeof(int));
|
|
Packit Service |
c5cf8c |
assert(layout[i]);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
/* alloc size*size ints to handle the all-on-one-process case */
|
|
Packit Service |
c5cf8c |
sources = (int *) malloc(size * size * sizeof(int));
|
|
Packit Service |
c5cf8c |
sweights = (int *) malloc(size * size * sizeof(int));
|
|
Packit Service |
c5cf8c |
destinations = (int *) malloc(size * size * sizeof(int));
|
|
Packit Service |
c5cf8c |
dweights = (int *) malloc(size * size * sizeof(int));
|
|
Packit Service |
c5cf8c |
degrees = (int *) malloc(size * size * sizeof(int));
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
for (i = 0; i < NUM_GRAPHS; i++) {
|
|
Packit Service |
c5cf8c |
create_graph_layout(i);
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
MTestPrintfMsg(1, "using graph layout '%s'\n", graph_layout_name);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* MPI_Dist_graph_create_adjacent */
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
MTestPrintfMsg(1, "testing MPI_Dist_graph_create_adjacent\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
indegree = 0;
|
|
Packit Service |
c5cf8c |
k = 0;
|
|
Packit Service |
c5cf8c |
for (j = 0; j < size; j++) {
|
|
Packit Service |
c5cf8c |
if (layout[j][rank]) {
|
|
Packit Service |
c5cf8c |
indegree++;
|
|
Packit Service |
c5cf8c |
sources[k] = j;
|
|
Packit Service |
c5cf8c |
sweights[k++] = layout[j][rank];
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
outdegree = 0;
|
|
Packit Service |
c5cf8c |
k = 0;
|
|
Packit Service |
c5cf8c |
for (j = 0; j < size; j++) {
|
|
Packit Service |
c5cf8c |
if (layout[rank][j]) {
|
|
Packit Service |
c5cf8c |
outdegree++;
|
|
Packit Service |
c5cf8c |
destinations[k] = j;
|
|
Packit Service |
c5cf8c |
dweights[k++] = layout[rank][j];
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
for (reorder = 0; reorder <= 1; reorder++) {
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, indegree, sources, sweights,
|
|
Packit Service |
c5cf8c |
outdegree, destinations, dweights, MPI_INFO_NULL,
|
|
Packit Service |
c5cf8c |
reorder, &comm);
|
|
Packit Service |
c5cf8c |
MPI_Barrier(comm);
|
|
Packit Service |
c5cf8c |
errs += verify_comm(comm);
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&comm);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* a weak check that passing MPI_UNWEIGHTED doesn't cause
|
|
Packit Service |
c5cf8c |
* create_adjacent to explode */
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, indegree, sources, MPI_UNWEIGHTED,
|
|
Packit Service |
c5cf8c |
outdegree, destinations, MPI_UNWEIGHTED, MPI_INFO_NULL,
|
|
Packit Service |
c5cf8c |
reorder, &comm);
|
|
Packit Service |
c5cf8c |
MPI_Barrier(comm);
|
|
Packit Service |
c5cf8c |
/* intentionally no verify here, weights won't match */
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&comm);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* MPI_Dist_graph_create() where each process specifies its
|
|
Packit Service |
c5cf8c |
* outgoing edges */
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ outgoing only\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
sources[0] = rank;
|
|
Packit Service |
c5cf8c |
k = 0;
|
|
Packit Service |
c5cf8c |
for (j = 0; j < size; j++) {
|
|
Packit Service |
c5cf8c |
if (layout[rank][j]) {
|
|
Packit Service |
c5cf8c |
destinations[k] = j;
|
|
Packit Service |
c5cf8c |
dweights[k++] = layout[rank][j];
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
degrees[0] = k;
|
|
Packit Service |
c5cf8c |
for (reorder = 0; reorder <= 1; reorder++) {
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_create(MPI_COMM_WORLD, 1, sources, degrees, destinations, dweights,
|
|
Packit Service |
c5cf8c |
MPI_INFO_NULL, reorder, &comm);
|
|
Packit Service |
c5cf8c |
MPI_Barrier(comm);
|
|
Packit Service |
c5cf8c |
errs += verify_comm(comm);
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&comm);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* MPI_Dist_graph_create() where each process specifies its
|
|
Packit Service |
c5cf8c |
* incoming edges */
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ incoming only\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
k = 0;
|
|
Packit Service |
c5cf8c |
for (j = 0; j < size; j++) {
|
|
Packit Service |
c5cf8c |
if (layout[j][rank]) {
|
|
Packit Service |
c5cf8c |
sources[k] = j;
|
|
Packit Service |
c5cf8c |
sweights[k] = layout[j][rank];
|
|
Packit Service |
c5cf8c |
degrees[k] = 1;
|
|
Packit Service |
c5cf8c |
destinations[k++] = rank;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
for (reorder = 0; reorder <= 1; reorder++) {
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_create(MPI_COMM_WORLD, k, sources, degrees, destinations, sweights,
|
|
Packit Service |
c5cf8c |
MPI_INFO_NULL, reorder, &comm);
|
|
Packit Service |
c5cf8c |
MPI_Barrier(comm);
|
|
Packit Service |
c5cf8c |
errs += verify_comm(comm);
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&comm);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* MPI_Dist_graph_create() where rank 0 specifies the entire
|
|
Packit Service |
c5cf8c |
* graph */
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ rank 0 specifies only\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
p = 0;
|
|
Packit Service |
c5cf8c |
for (j = 0; j < size; j++) {
|
|
Packit Service |
c5cf8c |
for (k = 0; k < size; k++) {
|
|
Packit Service |
c5cf8c |
if (layout[j][k]) {
|
|
Packit Service |
c5cf8c |
sources[p] = j;
|
|
Packit Service |
c5cf8c |
sweights[p] = layout[j][k];
|
|
Packit Service |
c5cf8c |
degrees[p] = 1;
|
|
Packit Service |
c5cf8c |
destinations[p++] = k;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
for (reorder = 0; reorder <= 1; reorder++) {
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_create(MPI_COMM_WORLD, (rank == 0) ? p : 0, sources, degrees,
|
|
Packit Service |
c5cf8c |
destinations, sweights, MPI_INFO_NULL, reorder, &comm);
|
|
Packit Service |
c5cf8c |
MPI_Barrier(comm);
|
|
Packit Service |
c5cf8c |
errs += verify_comm(comm);
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&comm);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* MPI_Dist_graph_create() where rank 0 specifies the entire
|
|
Packit Service |
c5cf8c |
* graph and all other ranks pass NULL. Can catch implementation
|
|
Packit Service |
c5cf8c |
* problems when MPI_UNWEIGHTED==NULL. */
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ rank 0 specifies only -- NULLs\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
p = 0;
|
|
Packit Service |
c5cf8c |
for (j = 0; j < size; j++) {
|
|
Packit Service |
c5cf8c |
for (k = 0; k < size; k++) {
|
|
Packit Service |
c5cf8c |
if (layout[j][k]) {
|
|
Packit Service |
c5cf8c |
sources[p] = j;
|
|
Packit Service |
c5cf8c |
sweights[p] = layout[j][k];
|
|
Packit Service |
c5cf8c |
degrees[p] = 1;
|
|
Packit Service |
c5cf8c |
destinations[p++] = k;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
for (reorder = 0; reorder <= 1; reorder++) {
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_create(MPI_COMM_WORLD, p, sources, degrees,
|
|
Packit Service |
c5cf8c |
destinations, sweights, MPI_INFO_NULL, reorder, &comm);
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_create(MPI_COMM_WORLD, 0, NULL, NULL,
|
|
Packit Service |
c5cf8c |
NULL, NULL, MPI_INFO_NULL, reorder, &comm);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Barrier(comm);
|
|
Packit Service |
c5cf8c |
errs += verify_comm(comm);
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&comm);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* now tests that don't depend on the layout[][] array */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* The MPI-2.2 standard recommends implementations set
|
|
Packit Service |
c5cf8c |
* MPI_UNWEIGHTED==NULL, but this leads to an ambiguity. The draft
|
|
Packit Service |
c5cf8c |
* MPI-3.0 standard specifically recommends _not_ setting it equal
|
|
Packit Service |
c5cf8c |
* to NULL. */
|
|
Packit Service |
c5cf8c |
if (MPI_UNWEIGHTED == NULL) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "MPI_UNWEIGHTED should not be NULL\n");
|
|
Packit Service |
c5cf8c |
++errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* MPI_Dist_graph_create() with no graph */
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ no graph\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
for (reorder = 0; reorder <= 1; reorder++) {
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_create(MPI_COMM_WORLD, 0, sources, degrees,
|
|
Packit Service |
c5cf8c |
destinations, sweights, MPI_INFO_NULL, reorder, &comm);
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted);
|
|
Packit Service |
c5cf8c |
if (!check_weighted) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "expected weighted == TRUE for the \"no graph\" case\n");
|
|
Packit Service |
c5cf8c |
++errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&comm);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* MPI_Dist_graph_create() with no graph -- passing MPI_WEIGHTS_EMPTY
|
|
Packit Service |
c5cf8c |
* instead */
|
|
Packit Service |
c5cf8c |
/* NOTE that MPI_WEIGHTS_EMPTY was added in MPI-3 and does not
|
|
Packit Service |
c5cf8c |
* appear before then. This part of the test thus requires a check
|
|
Packit Service |
c5cf8c |
* on the MPI major version */
|
|
Packit Service |
c5cf8c |
#if MPI_VERSION >= 3
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ no graph\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
for (reorder = 0; reorder <= 1; reorder++) {
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_create(MPI_COMM_WORLD, 0, sources, degrees,
|
|
Packit Service |
c5cf8c |
destinations, MPI_WEIGHTS_EMPTY, MPI_INFO_NULL, reorder, &comm);
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted);
|
|
Packit Service |
c5cf8c |
if (!check_weighted) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr,
|
|
Packit Service |
c5cf8c |
"expected weighted == TRUE for the \"no graph -- MPI_WEIGHTS_EMPTY\" case\n");
|
|
Packit Service |
c5cf8c |
++errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&comm);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* MPI_Dist_graph_create() with no graph -- passing NULLs instead */
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ no graph -- NULLs\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
for (reorder = 0; reorder <= 1; reorder++) {
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_create(MPI_COMM_WORLD, 0, NULL, NULL,
|
|
Packit Service |
c5cf8c |
NULL, NULL, MPI_INFO_NULL, reorder, &comm);
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted);
|
|
Packit Service |
c5cf8c |
/* ambiguous if they are equal, only check when they are distinct values. */
|
|
Packit Service |
c5cf8c |
if (MPI_UNWEIGHTED != NULL) {
|
|
Packit Service |
c5cf8c |
if (!check_weighted) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "expected weighted == TRUE for the \"no graph -- NULLs\" case\n");
|
|
Packit Service |
c5cf8c |
++errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&comm);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* MPI_Dist_graph_create() with no graph -- passing NULLs+MPI_UNWEIGHTED instead */
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ no graph -- NULLs+MPI_UNWEIGHTED\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
for (reorder = 0; reorder <= 1; reorder++) {
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_create(MPI_COMM_WORLD, 0, NULL, NULL,
|
|
Packit Service |
c5cf8c |
NULL, MPI_UNWEIGHTED, MPI_INFO_NULL, reorder, &comm);
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted);
|
|
Packit Service |
c5cf8c |
/* ambiguous if they are equal, only check when they are distinct values. */
|
|
Packit Service |
c5cf8c |
if (MPI_UNWEIGHTED != NULL) {
|
|
Packit Service |
c5cf8c |
if (check_weighted) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr,
|
|
Packit Service |
c5cf8c |
"expected weighted == FALSE for the \"no graph -- NULLs+MPI_UNWEIGHTED\" case\n");
|
|
Packit Service |
c5cf8c |
++errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&comm);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* MPI_Dist_graph_create_adjacent() with no graph */
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
MTestPrintfMsg(1, "testing MPI_Dist_graph_create_adjacent w/ no graph\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
for (reorder = 0; reorder <= 1; reorder++) {
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, 0, sources, sweights,
|
|
Packit Service |
c5cf8c |
0, destinations, dweights, MPI_INFO_NULL, reorder, &comm);
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted);
|
|
Packit Service |
c5cf8c |
if (!check_weighted) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "expected weighted == TRUE for the \"no graph\" case\n");
|
|
Packit Service |
c5cf8c |
++errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&comm);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* MPI_Dist_graph_create_adjacent() with no graph -- passing MPI_WEIGHTS_EMPTY instead */
|
|
Packit Service |
c5cf8c |
/* NOTE that MPI_WEIGHTS_EMPTY was added in MPI-3 and does not
|
|
Packit Service |
c5cf8c |
* appear before then. This part of the test thus requires a check
|
|
Packit Service |
c5cf8c |
* on the MPI major version */
|
|
Packit Service |
c5cf8c |
#if MPI_VERSION >= 3
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
MTestPrintfMsg(1,
|
|
Packit Service |
c5cf8c |
"testing MPI_Dist_graph_create_adjacent w/ no graph -- MPI_WEIGHTS_EMPTY\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
for (reorder = 0; reorder <= 1; reorder++) {
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, 0, sources, MPI_WEIGHTS_EMPTY,
|
|
Packit Service |
c5cf8c |
0, destinations, MPI_WEIGHTS_EMPTY, MPI_INFO_NULL, reorder,
|
|
Packit Service |
c5cf8c |
&comm);
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted);
|
|
Packit Service |
c5cf8c |
if (!check_weighted) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr,
|
|
Packit Service |
c5cf8c |
"expected weighted == TRUE for the \"no graph -- MPI_WEIGHTS_EMPTY\" case\n");
|
|
Packit Service |
c5cf8c |
++errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&comm);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* MPI_Dist_graph_create_adjacent() with no graph -- passing NULLs instead */
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
MTestPrintfMsg(1, "testing MPI_Dist_graph_create_adjacent w/ no graph -- NULLs\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
for (reorder = 0; reorder <= 1; reorder++) {
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, 0, NULL, NULL,
|
|
Packit Service |
c5cf8c |
0, NULL, NULL, MPI_INFO_NULL, reorder, &comm);
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted);
|
|
Packit Service |
c5cf8c |
/* ambiguous if they are equal, only check when they are distinct values. */
|
|
Packit Service |
c5cf8c |
if (MPI_UNWEIGHTED != NULL) {
|
|
Packit Service |
c5cf8c |
if (!check_weighted) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "expected weighted == TRUE for the \"no graph -- NULLs\" case\n");
|
|
Packit Service |
c5cf8c |
++errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&comm);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* MPI_Dist_graph_create_adjacent() with no graph -- passing NULLs+MPI_UNWEIGHTED instead */
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
MTestPrintfMsg(1,
|
|
Packit Service |
c5cf8c |
"testing MPI_Dist_graph_create_adjacent w/ no graph -- NULLs+MPI_UNWEIGHTED\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
for (reorder = 0; reorder <= 1; reorder++) {
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, 0, NULL, MPI_UNWEIGHTED,
|
|
Packit Service |
c5cf8c |
0, NULL, MPI_UNWEIGHTED, MPI_INFO_NULL, reorder, &comm);
|
|
Packit Service |
c5cf8c |
MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted);
|
|
Packit Service |
c5cf8c |
/* ambiguous if they are equal, only check when they are distinct values. */
|
|
Packit Service |
c5cf8c |
if (MPI_UNWEIGHTED != NULL) {
|
|
Packit Service |
c5cf8c |
if (check_weighted) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr,
|
|
Packit Service |
c5cf8c |
"expected weighted == FALSE for the \"no graph -- NULLs+MPI_UNWEIGHTED\" case\n");
|
|
Packit Service |
c5cf8c |
++errs;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&comm);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; i++)
|
|
Packit Service |
c5cf8c |
free(layout[i]);
|
|
Packit Service |
c5cf8c |
free(layout);
|
|
Packit Service |
c5cf8c |
free(sources);
|
|
Packit Service |
c5cf8c |
free(sweights);
|
|
Packit Service |
c5cf8c |
free(destinations);
|
|
Packit Service |
c5cf8c |
free(dweights);
|
|
Packit Service |
c5cf8c |
free(degrees);
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Finalize(errs);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return MTestReturnValue(errs);
|
|
Packit Service |
c5cf8c |
}
|