1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2003 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
13 static char MTEST_Descrip[] = "Create a communicator with a graph that contains null edges and one that contains duplicate edges";
16 int main( int argc, char *argv[] )
19 int *index = 0, *edges = 0;
20 int rank, size, i, j, crank, csize;
23 MTest_Init( &argc, &argv );
25 MPI_Comm_size( MPI_COMM_WORLD, &size );
26 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
28 index = (int *)malloc( size*sizeof(int) );
29 edges = (int *)malloc( size*sizeof(int) );
30 for (i=0; i<size; i++) {
34 /* As of MPI 2.1, self edges are permitted */
35 MPI_Graph_create( MPI_COMM_WORLD, size, index, edges, 0, &comm );
36 MPI_Comm_rank( comm, &crank );
37 MPI_Comm_size( comm, &csize );
40 fprintf( stderr, "Graph create with self links has size %d should be %d", csize, size );
44 MPI_Comm_free( &comm );
46 /* Create a graph with duplicate links */
47 index = (int *)malloc( size * sizeof(int) );
48 edges = (int *)malloc( size * 2 * sizeof(int) );
50 for (i=0; i<size; i++) {
52 edges[j++] = (i + 1) % size;
53 edges[j++] = (i + 1) % size;
55 /* As of MPI 2.1, duplicate edges are permitted */
56 MPI_Graph_create( MPI_COMM_WORLD, size, index, edges, 0, &comm );
57 MPI_Comm_rank( comm, &crank );
58 MPI_Comm_size( comm, &csize );
61 fprintf( stderr, "Graph create with duplicate links has size %d should be %d", csize, size );
65 MPI_Comm_free( &comm );
67 MTest_Finalize( errs );