1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2008 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
12 * Run this test with 8 processes. This test was submitted by xxx
13 * as a result of problems seen with the ch3:shm device on a Solaris
14 * system. The symptom is that the test hangs; this is due to losing
15 * a message, probably due to a race condition in a message-queue update.
16 * As a test for race conditions, it may need to be run multiple times
17 * to expose a problem if a problem does exist.
20 #define LOOP_COUNT 10000
24 #define PROGRESS_COUNT 0xfff
25 static int verbose = 0;
26 static int loopProgress = 0;
28 int main( int argc, char *argv[] )
34 MPI_Init( &argc, &argv ) ;
35 MPI_Comm_size( MPI_COMM_WORLD, &nProc ) ;
36 MPI_Comm_rank( MPI_COMM_WORLD, &rank ) ;
38 for (i=1; i<argc; i++) {
39 if (strcmp(argv[i],"-v") == 0 ||
40 strcmp(argv[i],"--verbose") == 0) verbose = 1;
41 else if (strcmp(argv[i],"-p") == 0 ||
42 strcmp(argv[i],"--progress") == 0) loopProgress = 1;
45 fprintf( stderr, "%s: [ -v | --verbose ] [ -p | --progress ]\n",
54 sprintf( buf, "fast_mpi_%d.dmp", rank ) ;
55 pf = fopen( buf, "w" ) ;
57 else if (loopProgress) {
64 psend = (int**)calloc( nProc, sizeof( int *) ) ;
65 precv = (int**)calloc( nProc, sizeof( int *) ) ;
66 for( i = 0 ; i < nProc ; i++ ) {
67 psend[ i ] = (int*)calloc( DATA_SIZE, sizeof( int ) ) ;
68 precv[ i ] = (int*)calloc( DATA_SIZE, sizeof( int ) ) ;
70 for( i = 0 ; i < LOOP_COUNT ; i++ ) {
72 fprintf( pf, "Master : loop %d\n", i ) ;
75 else if (loopProgress && (i & PROGRESS_COUNT) == 0) {
76 fprintf( pf, "Master: loop %d\n", i ); fflush( pf );
78 for( j = 1 ; j < nProc ; j++ ) {
80 fprintf( pf, " read from child %d\n", j ) ;
83 status = MPI_Recv( precv[ j ], DATA_SIZE, MPI_INT, j, MP_TAG,
84 MPI_COMM_WORLD, MPI_STATUS_IGNORE ) ;
86 fprintf( pf, " read from child %d done, status = %d\n", j,
91 for( j = 1 ; j < nProc ; j++ ) {
93 fprintf( pf, " send to child %d\n", j ) ;
96 status = MPI_Send( psend[ j ], DATA_SIZE - 1, MPI_INT, j,
97 MP_TAG, MPI_COMM_WORLD ) ;
99 fprintf( pf, " send to child %d done, status = %d\n", j,
105 for( i = 0 ; i < nProc ; i++ ) {
114 psend = (int*)calloc( DATA_SIZE, sizeof( int ) ) ;
115 precv = (int*)calloc( DATA_SIZE, sizeof( int ) ) ;
116 for( i = 0 ; i < LOOP_COUNT ; i++ ) {
118 fprintf( pf, " send to master\n" ) ;
122 else if (loopProgress && (i & PROGRESS_COUNT) == 0) {
123 fprintf( pf, "Slave: loop %d\n", i ); fflush( pf );
126 status = MPI_Send( psend, DATA_SIZE - 1, MPI_INT, 0, MP_TAG,
129 fprintf( pf, " send to master done, status = %d\n", status ) ;
131 fprintf( pf, " read from master\n" ) ;
134 status = MPI_Recv( precv, DATA_SIZE, MPI_INT, 0, MP_TAG,
135 MPI_COMM_WORLD, MPI_STATUS_IGNORE ) ;
137 fprintf( pf, " read from master done, status = %d\n", status ) ;
149 /* This test fails if it hangs */
151 printf( " No Errors\n" );