1 /* -*- Mode: C; c-basic-offset:4 ; -*- */
6 int main( int argc, char *argv[] )
9 int i, j, ndims, totnodes, err, errcnt = 0;
11 MPI_Init( &argc, &argv );
13 MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
15 /* Try for error checks */
19 err = MPI_Dims_create( 26, 3, dims );
20 if (err == MPI_SUCCESS) {
21 printf( "The product of the specified dims does not divide the nnodes and MPI_Dims_create did not return an error\n" );
23 printf( "dims[%d] = %d\n", i, dims[i] );
28 /* Check for a few reasonable decompositions */
29 dims[0] = dims[1] = 0;
30 err = MPI_Dims_create( 16, 2, dims );
32 char msg[MPI_MAX_ERROR_STRING];
34 MPI_Error_string( err, msg, &result_len );
35 printf( "Unexpected error return from dims_create (16,2) %s\n", msg );
39 if (dims[0] * dims[1] != 16) {
40 printf( "Returned dimensions do not match request\n" );
46 printf( "Expected 4 x 4, got %d x %d\n", dims[0],dims[1] );
51 dims[0] = dims[1] = 0;
52 /* 60 = 2 * 2 * 3 * 5 */
53 err = MPI_Dims_create( 60, 2, dims );
55 char msg[MPI_MAX_ERROR_STRING];
57 MPI_Error_string( err, msg, &result_len );
58 printf( "Unexpected error return from dims_create (16,2) %s\n", msg );
62 if (dims[0] * dims[1] != 60) {
63 printf( "Returned dimensions do not match request (%d)\n",
68 if (dims[0] == 1 || dims[1] == 1) {
70 printf( "Expected rectangular decomp, got %d x %d\n",
76 /* Test a range of values */
77 for (ndims=1; ndims<=4; ndims++) {
78 for (i=2; i<64; i++) {
79 for (j=0; j<ndims; j++) {
82 MPI_Dims_create( i, ndims, dims );
83 /* Check the results */
85 for (j=0; j<ndims; j++) {
89 printf( "Non positive dims[%d] = %d for %d nodes and %d ndims\n",
90 j, dims[j], i, ndims );
95 printf( "Did not correctly partition %d nodes among %d dims (got %d nodes)\n",
99 for (j=0; j<ndims; j++) {
100 printf( " %d", dims[j] );
108 /* Summarize the results */
110 printf( " %d errors found\n", errcnt );
113 printf( " No Errors\n" );