From b9896649ce1f82f50252b3b9fdd561caa4d0bf9c Mon Sep 17 00:00:00 2001 From: Jeff Hammond Date: Wed, 20 Mar 2013 20:21:15 -0500 Subject: [PATCH] jeff's changes to the test suite for sleep() and coll6 --- test/mpi/basic/wtime.c | 2 +- test/mpi/coll/coll6.c | 67 +++++++++++--------- test/mpi/errors/faults/pt2ptf2.c | 2 +- test/mpi/group/gtranksperf.c | 7 +-- .../mpi_t/nem_fbox_fallback_to_queue_count.c | 4 +- test/mpi/manual/spawntest_master.c | 6 +- test/mpi/manual/testconnectserial.c | 2 +- test/mpi/threads/comm/comm_dup_deadlock.c | 6 +-- test/mpi/threads/comm/ctxdup.c | 6 +-- 9 files changed, 49 insertions(+), 53 deletions(-) diff --git a/test/mpi/basic/wtime.c b/test/mpi/basic/wtime.c index bcad008..5a137fe 100644 --- a/test/mpi/basic/wtime.c +++ b/test/mpi/basic/wtime.c @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) MPI_Comm_rank(MPI_COMM_WORLD, &i); dStart = MPI_Wtime(); - sleep(1); + MTestSleep(1); dFinish = MPI_Wtime(); dDuration = dFinish - dStart; diff --git a/test/mpi/coll/coll6.c b/test/mpi/coll/coll6.c index 5691357..c2ffac1 100644 --- a/test/mpi/coll/coll6.c +++ b/test/mpi/coll/coll6.c @@ -17,21 +17,24 @@ int main( int argc, char **argv ) int participants; int displs[MAX_PROCESSES]; int recv_counts[MAX_PROCESSES]; + MPI_Comm test_comm; MTest_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &rank ); MPI_Comm_size( MPI_COMM_WORLD, &size ); /* A maximum of MAX_PROCESSES processes can participate */ - if ( size > MAX_PROCESSES ) participants = MAX_PROCESSES; - else participants = size; - /* while (MAX_PROCESSES % participants) participants--; */ + participants = ( size > MAX_PROCESSES ) ? MAX_PROCESSES : size; + if (MAX_PROCESSES % participants) { - fprintf( stderr, "Number of processors must divide %d\n", - MAX_PROCESSES ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - } - if ( (rank < participants) ) { + fprintf( stderr, "Number of processors must divide %d\n", + MAX_PROCESSES ); + MPI_Abort( MPI_COMM_WORLD, 1 ); + } + + MPI_Comm_split(MPI_COMM_WORLD, rank /* for fabs(3) */ -#ifdef HAVE_UNISTD_H -#include /* for sleep(3) */ -#endif /* Measure and compare the relative performance of MPI_Group_translate_ranks * with small and large group2 sizes but a constant number of ranks. This @@ -89,10 +86,10 @@ int main( int argc, char *argv[] ) MPI_Barrier(comm); if (rank != 0) { - sleep(10); + MTestSleep(10); } else /* rank==0 */ { - sleep(1); /* try to avoid timing while everyone else is making syscalls */ + MTestSleep(1); /* try to avoid timing while everyone else is making syscalls */ MPI_Group_translate_ranks(grev, size, ranks, gworld, ranksout); /*throwaway iter*/ start = MPI_Wtime(); diff --git a/test/mpi/manual/mpi_t/nem_fbox_fallback_to_queue_count.c b/test/mpi/manual/mpi_t/nem_fbox_fallback_to_queue_count.c index c6dec0b..b397a99 100644 --- a/test/mpi/manual/mpi_t/nem_fbox_fallback_to_queue_count.c +++ b/test/mpi/manual/mpi_t/nem_fbox_fallback_to_queue_count.c @@ -92,13 +92,13 @@ void send_first_test() * FIXME: Ideally this should use a barrier, but that uses messages * internally and hence will sometimes screw up the asserts above. */ - sleep(1); + MTestSleep(1); } else if (rank == 1) { char recv_buf[BUF_COUNT]; MPI_Status status; - sleep(1); /* see above */ + MTestSleep(1); /* see above */ MPI_Recv(recv_buf, BUF_COUNT, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status); MPI_Recv(recv_buf, BUF_COUNT, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status); diff --git a/test/mpi/manual/spawntest_master.c b/test/mpi/manual/spawntest_master.c index 62e87fd..bb02481 100644 --- a/test/mpi/manual/spawntest_master.c +++ b/test/mpi/manual/spawntest_master.c @@ -48,11 +48,11 @@ int main( int argc, char *argv[] ) { MPI_Comm_free( &allcomm ); MPI_Comm_disconnect( &intercomm ); - fprintf(stdout, "%s:%d: Sleep starting; children should exit\n", + fprintf(stdout, "%s:%d: MTestSleep starting; children should exit\n", __FILE__, __LINE__ );fflush(stdout); - sleep(30); + MTestSleep(30); fprintf(stdout, - "%s:%d: Sleep done; all children should have already exited\n", + "%s:%d: MTestSleep done; all children should have already exited\n", __FILE__, __LINE__ );fflush(stdout); MPI_Finalize(); diff --git a/test/mpi/manual/testconnectserial.c b/test/mpi/manual/testconnectserial.c index 88d3bf4..10ef028 100644 --- a/test/mpi/manual/testconnectserial.c +++ b/test/mpi/manual/testconnectserial.c @@ -119,7 +119,7 @@ int main( int argc, char ** argv ) { if( expectedRank == 0 ) { /* Cleanup on rank zero - delete some files */ - sleep( 4 ); + MTestSleep( 4 ); unlink( actualFname ); free( actualFname ); unlink( globalFname ); diff --git a/test/mpi/threads/comm/comm_dup_deadlock.c b/test/mpi/threads/comm/comm_dup_deadlock.c index c44b8fd..23a28be 100644 --- a/test/mpi/threads/comm/comm_dup_deadlock.c +++ b/test/mpi/threads/comm/comm_dup_deadlock.c @@ -21,10 +21,6 @@ } \ } while (0) -#ifdef HAVE_WINDOWS_H -#define sleep(a) Sleep(a*1000) -#endif - MPI_Comm comms[NUM_THREADS]; MTEST_THREAD_LOCK_TYPE comm_lock; int rank, size; @@ -41,7 +37,7 @@ MTEST_THREAD_RETURN_TYPE test_comm_dup(void *arg) MPI_Comm comm, self_dup; if (*(int*)arg == rank) { - sleep(1); + MTestSleep(1); } MTest_thread_lock(&comm_lock); diff --git a/test/mpi/threads/comm/ctxdup.c b/test/mpi/threads/comm/ctxdup.c index 3f3a9b3..bad21a9 100644 --- a/test/mpi/threads/comm/ctxdup.c +++ b/test/mpi/threads/comm/ctxdup.c @@ -15,10 +15,6 @@ static char MTEST_Descrip[] = "Creating communications concurrently in different threads"; */ -#ifdef HAVE_WINDOWS_H -#define sleep(a) Sleep(a*1000) -#endif - MTEST_THREAD_RETURN_TYPE dup_thread(void *); MTEST_THREAD_RETURN_TYPE dup_thread(void *p) @@ -88,7 +84,7 @@ int main( int argc, char *argv[] ) /* If we're odd, send to our new thread and then delay */ if (rank & 0x1) { MPI_Ssend( buffer, 0, MPI_INT, rank, 0, MPI_COMM_WORLD ); - sleep(1); + MTestSleep(1); } MPI_Comm_dup( comm1, &comm4 ); -- 1.7.7.5 (Apple Git-26)