X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d0ffc37686edcc803601f76ab51fdfed5fc2f241..2bb3a0d042a8a1deb91c18dba0cbdf42237413d4:/teshsuite/smpi/mpich3-test/pt2pt/rqfreeb.c diff --git a/teshsuite/smpi/mpich3-test/pt2pt/rqfreeb.c b/teshsuite/smpi/mpich3-test/pt2pt/rqfreeb.c index 1a6eab1216..c6abf8aab9 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/rqfreeb.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/rqfreeb.c @@ -9,7 +9,7 @@ #include "mpitest.h" /* Test Ibsend and Request_free */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { MPI_Comm comm = MPI_COMM_WORLD; int dest = 1, src = 0, tag = 1; @@ -19,103 +19,105 @@ int main( int argc, char *argv[] ) int errs = 0, rank, size; int bufsize, bsize; - MTest_Init( &argc, &argv ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); - MPI_Comm_size( MPI_COMM_WORLD, &size ); + MTest_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); if (src >= size || dest >= size) { - int r = src; - if (dest > r) r = dest; - fprintf( stderr, "This program requires %d processes\n", r-1 ); - MPI_Abort( MPI_COMM_WORLD, 1 ); + int r = src; + if (dest > r) + r = dest; + fprintf(stderr, "This program requires %d processes\n", r - 1); + MPI_Abort(MPI_COMM_WORLD, 1); } if (rank == src) { - MPI_Request r; + MPI_Request r; - MPI_Barrier( MPI_COMM_WORLD ); + MPI_Barrier(MPI_COMM_WORLD); - /* According to the standard, we must use the PACK_SIZE length of each - message in the computation of the message buffer size */ - MPI_Pack_size( 5, MPI_INT, comm, &s1 ); - bufsize = MPI_BSEND_OVERHEAD + s1 + 2000; - buf = (char *)malloc( bufsize ); - MPI_Buffer_attach( buf, bufsize ); + /* According to the standard, we must use the PACK_SIZE length of each + * message in the computation of the message buffer size */ + MPI_Pack_size(5, MPI_INT, comm, &s1); + bufsize = MPI_BSEND_OVERHEAD + s1 + 2000; + buf = (char *) malloc(bufsize); + MPI_Buffer_attach(buf, bufsize); - MTestPrintfMsg( 10, "About create and free Isend request\n" ); - smsg[0] = 10; - MPI_Isend( &smsg[0], 1, MPI_INT, dest, tag, comm, &r ); - MPI_Request_free( &r ); - if (r != MPI_REQUEST_NULL) { - errs++; - fprintf( stderr, "Request not set to NULL after request free\n" ); - } - MTestPrintfMsg( 10, "About create and free Ibsend request\n" ); - smsg[1] = 11; - MPI_Ibsend( &smsg[1], 1, MPI_INT, dest, tag+1, comm, &r ); - MPI_Request_free( &r ); - if (r != MPI_REQUEST_NULL) { - errs++; - fprintf( stderr, "Request not set to NULL after request free\n" ); - } - MTestPrintfMsg( 10, "About create and free Issend request\n" ); - smsg[2] = 12; - MPI_Issend( &smsg[2], 1, MPI_INT, dest, tag+2, comm, &r ); - MPI_Request_free( &r ); - if (r != MPI_REQUEST_NULL) { - errs++; - fprintf( stderr, "Request not set to NULL after request free\n" ); - } - MTestPrintfMsg( 10, "About create and free Irsend request\n" ); - smsg[3] = 13; - MPI_Irsend( &smsg[3], 1, MPI_INT, dest, tag+3, comm, &r ); - MPI_Request_free( &r ); - if (r != MPI_REQUEST_NULL) { - errs++; - fprintf( stderr, "Request not set to NULL after request free\n" ); - } - smsg[4] = 14; - MPI_Isend( &smsg[4], 1, MPI_INT, dest, tag+4, comm, &r ); - MPI_Wait( &r, MPI_STATUS_IGNORE ); + MTestPrintfMsg(10, "About create and free Isend request\n"); + smsg[0] = 10; + MPI_Isend(&smsg[0], 1, MPI_INT, dest, tag, comm, &r); + MPI_Request_free(&r); + if (r != MPI_REQUEST_NULL) { + errs++; + fprintf(stderr, "Request not set to NULL after request free\n"); + } + MTestPrintfMsg(10, "About create and free Ibsend request\n"); + smsg[1] = 11; + MPI_Ibsend(&smsg[1], 1, MPI_INT, dest, tag + 1, comm, &r); + MPI_Request_free(&r); + if (r != MPI_REQUEST_NULL) { + errs++; + fprintf(stderr, "Request not set to NULL after request free\n"); + } + MTestPrintfMsg(10, "About create and free Issend request\n"); + smsg[2] = 12; + MPI_Issend(&smsg[2], 1, MPI_INT, dest, tag + 2, comm, &r); + MPI_Request_free(&r); + if (r != MPI_REQUEST_NULL) { + errs++; + fprintf(stderr, "Request not set to NULL after request free\n"); + } + MTestPrintfMsg(10, "About create and free Irsend request\n"); + smsg[3] = 13; + MPI_Irsend(&smsg[3], 1, MPI_INT, dest, tag + 3, comm, &r); + MPI_Request_free(&r); + if (r != MPI_REQUEST_NULL) { + errs++; + fprintf(stderr, "Request not set to NULL after request free\n"); + } + smsg[4] = 14; + MPI_Isend(&smsg[4], 1, MPI_INT, dest, tag + 4, comm, &r); + MPI_Wait(&r, MPI_STATUS_IGNORE); - /* We can't guarantee that messages arrive until the detach */ - MPI_Buffer_detach( &bbuf, &bsize ); + /* We can't guarantee that messages arrive until the detach */ + MPI_Buffer_detach(&bbuf, &bsize); + free(buf); } if (rank == dest) { - MPI_Request r[5]; - int i; + MPI_Request r[5]; + int i; - for (i=0; i<5; i++) { - MPI_Irecv( &rmsg[i], 1, MPI_INT, src, tag+i, comm, &r[i] ); - } - if (rank != src) /* Just in case rank == src */ - MPI_Barrier( MPI_COMM_WORLD ); + for (i = 0; i < 5; i++) { + MPI_Irecv(&rmsg[i], 1, MPI_INT, src, tag + i, comm, &r[i]); + } + if (rank != src) /* Just in case rank == src */ + MPI_Barrier(MPI_COMM_WORLD); - for (i=0; i<4; i++) { - MPI_Wait( &r[i], MPI_STATUS_IGNORE ); - if (rmsg[i] != 10+i) { - errs++; - fprintf( stderr, "message %d (%d) should be %d\n", i, rmsg[i], 10+i ); - } - } - /* The MPI standard says that there is no way to use MPI_Request_free - safely with receive requests. A strict MPI implementation may - choose to consider these erroreous (an IBM MPI implementation - does so) */ + for (i = 0; i < 4; i++) { + MPI_Wait(&r[i], MPI_STATUS_IGNORE); + if (rmsg[i] != 10 + i) { + errs++; + fprintf(stderr, "message %d (%d) should be %d\n", i, rmsg[i], 10 + i); + } + } + /* The MPI standard says that there is no way to use MPI_Request_free + * safely with receive requests. A strict MPI implementation may + * choose to consider these erroreous (an IBM MPI implementation + * does so) */ #ifdef USE_STRICT_MPI - MPI_Wait( &r[4], MPI_STATUS_IGNORE ); + MPI_Wait(&r[4], MPI_STATUS_IGNORE); #else - MTestPrintfMsg( 10, "About free Irecv request\n" ); - MPI_Request_free( &r[4] ); + MTestPrintfMsg(10, "About free Irecv request\n"); + MPI_Request_free(&r[4]); #endif } if (rank != dest && rank != src) { - MPI_Barrier( MPI_COMM_WORLD ); + MPI_Barrier(MPI_COMM_WORLD); } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize();