From e947a76de27ef7ddb85e5e3a0953711e410533f1 Mon Sep 17 00:00:00 2001 From: degomme Date: Sat, 11 Feb 2017 00:29:25 +0100 Subject: [PATCH] Update mpich pt2pt tests --- .../smpi/mpich3-test/pt2pt/CMakeLists.txt | 8 +- teshsuite/smpi/mpich3-test/pt2pt/anyall.c | 103 ++-- .../smpi/mpich3-test/pt2pt/big_count_status.c | 3 +- teshsuite/smpi/mpich3-test/pt2pt/bottom.c | 77 ++- teshsuite/smpi/mpich3-test/pt2pt/bsend1.c | 77 +-- teshsuite/smpi/mpich3-test/pt2pt/bsend2.c | 75 ++- teshsuite/smpi/mpich3-test/pt2pt/bsend3.c | 79 ++- teshsuite/smpi/mpich3-test/pt2pt/bsend4.c | 77 ++- teshsuite/smpi/mpich3-test/pt2pt/bsend5.c | 87 ++-- teshsuite/smpi/mpich3-test/pt2pt/bsendalign.c | 96 ++-- teshsuite/smpi/mpich3-test/pt2pt/bsendfrag.c | 150 +++--- .../smpi/mpich3-test/pt2pt/bsendpending.c | 224 ++++----- .../smpi/mpich3-test/pt2pt/cancelanysrc.c | 50 ++ teshsuite/smpi/mpich3-test/pt2pt/cancelrecv.c | 189 ++++--- teshsuite/smpi/mpich3-test/pt2pt/dtype_send.c | 101 ++++ teshsuite/smpi/mpich3-test/pt2pt/eagerdt.c | 80 +-- teshsuite/smpi/mpich3-test/pt2pt/greq1.c | 67 +-- teshsuite/smpi/mpich3-test/pt2pt/icsend.c | 89 ++-- .../smpi/mpich3-test/pt2pt/inactivereq.c | 151 +++--- teshsuite/smpi/mpich3-test/pt2pt/isendirecv.c | 50 ++ teshsuite/smpi/mpich3-test/pt2pt/isendself.c | 57 +-- .../smpi/mpich3-test/pt2pt/isendselfprobe.c | 38 +- .../smpi/mpich3-test/pt2pt/issendselfcancel.c | 3 +- .../smpi/mpich3-test/pt2pt/large_message.c | 98 ++-- teshsuite/smpi/mpich3-test/pt2pt/many_isend.c | 59 +++ teshsuite/smpi/mpich3-test/pt2pt/manylmt.c | 61 +++ teshsuite/smpi/mpich3-test/pt2pt/mprobe.c | 252 +++++++++- teshsuite/smpi/mpich3-test/pt2pt/pingping.c | 166 ++++--- .../smpi/mpich3-test/pt2pt/probe-unexp.c | 230 ++++----- teshsuite/smpi/mpich3-test/pt2pt/probenull.c | 52 +- teshsuite/smpi/mpich3-test/pt2pt/pscancel.c | 469 +++++++++--------- teshsuite/smpi/mpich3-test/pt2pt/rcancel.c | 109 ++-- teshsuite/smpi/mpich3-test/pt2pt/recv_any.c | 80 +++ teshsuite/smpi/mpich3-test/pt2pt/rqfreeb.c | 155 +++--- teshsuite/smpi/mpich3-test/pt2pt/rqstatus.c | 123 +++-- teshsuite/smpi/mpich3-test/pt2pt/scancel.c | 465 ++++++++--------- teshsuite/smpi/mpich3-test/pt2pt/scancel2.c | 99 ++-- .../smpi/mpich3-test/pt2pt/scancel_unmatch.c | 61 +++ teshsuite/smpi/mpich3-test/pt2pt/sendall.c | 106 ++-- teshsuite/smpi/mpich3-test/pt2pt/sendflood.c | 218 ++++---- teshsuite/smpi/mpich3-test/pt2pt/sendrecv1.c | 124 ++--- teshsuite/smpi/mpich3-test/pt2pt/sendrecv2.c | 155 +++--- teshsuite/smpi/mpich3-test/pt2pt/sendrecv3.c | 129 +++-- teshsuite/smpi/mpich3-test/pt2pt/sendself.c | 209 ++++---- teshsuite/smpi/mpich3-test/pt2pt/testlist | 1 + .../smpi/mpich3-test/pt2pt/waitany-null.c | 65 +-- .../smpi/mpich3-test/pt2pt/waittestnull.c | 68 +-- 47 files changed, 3042 insertions(+), 2443 deletions(-) create mode 100644 teshsuite/smpi/mpich3-test/pt2pt/cancelanysrc.c create mode 100644 teshsuite/smpi/mpich3-test/pt2pt/dtype_send.c create mode 100644 teshsuite/smpi/mpich3-test/pt2pt/isendirecv.c create mode 100644 teshsuite/smpi/mpich3-test/pt2pt/many_isend.c create mode 100644 teshsuite/smpi/mpich3-test/pt2pt/manylmt.c create mode 100644 teshsuite/smpi/mpich3-test/pt2pt/recv_any.c create mode 100644 teshsuite/smpi/mpich3-test/pt2pt/scancel_unmatch.c diff --git a/teshsuite/smpi/mpich3-test/pt2pt/CMakeLists.txt b/teshsuite/smpi/mpich3-test/pt2pt/CMakeLists.txt index aa3479c9c8..ebf185798d 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/CMakeLists.txt +++ b/teshsuite/smpi/mpich3-test/pt2pt/CMakeLists.txt @@ -9,9 +9,9 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite) include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../include/") - foreach(file anyall bottom eagerdt inactivereq isendself isendselfprobe issendselfcancel mprobe pingping probenull - probe-unexp sendall sendflood sendrecv1 sendrecv2 sendrecv3 waitany-null waittestnull) - # not compiled files: big_count_status bsend1 bsend2 bsend3 bsend4 bsend5 bsendalign bsendfrag bsendpending + foreach(file anyall bottom eagerdt inactivereq isendself isendirecv isendselfprobe issendselfcancel pingping probenull + probe-unexp sendall sendflood sendrecv1 sendrecv2 sendrecv3 waitany-null waittestnull ) + # not compiled files: big_count_status bsend1 bsend2 bsend3 bsend4 bsend5 bsendalign bsendfrag bsendpending mprobe # cancelrecv greq1 icsend large_message pscancel rcancel rqfreeb rqstatus scancel2 scancel sendself add_executable(${file} ${file}.c) target_link_libraries(${file} simgrid mtest_c) @@ -23,7 +23,7 @@ if (enable_smpi_MPICH3_testsuite AND HAVE_RAW_CONTEXTS) SET_TESTS_PROPERTIES(test-smpi-mpich3-pt2pt-raw PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!") endif() -foreach(file anyall bottom eagerdt inactivereq isendself isendselfprobe issendselfcancel mprobe pingping probenull +foreach(file anyall bottom eagerdt inactivereq isendself isendirecv isendselfprobe issendselfcancel pingping probenull probe-unexp sendall sendflood sendrecv1 sendrecv2 sendrecv3 waitany-null waittestnull big_count_status bsend1 bsend2 bsend3 bsend4 bsend5 bsendalign bsendfrag bsendpending cancelrecv greq1 icsend large_message pscancel rcancel rqfreeb rqstatus scancel2 scancel sendself) diff --git a/teshsuite/smpi/mpich3-test/pt2pt/anyall.c b/teshsuite/smpi/mpich3-test/pt2pt/anyall.c index b54b13ad8f..405c794804 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/anyall.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/anyall.c @@ -14,74 +14,73 @@ static char MTEST_Descrip[] = "One implementation delivered incorrect data when an MPI recieve uses both ANY_SOURCE and ANY_TAG"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { - int wrank, wsize, master, worker, i, j, idx, count; - int errs = 0; + int wrank, wsize, master, worker, i, j, idx, count; + int errs = 0; MPI_Request r[MAX_MSGS]; - int buf[MAX_MSGS][MAX_MSGS]; - MPI_Comm comm; - MPI_Status status; + int buf[MAX_MSGS][MAX_MSGS]; + MPI_Comm comm; + MPI_Status status; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - MPI_Comm_rank( MPI_COMM_WORLD, &wrank ); - MPI_Comm_size( MPI_COMM_WORLD, &wsize ); + MPI_Comm_rank(MPI_COMM_WORLD, &wrank); + MPI_Comm_size(MPI_COMM_WORLD, &wsize); comm = MPI_COMM_WORLD; master = 0; worker = 1; - /* The test takes advantage of the ordering rules for messages*/ + /* The test takes advantage of the ordering rules for messages */ if (wrank == master) { - /* Initialize the send buffer */ - for (i=0; i #endif -/* +/* * This is a simple program that tests bsend. It may be run as a single * process to simplify debugging; in addition, bsend allows send-to-self * programs. */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { MPI_Comm comm = MPI_COMM_WORLD; int dest = 0, src = 0, tag = 1; @@ -30,55 +30,58 @@ int main( int argc, char *argv[] ) int errs = 0, rank; int bufsize, bsize; - MTest_Init( &argc, &argv ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); + MTest_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* 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( 7, MPI_CHAR, comm, &s1 ); - MPI_Pack_size( 2, MPI_DOUBLE, comm, &s2 ); - MPI_Pack_size( 17, MPI_CHAR, comm, &s3 ); + * message in the computation of the message buffer size */ + MPI_Pack_size(7, MPI_CHAR, comm, &s1); + MPI_Pack_size(2, MPI_DOUBLE, comm, &s2); + MPI_Pack_size(17, MPI_CHAR, comm, &s3); bufsize = 3 * MPI_BSEND_OVERHEAD + s1 + s2 + s3; - buf = (char *)malloc( bufsize ); - MPI_Buffer_attach( buf, bufsize ); + buf = (char *) malloc(bufsize); + MPI_Buffer_attach(buf, bufsize); - strncpy( msg1, "012345", 7 ); - strncpy( msg3, "0123401234012341", 17 ); - msg2[0] = 1.23; msg2[1] = 3.21; + strncpy(msg1, "012345", 7); + strncpy(msg3, "0123401234012341", 17); + msg2[0] = 1.23; + msg2[1] = 3.21; if (rank == src) { - /* These message sizes are chosen to expose any alignment problems */ - MPI_Bsend( msg1, 7, MPI_CHAR, dest, tag, comm ); - MPI_Bsend( msg2, 2, MPI_DOUBLE, dest, tag, comm ); - MPI_Bsend( msg3, 17, MPI_CHAR, dest, tag, comm ); + /* These message sizes are chosen to expose any alignment problems */ + MPI_Bsend(msg1, 7, MPI_CHAR, dest, tag, comm); + MPI_Bsend(msg2, 2, MPI_DOUBLE, dest, tag, comm); + MPI_Bsend(msg3, 17, MPI_CHAR, dest, tag, comm); } if (rank == dest) { - MPI_Recv( rmsg1, 7, MPI_CHAR, src, tag, comm, MPI_STATUS_IGNORE ); - MPI_Recv( rmsg2, 10, MPI_DOUBLE, src, tag, comm, MPI_STATUS_IGNORE ); - MPI_Recv( rmsg3, 17, MPI_CHAR, src, tag, comm, MPI_STATUS_IGNORE ); + MPI_Recv(rmsg1, 7, MPI_CHAR, src, tag, comm, MPI_STATUS_IGNORE); + MPI_Recv(rmsg2, 10, MPI_DOUBLE, src, tag, comm, MPI_STATUS_IGNORE); + MPI_Recv(rmsg3, 17, MPI_CHAR, src, tag, comm, MPI_STATUS_IGNORE); - if (strcmp( rmsg1, msg1 ) != 0) { - errs++; - fprintf( stderr, "message 1 (%s) should be %s\n", rmsg1, msg1 ); - } - if (rmsg2[0] != msg2[0] || rmsg2[1] != msg2[1]) { - errs++; - fprintf( stderr, - "message 2 incorrect, values are (%f,%f) but should be (%f,%f)\n", - rmsg2[0], rmsg2[1], msg2[0], msg2[1] ); - } - if (strcmp( rmsg3, msg3 ) != 0) { - errs++; - fprintf( stderr, "message 3 (%s) should be %s\n", rmsg3, msg3 ); - } + if (strcmp(rmsg1, msg1) != 0) { + errs++; + fprintf(stderr, "message 1 (%s) should be %s\n", rmsg1, msg1); + } + if (rmsg2[0] != msg2[0] || rmsg2[1] != msg2[1]) { + errs++; + fprintf(stderr, + "message 2 incorrect, values are (%f,%f) but should be (%f,%f)\n", + rmsg2[0], rmsg2[1], msg2[0], msg2[1]); + } + if (strcmp(rmsg3, msg3) != 0) { + errs++; + fprintf(stderr, "message 3 (%s) should be %s\n", rmsg3, msg3); + } } /* We can't guarantee that messages arrive until the detach */ - MPI_Buffer_detach( &bbuf, &bsize ); + MPI_Buffer_detach(&bbuf, &bsize); + + free(buf); + + MTest_Finalize(errs); - MTest_Finalize( errs ); - MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/pt2pt/bsend2.c b/teshsuite/smpi/mpich3-test/pt2pt/bsend2.c index 4f6ad93ac7..eb0aa4ebfe 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/bsend2.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/bsend2.c @@ -8,54 +8,53 @@ #include "mpitest.h" #define BUFSIZE 2000 -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { MPI_Status status; int a[10], b[10]; int buf[BUFSIZE], *bptr, bl, i, j, rank, size; int errs = 0; - MTest_Init( 0, 0 ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); - MPI_Comm_size( MPI_COMM_WORLD, &size ); - MPI_Buffer_attach( buf, BUFSIZE ); - - for (j=0; j<10; j++) { - for (i=0; i<10; i++) { - a[i] = (rank + 10 * j) * size + i; - } - MPI_Bsend( a, 10, MPI_INT, 0, 27+j, MPI_COMM_WORLD ); + MTest_Init(0, 0); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Buffer_attach(buf, BUFSIZE); + + for (j = 0; j < 10; j++) { + for (i = 0; i < 10; i++) { + a[i] = (rank + 10 * j) * size + i; + } + MPI_Bsend(a, 10, MPI_INT, 0, 27 + j, MPI_COMM_WORLD); } if (rank == 0) { - for (i=0; i #include "mpi.h" -#include "mpitest.h" +#include "mpitest.h" #define BUFSIZE 2000 -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { MPI_Status status; MPI_Request request; int a[10], b[10]; - int buf[BUFSIZE], *bptr, bl, i, j, rank, size, errs=0; + int buf[BUFSIZE], *bptr, bl, i, j, rank, size, errs = 0; - MTest_Init( 0, 0 ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); - MPI_Comm_size( MPI_COMM_WORLD, &size ); - MPI_Buffer_attach( buf, BUFSIZE ); + MTest_Init(0, 0); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Buffer_attach(buf, BUFSIZE); - for (j=0; j<10; j++) { - for (i=0; i<10; i++) { - a[i] = (rank + 10 * j) * size + i; - } - MPI_Ibsend( a, 10, MPI_INT, 0, 27+j, MPI_COMM_WORLD, &request ); - MPI_Wait( &request, &status ); + for (j = 0; j < 10; j++) { + for (i = 0; i < 10; i++) { + a[i] = (rank + 10 * j) * size + i; + } + MPI_Ibsend(a, 10, MPI_INT, 0, 27 + j, MPI_COMM_WORLD, &request); + MPI_Wait(&request, &status); } if (rank == 0) { - for (i=0; i #include "mpi.h" -#include "mpitest.h" +#include "mpitest.h" #define BUFSIZE 2000 -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { MPI_Status status; - MPI_Comm comm,scomm; + MPI_Comm comm, scomm; int a[10], b[10]; - int buf[BUFSIZE], *bptr, bl, i, j, rank, size, color, errs=0; + int buf[BUFSIZE], *bptr, bl, i, j, rank, size, color, errs = 0; - MTest_Init( 0, 0 ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); + MTest_Init(0, 0); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); color = rank % 2; - MPI_Comm_split( MPI_COMM_WORLD, color, rank, &scomm ); - MPI_Intercomm_create( scomm, 0, MPI_COMM_WORLD, 1-color, 52, &comm); - MPI_Comm_rank( comm, &rank ); - MPI_Comm_remote_size( comm, &size ); - MPI_Buffer_attach( buf, BUFSIZE ); - - for (j=0; j<10; j++) { - for (i=0; i<10; i++) { - a[i] = (rank + 10 * j) * size + i; - } - MPI_Bsend( a, 10, MPI_INT, 0, 27+j, comm ); + MPI_Comm_split(MPI_COMM_WORLD, color, rank, &scomm); + MPI_Intercomm_create(scomm, 0, MPI_COMM_WORLD, 1 - color, 52, &comm); + MPI_Comm_rank(comm, &rank); + MPI_Comm_remote_size(comm, &size); + MPI_Buffer_attach(buf, BUFSIZE); + + for (j = 0; j < 10; j++) { + for (i = 0; i < 10; i++) { + a[i] = (rank + 10 * j) * size + i; + } + MPI_Bsend(a, 10, MPI_INT, 0, 27 + j, comm); } if (rank == 0) { - for (i=0; i +#include +#include +#include "mpi.h" + +int main(int argc, char **argv) +{ + int size, rank, msg, cancelled; + MPI_Request request; + MPI_Status status; + + MPI_Init(&argc, &argv); + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + + if (size != 2) { + fprintf(stderr, "ERROR: must be run with 2 processes"); + MPI_Abort(MPI_COMM_WORLD, 1); + } + + if (rank == 0) { + msg = -1; + /* Post, then cancel MPI_ANY_SOURCE recv */ + MPI_Irecv(&msg, 1, MPI_INT, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &request); + MPI_Cancel(&request); + MPI_Wait(&request, &status); + MPI_Test_cancelled(&status, &cancelled); + assert(cancelled); + + MPI_Barrier(MPI_COMM_WORLD); + MPI_Irecv(&msg, 1, MPI_INT, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &request); + MPI_Wait(&request, &status); + assert(msg == 42); + } + else { + MPI_Barrier(MPI_COMM_WORLD); + msg = 42; + MPI_Send(&msg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD); + } + + if (rank == 0) + printf(" No Errors\n"); + + MPI_Finalize(); +} diff --git a/teshsuite/smpi/mpich3-test/pt2pt/cancelrecv.c b/teshsuite/smpi/mpich3-test/pt2pt/cancelrecv.c index 850364a01b..d78a4d9ed8 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/cancelrecv.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/cancelrecv.c @@ -7,133 +7,128 @@ #include #include #include "mpitest.h" -#include /* For memset */ +#include /* For memset */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { MPI_Request r[3]; - MPI_Status s[3]; + MPI_Status s[3]; int *buf0, *buf1, *buf2; int rank, size, src, dest, flag, errs = 0; int n0, n1, n2; MPI_Comm comm; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - MPI_Comm_size( MPI_COMM_WORLD, &size ); + MPI_Comm_size(MPI_COMM_WORLD, &size); if (size < 2) { - fprintf( stderr, "Must run with at least 2 processes\n" ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); + fprintf(stderr, "Must run with at least 2 processes\n"); + MPI_Abort(MPI_COMM_WORLD, 1); } - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); dest = 0; - src = 1; + src = 1; comm = MPI_COMM_WORLD; n0 = n1 = n2 = 65536; - buf0 = (int *)malloc( n0 * sizeof(int) ); - buf1 = (int *)malloc( n1 * sizeof(int) ); - buf2 = (int *)malloc( n2 * sizeof(int) ); + buf0 = (int *) malloc(n0 * sizeof(int)); + buf1 = (int *) malloc(n1 * sizeof(int)); + buf2 = (int *) malloc(n2 * sizeof(int)); if (!buf0 || !buf1 || !buf2) { - fprintf( stderr, "Unable to allocate buffers of size %d\n", - n0 * (int)sizeof(int) ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); + fprintf(stderr, "Unable to allocate buffers of size %d\n", n0 * (int) sizeof(int)); + MPI_Abort(MPI_COMM_WORLD, 1); } - memset( buf0, -1, n0 * sizeof(int) ); - memset( buf1, -1, n0 * sizeof(int) ); - memset( buf2, -1, n0 * sizeof(int) ); + memset(buf0, -1, n0 * sizeof(int)); + memset(buf1, -1, n0 * sizeof(int)); + memset(buf2, -1, n0 * sizeof(int)); if (rank == dest) { - MPI_Irecv( buf0, n0, MPI_INT, src, 0, comm, &r[0] ); - MPI_Irecv( buf1, n1, MPI_INT, src, 1, comm, &r[1] ); - MPI_Irecv( buf2, n2, MPI_INT, src, 2, comm, &r[2] ); - - MPI_Barrier( comm ); + MPI_Irecv(buf0, n0, MPI_INT, src, 0, comm, &r[0]); + MPI_Irecv(buf1, n1, MPI_INT, src, 1, comm, &r[1]); + MPI_Irecv(buf2, n2, MPI_INT, src, 2, comm, &r[2]); - MPI_Cancel( &r[1] ); - MPI_Barrier( comm ); - memset( s, -1, sizeof(s) ); - MPI_Waitall( 3, r, s ); - MPI_Test_cancelled( &s[0], &flag ); + MPI_Barrier(comm); + + MPI_Cancel(&r[1]); + MPI_Barrier(comm); + memset(s, -1, sizeof(s)); + MPI_Waitall(3, r, s); + MPI_Test_cancelled(&s[0], &flag); if (flag) { - errs++; - printf( "request 0 was cancelled!\n" ); - } - MPI_Test_cancelled( &s[1], &flag ); + errs++; + printf("request 0 was cancelled!\n"); + } + MPI_Test_cancelled(&s[1], &flag); if (!flag) { - errs++; - printf( "request 1 was not cancelled!\n" ); - } - MPI_Test_cancelled( &s[2], &flag ); + errs++; + printf("request 1 was not cancelled!\n"); + } + MPI_Test_cancelled(&s[2], &flag); if (flag) { - errs++; - printf( "request 2 was cancelled!\n" ); - } - MPI_Barrier( comm ); + errs++; + printf("request 2 was cancelled!\n"); + } + MPI_Barrier(comm); } if (rank == src) { - int tflag; - MPI_Barrier( comm ); - MPI_Barrier( comm ); - MPI_Send( buf0, n0, MPI_INT, dest, 0, comm ); - MPI_Isend( buf2, n2, MPI_INT, dest, 2, comm, &r[1] ); - MPI_Isend( buf1, n1, MPI_INT, dest, 4, comm, &r[0] ); - MPI_Cancel( &r[0] ); - memset( s, -3, sizeof(s) ); - s[0].MPI_ERROR = -3; - s[1].MPI_ERROR = -3; - MPI_Testall( 2, r, &tflag, s ); - if (tflag) { - MPI_Test_cancelled( &s[0], &flag ); - if (!flag) { - errs++; - printf( "send request 0 was not cancelled!\n" ); - } - MPI_Test_cancelled( &s[1], &flag ); - if (flag) { - errs++; - printf( "send request 1 was cancelled!\n" ); - } - } - else { - /* If all requests are not complete, then neither r nor s - may be changed */ - if ( (s[0].MPI_ERROR) != -3) { - errs++; - printf( "Send request status 0 modified. s[0].MPI_ERROR = %x\n", - s[0].MPI_ERROR ); - } - if ( (s[1].MPI_ERROR) != -3) { - errs++; - printf( "Send request status 1 modified. s[1].MPI_ERROR = %x\n", - s[1].MPI_ERROR ); - } - } - MPI_Barrier( comm ); - while (!tflag) { - MPI_Testall( 2, r, &tflag, s ); - } - MPI_Test_cancelled( &s[0], &flag ); - if (!flag) { - errs++; - printf( "send request 0 was not cancelled!\n" ); - } - MPI_Test_cancelled( &s[1], &flag ); - if (flag) { - errs++; - printf( "send request 1 was cancelled!\n" ); - } + int tflag; + MPI_Barrier(comm); + MPI_Barrier(comm); + MPI_Send(buf0, n0, MPI_INT, dest, 0, comm); + MPI_Isend(buf2, n2, MPI_INT, dest, 2, comm, &r[1]); + MPI_Isend(buf1, n1, MPI_INT, dest, 4, comm, &r[0]); + MPI_Cancel(&r[0]); + memset(s, -3, sizeof(s)); + s[0].MPI_ERROR = -3; + s[1].MPI_ERROR = -3; + MPI_Testall(2, r, &tflag, s); + if (tflag) { + MPI_Test_cancelled(&s[0], &flag); + if (!flag) { + errs++; + printf("send request 0 was not cancelled!\n"); + } + MPI_Test_cancelled(&s[1], &flag); + if (flag) { + errs++; + printf("send request 1 was cancelled!\n"); + } + } + else { + /* If all requests are not complete, then neither r nor s + * may be changed */ + if ((s[0].MPI_ERROR) != -3) { + errs++; + printf("Send request status 0 modified. s[0].MPI_ERROR = %x\n", s[0].MPI_ERROR); + } + if ((s[1].MPI_ERROR) != -3) { + errs++; + printf("Send request status 1 modified. s[1].MPI_ERROR = %x\n", s[1].MPI_ERROR); + } + } + MPI_Barrier(comm); + while (!tflag) { + MPI_Testall(2, r, &tflag, s); + } + MPI_Test_cancelled(&s[0], &flag); + if (!flag) { + errs++; + printf("send request 0 was not cancelled!\n"); + } + MPI_Test_cancelled(&s[1], &flag); + if (flag) { + errs++; + printf("send request 1 was cancelled!\n"); + } } if (rank != src && rank != dest) { - MPI_Barrier( comm ); - MPI_Barrier( comm ); - MPI_Barrier( comm ); + MPI_Barrier(comm); + MPI_Barrier(comm); + MPI_Barrier(comm); } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; diff --git a/teshsuite/smpi/mpich3-test/pt2pt/dtype_send.c b/teshsuite/smpi/mpich3-test/pt2pt/dtype_send.c new file mode 100644 index 0000000000..a089bd67b7 --- /dev/null +++ b/teshsuite/smpi/mpich3-test/pt2pt/dtype_send.c @@ -0,0 +1,101 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2016 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ + +#include +#include +#include + +#define NUM_LOOPS (128) + +int main(int argc, char **argv) +{ + int i, rank, size; + MPI_Request *req; + MPI_Datatype newtype; + int snd_buf[3], rcv_buf[3]; + int count = 2; + int *displs; + + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + + if (size < 2) { + fprintf(stderr, "Must run with at least 2 processes\n"); + MPI_Abort(MPI_COMM_WORLD, 1); + } + + displs = (int *) malloc(count * sizeof(int)); + for (i = 0; i < count; i++) + displs[i] = i * 2; + + MPI_Barrier(MPI_COMM_WORLD); + + /* test isends */ + MPI_Type_create_indexed_block(count, 1, displs, MPI_INT, &newtype); + MPI_Type_commit(&newtype); + + if (rank == 0) { + req = (MPI_Request *) malloc(NUM_LOOPS * sizeof(MPI_Request)); + for (i = 0; i < NUM_LOOPS; i++) + MPI_Isend(snd_buf, 1, newtype, !rank, 0, MPI_COMM_WORLD, &req[i]); + } + else { + for (i = 0; i < NUM_LOOPS; i++) + MPI_Recv(rcv_buf, 1, newtype, !rank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + } + MPI_Type_free(&newtype); + if (rank == 0) + MPI_Waitall(NUM_LOOPS, req, MPI_STATUSES_IGNORE); + + MPI_Barrier(MPI_COMM_WORLD); + + /* test issends */ + MPI_Type_create_indexed_block(count, 1, displs, MPI_INT, &newtype); + MPI_Type_commit(&newtype); + + if (rank == 0) { + req = (MPI_Request *) malloc(NUM_LOOPS * sizeof(MPI_Request)); + for (i = 0; i < NUM_LOOPS; i++) + MPI_Issend(snd_buf, 1, newtype, !rank, 0, MPI_COMM_WORLD, &req[i]); + } + else { + for (i = 0; i < NUM_LOOPS; i++) + MPI_Recv(rcv_buf, 1, newtype, !rank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + } + MPI_Type_free(&newtype); + if (rank == 0) + MPI_Waitall(NUM_LOOPS, req, MPI_STATUSES_IGNORE); + + MPI_Barrier(MPI_COMM_WORLD); + + /* test irsends */ + MPI_Type_create_indexed_block(count, 1, displs, MPI_INT, &newtype); + MPI_Type_commit(&newtype); + + req = (MPI_Request *) malloc(NUM_LOOPS * sizeof(MPI_Request)); + if (rank == 0) { + MPI_Barrier(MPI_COMM_WORLD); + for (i = 0; i < NUM_LOOPS; i++) + MPI_Irsend(snd_buf, 1, newtype, !rank, 0, MPI_COMM_WORLD, &req[i]); + } + else { + for (i = 0; i < NUM_LOOPS; i++) + MPI_Irecv(rcv_buf, 1, newtype, !rank, 0, MPI_COMM_WORLD, &req[i]); + MPI_Barrier(MPI_COMM_WORLD); + } + MPI_Type_free(&newtype); + MPI_Waitall(NUM_LOOPS, req, MPI_STATUSES_IGNORE); + + MPI_Barrier(MPI_COMM_WORLD); + + MPI_Finalize(); + + if (rank == 0) + printf(" No Errors\n"); + + return 0; +} diff --git a/teshsuite/smpi/mpich3-test/pt2pt/eagerdt.c b/teshsuite/smpi/mpich3-test/pt2pt/eagerdt.c index 7855b75e4f..529d490394 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/eagerdt.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/eagerdt.c @@ -14,65 +14,67 @@ static char MTEST_Descrip[] = "Test of a large number of derived-datatype messag #define MAX_MSGS 30 -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rank, size, dest, source; int i, indices[40]; MPI_Aint extent; int *buf, *bufs[MAX_MSGS]; - MPI_Comm comm; - MPI_Datatype dtype; - MPI_Request req[MAX_MSGS]; + MPI_Comm comm; + MPI_Datatype dtype; + MPI_Request req[MAX_MSGS]; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); source = 0; - dest = size - 1; - + dest = size - 1; + /* Setup by creating a blocked datatype that is likely to be processed - in a piecemeal fashion */ - for (i=0; i<30; i++) { - indices[i] = i*40; + * in a piecemeal fashion */ + for (i = 0; i < 30; i++) { + indices[i] = i * 40; } /* 30 blocks of size 10 */ - MPI_Type_create_indexed_block( 30, 10, indices, MPI_INT, &dtype ); - MPI_Type_commit( &dtype ); - + MPI_Type_create_indexed_block(30, 10, indices, MPI_INT, &dtype); + MPI_Type_commit(&dtype); + /* Create the corresponding message buffers */ - MPI_Type_extent( dtype, &extent ); - for (i=0; iMPI_SOURCE = MPI_UNDEFINED; - status->MPI_TAG = MPI_UNDEFINED; - MPI_Status_set_cancelled( status, 0 ); - MPI_Status_set_elements( status, MPI_BYTE, 0 ); + status->MPI_TAG = MPI_UNDEFINED; + MPI_Status_set_cancelled(status, 0); + MPI_Status_set_elements(status, MPI_BYTE, 0); return 0; } -int free_fn( void *extra_state ); -int free_fn( void *extra_state ) + +int free_fn(void *extra_state); +int free_fn(void *extra_state) { - int *b = (int *)extra_state; - if (b) *b = *b - 1; + int *b = (int *) extra_state; + if (b) + *b = *b - 1; /* The value returned by the free function is the error code - returned by the wait/test function */ + * returned by the wait/test function */ return 0; } -int cancel_fn( void *extra_state, int complete ); -int cancel_fn( void *extra_state, int complete ) + +int cancel_fn(void *extra_state, int complete); +int cancel_fn(void *extra_state, int complete) { return 0; } @@ -43,44 +46,44 @@ int cancel_fn( void *extra_state, int complete ) * MPI_Grequest_complete function would be called from another routine, * often running in a separate thread. This simple code allows us to * check that requests can be created, tested, and waited on in the - * case where the request is complete before the wait is called. + * case where the request is complete before the wait is called. * * Note that MPI did *not* define a routine that can be called within - * test or wait to advance the state of a generalized request. + * test or wait to advance the state of a generalized request. * Most uses of generalized requests will need to use a separate thread. */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int counter, flag; - MPI_Status status; - MPI_Request request; + MPI_Status status; + MPI_Request request; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - MPI_Grequest_start( query_fn, free_fn, cancel_fn, NULL, &request ); - - MPI_Test( &request, &flag, &status ); + MPI_Grequest_start(query_fn, free_fn, cancel_fn, NULL, &request); + + MPI_Test(&request, &flag, &status); if (flag) { - errs++; - fprintf( stderr, "Generalized request marked as complete\n" ); + errs++; + fprintf(stderr, "Generalized request marked as complete\n"); } - MPI_Grequest_complete( request ); + MPI_Grequest_complete(request); - MPI_Wait( &request, &status ); + MPI_Wait(&request, &status); counter = 1; - MPI_Grequest_start( query_fn, free_fn, cancel_fn, &counter, &request ); - MPI_Grequest_complete( request ); - MPI_Wait( &request, MPI_STATUS_IGNORE ); - + MPI_Grequest_start(query_fn, free_fn, cancel_fn, &counter, &request); + MPI_Grequest_complete(request); + MPI_Wait(&request, MPI_STATUS_IGNORE); + if (counter) { - errs++; - fprintf( stderr, "Free routine not called, or not called with extra_data" ); + errs++; + fprintf(stderr, "Free routine not called, or not called with extra_data"); } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/pt2pt/icsend.c b/teshsuite/smpi/mpich3-test/pt2pt/icsend.c index ae196ef438..9981846880 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/icsend.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/icsend.c @@ -12,61 +12,62 @@ static char MTEST_Descrip[] = "Simple test of intercommunicator send and receive"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int leftGroup, buf, rank, remote_size, i; MPI_Comm comm; MPI_Status status; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - while (MTestGetIntercomm( &comm, &leftGroup, 4 )) { - if (comm == MPI_COMM_NULL) continue; + while (MTestGetIntercomm(&comm, &leftGroup, 4)) { + if (comm == MPI_COMM_NULL) + continue; - if (leftGroup) { - MPI_Comm_rank( comm, &rank ); - buf = rank; - MPI_Send( &buf, 1, MPI_INT, 0, 0, comm ); - } - else { - MPI_Comm_remote_size( comm, &remote_size ); - MPI_Comm_rank( comm, &rank ); - if (rank == 0) { - for (i=0; iMPI_TAG != MPI_ANY_TAG) { - errs++; - printf( "MPI_TAG not MPI_ANY_TAG in status\n" ); + errs++; + printf("MPI_TAG not MPI_ANY_TAG in status\n"); } if (s->MPI_SOURCE != MPI_ANY_SOURCE) { - errs++; - printf( "MPI_SOURCE not MPI_ANY_SOURCE in status\n" ); + errs++; + printf("MPI_SOURCE not MPI_ANY_SOURCE in status\n"); } - MPI_Get_count( s, MPI_INT, &count ); + MPI_Get_count(s, MPI_INT, &count); if (count != 0) { - errs++; - printf( "count in status is not 0\n" ); + errs++; + printf("count in status is not 0\n"); } /* Return true only if status passed all tests */ return errs ? 0 : 1; @@ -43,7 +43,7 @@ int StatusEmpty( MPI_Status *s ) int main(int argc, char *argv[]) { MPI_Request r; - MPI_Status s; + MPI_Status s; int errs = 0; int flag; int buf[10]; @@ -52,115 +52,116 @@ int main(int argc, char *argv[]) int dest = 0; int rank, size; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - MPI_Comm_size( MPI_COMM_WORLD, &size ); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* Create a persistent send request */ - MPI_Send_init( buf, 10, MPI_INT, dest, tag, MPI_COMM_WORLD, &r ); + MPI_Send_init(buf, 10, MPI_INT, dest, tag, MPI_COMM_WORLD, &r); flag = 0; s.MPI_TAG = 10; s.MPI_SOURCE = 10; - MPI_Test( &r, &flag, &s ); + MPI_Test(&r, &flag, &s); if (!flag) { - errs++; - printf( "Flag not true after MPI_Test (send)\n" ); - printf( "Aborting further tests to avoid hanging in MPI_Wait\n" ); - MTest_Finalize( errs ); - MPI_Finalize(); - return 0; + errs++; + printf("Flag not true after MPI_Test (send)\n"); + printf("Aborting further tests to avoid hanging in MPI_Wait\n"); + MTest_Finalize(errs); + MPI_Finalize(); + return 0; } - if (!StatusEmpty( &s )) { - errs++; - printf( "Status not empty after MPI_Test (send)\n" ); + if (!StatusEmpty(&s)) { + errs++; + printf("Status not empty after MPI_Test (send)\n"); } s.MPI_TAG = 10; s.MPI_SOURCE = 10; - MPI_Wait( &r, &s ); - if (!StatusEmpty( &s )) { - errs++; - printf( "Status not empty after MPI_Wait (send)\n" ); + MPI_Wait(&r, &s); + if (!StatusEmpty(&s)) { + errs++; + printf("Status not empty after MPI_Wait (send)\n"); } /* Now try to use that request, then check again */ if (rank == 0) { - int i; - MPI_Request *rr = (MPI_Request *)malloc(size * sizeof(MPI_Request)); - for (i=0; i +#include +#include "mpitest.h" + +int main(int argc, char *argv[]) +{ + int errors = 0; + int elems = 20; + int rank, nproc, dest, i; + float *in_buf, *out_buf; + MPI_Comm comm; + MPI_Request *reqs; + + MTest_Init(&argc, &argv); + + comm = MPI_COMM_WORLD; + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &nproc); + + reqs = (MPI_Request *) malloc(2 * nproc * sizeof(MPI_Request)); + in_buf = (float *) malloc(elems * nproc * sizeof(float)); + out_buf = (float *) malloc(elems * nproc * sizeof(float)); + MTEST_VG_MEM_INIT(out_buf, elems * nproc * sizeof(float)); + + for (i = 0; i < nproc; i++) { + MPI_Irecv(&in_buf[elems * i], elems, MPI_FLOAT, i, 0, comm, &reqs[i]); + } + + for (i = 0; i < nproc; i++) { + MPI_Isend(&out_buf[elems * i], elems, MPI_FLOAT, i, 0, comm, &reqs[i + nproc]); + } + + MPI_Waitall(nproc * 2, reqs, MPI_STATUSES_IGNORE); + + free(reqs); + free(in_buf); + free(out_buf); + MTest_Finalize(errors); + MPI_Finalize(); + return 0; + +} diff --git a/teshsuite/smpi/mpich3-test/pt2pt/isendself.c b/teshsuite/smpi/mpich3-test/pt2pt/isendself.c index 29f98cebf4..3c373eabf1 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/isendself.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/isendself.c @@ -7,52 +7,45 @@ #include "mpi.h" #include "mpitest.h" -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int a[10], b[10], i; MPI_Status status; MPI_Request request; int rank, count; int errs = 0; - - MTest_Init( &argc, &argv ); + + MTest_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - for (i=0; i<10; i++) a[i] = i+1; + + for (i = 0; i < 10; i++) + a[i] = i + 1; status.MPI_ERROR = 0; - MPI_Isend( a, 0, MPI_INT, rank, 0, MPI_COMM_WORLD, &request ); - MPI_Recv( b, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, - &status ); - MPI_Get_count( &status, MPI_INT, &count ); - if (status.MPI_SOURCE != rank || - status.MPI_TAG != 0 || - status.MPI_ERROR != 0 || - count != 0) { - errs++; - printf ("1 status = %d %d %d %d\n", status.MPI_SOURCE, status.MPI_TAG, - status.MPI_ERROR, count ); + MPI_Isend(a, 0, MPI_INT, rank, 0, MPI_COMM_WORLD, &request); + MPI_Recv(b, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status); + MPI_Get_count(&status, MPI_INT, &count); + if (status.MPI_SOURCE != rank || status.MPI_TAG != 0 || status.MPI_ERROR != 0 || count != 0) { + errs++; + printf("1 status = %d %d %d %d\n", status.MPI_SOURCE, status.MPI_TAG, + status.MPI_ERROR, count); } - /* printf( "b[0] = %d\n", b[0] );*/ - MPI_Wait( &request, &status ); - - MPI_Isend( 0, 0, MPI_INT, rank, 0, MPI_COMM_WORLD, &request ); - MPI_Recv( 0, 0, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, - &status ); - MPI_Get_count( &status, MPI_INT, &count ); - if (status.MPI_SOURCE != rank || - status.MPI_TAG != 0 || - status.MPI_ERROR != 0 || - count != 0) { - errs++; - printf ("2 status = %d %d %d %d\n", status.MPI_SOURCE, status.MPI_TAG, - status.MPI_ERROR, count ); + /* printf("b[0] = %d\n", b[0]); */ + MPI_Wait(&request, &status); + + MPI_Isend(NULL, 0, MPI_INT, rank, 0, MPI_COMM_WORLD, &request); + MPI_Recv(NULL, 0, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status); + MPI_Get_count(&status, MPI_INT, &count); + if (status.MPI_SOURCE != rank || status.MPI_TAG != 0 || status.MPI_ERROR != 0 || count != 0) { + errs++; + printf("2 status = %d %d %d %d\n", status.MPI_SOURCE, status.MPI_TAG, + status.MPI_ERROR, count); } - MPI_Wait( &request, &status ); + MPI_Wait(&request, &status); - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/pt2pt/isendselfprobe.c b/teshsuite/smpi/mpich3-test/pt2pt/isendselfprobe.c index 1b3c6c051b..5a5357bf23 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/isendselfprobe.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/isendselfprobe.c @@ -7,7 +7,7 @@ #include "mpi.h" #include "mpitest.h" -int main( int argc, char * argv[] ) +int main(int argc, char *argv[]) { int rank; int sendMsg = 123; @@ -18,30 +18,26 @@ int main( int argc, char * argv[] ) MPI_Request request; int errs = 0; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); - if(rank == 0) - { - MPI_Isend( &sendMsg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &request ); - while(!flag) - { - MPI_Iprobe( 0, 0, MPI_COMM_WORLD, &flag, &status ); - } - MPI_Get_count( &status, MPI_INT, &count ); - if(count != 1) - { - errs++; - } - MPI_Recv( &recvMsg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &status ); - if(recvMsg != 123) - { - errs++; - } - MPI_Wait( &request, &status ); + if (rank == 0) { + MPI_Isend(&sendMsg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &request); + while (!flag) { + MPI_Iprobe(0, 0, MPI_COMM_WORLD, &flag, &status); + } + MPI_Get_count(&status, MPI_INT, &count); + if (count != 1) { + errs++; + } + MPI_Recv(&recvMsg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &status); + if (recvMsg != 123) { + errs++; + } + MPI_Wait(&request, &status); } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/pt2pt/issendselfcancel.c b/teshsuite/smpi/mpich3-test/pt2pt/issendselfcancel.c index 1151466f15..20adb4b80b 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/issendselfcancel.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/issendselfcancel.c @@ -13,7 +13,7 @@ int main(int argc, char **argv) MPI_Request req; MPI_Status status; - MPI_Init(&argc, &argv); + MPI_Init(NULL, NULL); MPI_Issend(NULL, 0, MPI_BYTE, 0, 123, MPI_COMM_SELF, &req); @@ -33,5 +33,4 @@ int main(int argc, char **argv) printf(" No Errors\n"); MPI_Finalize(); - return 0; } diff --git a/teshsuite/smpi/mpich3-test/pt2pt/large_message.c b/teshsuite/smpi/mpich3-test/pt2pt/large_message.c index 42d60b7bb6..cc0526a086 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/large_message.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/large_message.c @@ -8,63 +8,69 @@ #include #include "mpitest.h" -/* tests send/recv of a message > 2GB. count=270M, type=long long +/* tests send/recv of a message > 2GB. count=270M, type=long long run with 3 processes to exercise both shared memory and TCP in Nemesis tests*/ -int main(int argc, char *argv[]) +int main(int argc, char *argv[]) { - int /* ierr, */ i,size,rank; - int cnt = 270000000; - MPI_Status status; - long long *cols; - int errs = 0; + int ierr, i, size, rank; + int cnt = 270000000; + int stat_cnt = 0; + MPI_Status status; + long long *cols; + int errs = 0; - MTest_Init(&argc,&argv); + MTest_Init(&argc, &argv); /* need large memory */ - if (sizeof(void *) < 8) { - MTest_Finalize(errs); - MPI_Finalize(); - return 0; - } + if (sizeof(void *) < 8) { + MTest_Finalize(errs); + MPI_Finalize(); + return 0; + } - /* ierr = */ MPI_Comm_size(MPI_COMM_WORLD,&size); - /* ierr = */ MPI_Comm_rank(MPI_COMM_WORLD,&rank); - if (size != 3) { - fprintf(stderr,"[%d] usage: mpiexec -n 3 %s\n",rank,argv[0]); - MPI_Abort(MPI_COMM_WORLD,1); - exit(1); - } + ierr = MPI_Comm_size(MPI_COMM_WORLD, &size); + ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank); + if (size != 3) { + fprintf(stderr, "[%d] usage: mpiexec -n 3 %s\n", rank, argv[0]); + MPI_Abort(MPI_COMM_WORLD, 1); + } - cols = malloc(cnt*sizeof(long long)); - if (cols == NULL) { - printf("malloc of >2GB array failed\n"); - errs++; - MTest_Finalize(errs); - MPI_Finalize(); - return 0; - } + cols = malloc(cnt * sizeof(long long)); + if (cols == NULL) { + printf("malloc of >2GB array failed\n"); + errs++; + MTest_Finalize(errs); + MPI_Finalize(); + return 0; + } - if (rank == 0) { - for (i=0; i +#include +#include +#include + +#define ITER 5 +#define BUF_COUNT (16*1024) + +int rank, nprocs; +char recvbuf[BUF_COUNT], sendbuf[BUF_COUNT]; + +int main(int argc, char *argv[]) +{ + int x, i; + MPI_Status *sendstats = NULL; + MPI_Request *sendreqs = NULL; + + MPI_Init(&argc, &argv); + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &nprocs); + + sendreqs = (MPI_Request *) malloc(nprocs * sizeof(MPI_Request)); + sendstats = (MPI_Status *) malloc(nprocs * sizeof(MPI_Status)); + + for (x = 0; x < ITER; x++) { + MPI_Barrier(MPI_COMM_WORLD); + + /* all to all send */ + for (i = 0; i < nprocs; i++) { + MPI_Isend(sendbuf, BUF_COUNT, MPI_CHAR, i, 0, MPI_COMM_WORLD, &sendreqs[i]); + } + + /* receive one by one */ + for (i = 0; i < nprocs; i++) { + MPI_Recv(recvbuf, BUF_COUNT, MPI_CHAR, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, + MPI_STATUS_IGNORE); + } + + /* ensure all send request completed */ + MPI_Waitall(nprocs, sendreqs, sendstats); + } + + MPI_Barrier(MPI_COMM_WORLD); + if (rank == 0) + printf(" No Errors\n"); + + free(sendreqs); + free(sendstats); + + MPI_Finalize(); + + return 0; +} diff --git a/teshsuite/smpi/mpich3-test/pt2pt/manylmt.c b/teshsuite/smpi/mpich3-test/pt2pt/manylmt.c new file mode 100644 index 0000000000..711f2d6bf9 --- /dev/null +++ b/teshsuite/smpi/mpich3-test/pt2pt/manylmt.c @@ -0,0 +1,61 @@ +/* + * (C) 2016 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + * + * Portions of this code were written by Intel Corporation. + * Copyright (C) 2011-2016 Intel Corporation. Intel provides this material + * to Argonne National Laboratory subject to Software Grant and Corporate + * Contributor License Agreement dated February 8, 2012. + * + * + * This program checks if MPICH can correctly handle + * many outstanding large message transfers + * + */ + +#include +#include +#include +#include + +#define N_TRY 32 +#define BLKSIZE (10*1024*1024) + +int main(int argc, char *argv[]) +{ + int size, rank; + int dest; + int i; + char *buff; + MPI_Request reqs[N_TRY]; + + MPI_Init(&argc, &argv); + + buff = malloc(N_TRY * BLKSIZE); + memset(buff, -1, N_TRY * BLKSIZE); + + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + + dest = size - 1; + + if (rank == 0) { + for (i = 0; i < N_TRY; i++) + MPI_Isend(buff + BLKSIZE*i, BLKSIZE, MPI_BYTE, dest, 0, MPI_COMM_WORLD, &reqs[i]); + MPI_Waitall(N_TRY, reqs, MPI_STATUSES_IGNORE); + } + else if (rank == dest) { + for (i = 0; i < N_TRY; i++) + MPI_Irecv(buff + BLKSIZE*i, BLKSIZE, MPI_BYTE, 0, 0, MPI_COMM_WORLD, &reqs[i]); + MPI_Waitall(N_TRY, reqs, MPI_STATUSES_IGNORE); + } + + free(buff); + + if (rank == 0) + puts(" No Errors"); + + MPI_Finalize(); + + return 0; +} diff --git a/teshsuite/smpi/mpich3-test/pt2pt/mprobe.c b/teshsuite/smpi/mpich3-test/pt2pt/mprobe.c index 2e97536c96..e1c55c96ee 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/mprobe.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/mprobe.c @@ -10,13 +10,6 @@ #include "mpi.h" #include "mpitest.h" -/* This is a temporary #ifdef to control whether we test this functionality. A - * configure-test or similar would be better. Eventually the MPI-3 standard - * will be released and this can be gated on a MPI_VERSION check */ -#if !defined(USE_STRICT_MPI) && defined(MPICH) -#define TEST_MPROBE_ROUTINES 1 -#endif - /* assert-like macro that bumps the err count and emits a message */ #define check(x_) \ do { \ @@ -28,18 +21,20 @@ } \ } while (0) +#define LARGE_DIM 512 +#define LARGE_SZ (LARGE_DIM * LARGE_DIM) + int main(int argc, char **argv) { int errs = 0; - int rank, size; -#ifdef TEST_MPROBE_ROUTINES int found, completed; - int sendbuf[8], recvbuf[8]; - int count; + int rank, size; + int *sendbuf = NULL, *recvbuf = NULL; + int count, i; MPI_Message msg; MPI_Request rreq; MPI_Status s1, s2; -#endif + MPI_Datatype vectype; MPI_Init(&argc, &argv); @@ -49,7 +44,6 @@ int main(int argc, char **argv) if (size < 2) { printf("this test requires at least 2 processes\n"); MPI_Abort(MPI_COMM_WORLD, 1); - exit(1); } /* all processes besides ranks 0 & 1 aren't used by this test */ @@ -57,7 +51,13 @@ int main(int argc, char **argv) goto epilogue; } -#ifdef TEST_MPROBE_ROUTINES + sendbuf = (int *) malloc(LARGE_SZ * sizeof(int)); + recvbuf = (int *) malloc(LARGE_SZ * sizeof(int)); + if (sendbuf == NULL || recvbuf == NULL) { + printf("Error in memory allocation\n"); + MPI_Abort(MPI_COMM_WORLD, 1); + } + /* test 0: simple send & mprobe+mrecv */ if (rank == 0) { sendbuf[0] = 0xdeadbeef; @@ -267,7 +267,7 @@ int main(int argc, char **argv) MPI_Imrecv(recvbuf, count, MPI_INT, &msg, &rreq); check(rreq != MPI_REQUEST_NULL); completed = 0; - MPI_Test(&rreq, &completed, &s2); /* single test should always succeed */ + MPI_Test(&rreq, &completed, &s2); /* single test should always succeed */ check(completed); /* recvbuf should remain unmodified */ check(recvbuf[0] == 0x01234567); @@ -341,7 +341,7 @@ int main(int argc, char **argv) MPI_Imrecv(recvbuf, count, MPI_INT, &msg, &rreq); check(rreq != MPI_REQUEST_NULL); completed = 0; - MPI_Test(&rreq, &completed, &s2); /* single test should always succeed */ + MPI_Test(&rreq, &completed, &s2); /* single test should always succeed */ check(completed); /* recvbuf should remain unmodified */ check(recvbuf[0] == 0x01234567); @@ -356,6 +356,221 @@ int main(int argc, char **argv) check(count == 0); } + /* test 8: simple ssend & mprobe+mrecv */ + if (rank == 0) { + sendbuf[0] = 0xdeadbeef; + sendbuf[1] = 0xfeedface; + MPI_Ssend(sendbuf, 2, MPI_INT, 1, 5, MPI_COMM_WORLD); + } + else { + memset(&s1, 0xab, sizeof(MPI_Status)); + memset(&s2, 0xab, sizeof(MPI_Status)); + /* the error field should remain unmodified */ + s1.MPI_ERROR = MPI_ERR_DIMS; + s2.MPI_ERROR = MPI_ERR_TOPOLOGY; + + msg = MPI_MESSAGE_NULL; + MPI_Mprobe(0, 5, MPI_COMM_WORLD, &msg, &s1); + check(s1.MPI_SOURCE == 0); + check(s1.MPI_TAG == 5); + check(s1.MPI_ERROR == MPI_ERR_DIMS); + check(msg != MPI_MESSAGE_NULL); + + count = -1; + MPI_Get_count(&s1, MPI_INT, &count); + check(count == 2); + + recvbuf[0] = 0x01234567; + recvbuf[1] = 0x89abcdef; + MPI_Mrecv(recvbuf, count, MPI_INT, &msg, &s2); + check(recvbuf[0] == 0xdeadbeef); + check(recvbuf[1] == 0xfeedface); + check(s2.MPI_SOURCE == 0); + check(s2.MPI_TAG == 5); + check(s2.MPI_ERROR == MPI_ERR_TOPOLOGY); + check(msg == MPI_MESSAGE_NULL); + } + + /* test 9: mprobe+mrecv LARGE */ + if (rank == 0) { + for (i = 0; i < LARGE_SZ; i++) + sendbuf[i] = i; + MPI_Send(sendbuf, LARGE_SZ, MPI_INT, 1, 5, MPI_COMM_WORLD); + } + else { + memset(&s1, 0xab, sizeof(MPI_Status)); + memset(&s2, 0xab, sizeof(MPI_Status)); + /* the error field should remain unmodified */ + s1.MPI_ERROR = MPI_ERR_DIMS; + s2.MPI_ERROR = MPI_ERR_TOPOLOGY; + + msg = MPI_MESSAGE_NULL; + MPI_Mprobe(0, 5, MPI_COMM_WORLD, &msg, &s1); + check(s1.MPI_SOURCE == 0); + check(s1.MPI_TAG == 5); + check(s1.MPI_ERROR == MPI_ERR_DIMS); + check(msg != MPI_MESSAGE_NULL); + + count = -1; + MPI_Get_count(&s1, MPI_INT, &count); + check(count == LARGE_SZ); + + memset(recvbuf, 0xFF, LARGE_SZ * sizeof(int)); + MPI_Mrecv(recvbuf, count, MPI_INT, &msg, &s2); + for (i = 0; i < LARGE_SZ; i++) + check(recvbuf[i] == i); + check(s2.MPI_SOURCE == 0); + check(s2.MPI_TAG == 5); + check(s2.MPI_ERROR == MPI_ERR_TOPOLOGY); + check(msg == MPI_MESSAGE_NULL); + } + + /* test 10: mprobe+mrecv noncontiguous datatype */ + MPI_Type_vector(2, 1, 4, MPI_INT, &vectype); + MPI_Type_commit(&vectype); + if (rank == 0) { + memset(sendbuf, 0, 8 * sizeof(int)); + sendbuf[0] = 0xdeadbeef; + sendbuf[4] = 0xfeedface; + MPI_Send(sendbuf, 1, vectype, 1, 5, MPI_COMM_WORLD); + } + else { + memset(&s1, 0xab, sizeof(MPI_Status)); + memset(&s2, 0xab, sizeof(MPI_Status)); + /* the error field should remain unmodified */ + s1.MPI_ERROR = MPI_ERR_DIMS; + s2.MPI_ERROR = MPI_ERR_TOPOLOGY; + + msg = MPI_MESSAGE_NULL; + MPI_Mprobe(0, 5, MPI_COMM_WORLD, &msg, &s1); + check(s1.MPI_SOURCE == 0); + check(s1.MPI_TAG == 5); + check(s1.MPI_ERROR == MPI_ERR_DIMS); + check(msg != MPI_MESSAGE_NULL); + + count = -1; + MPI_Get_count(&s1, vectype, &count); + check(count == 1); + + memset(recvbuf, 0, 8 * sizeof(int)); + MPI_Mrecv(recvbuf, 1, vectype, &msg, &s2); + check(recvbuf[0] == 0xdeadbeef); + for (i = 1; i < 4; i++) + check(recvbuf[i] == 0); + check(recvbuf[4] = 0xfeedface); + for (i = 5; i < 8; i++) + check(recvbuf[i] == 0); + check(s2.MPI_SOURCE == 0); + check(s2.MPI_TAG == 5); + check(s2.MPI_ERROR == MPI_ERR_TOPOLOGY); + check(msg == MPI_MESSAGE_NULL); + } + MPI_Type_free(&vectype); + + /* test 11: mprobe+mrecv noncontiguous datatype LARGE */ + MPI_Type_vector(LARGE_DIM, LARGE_DIM - 1, LARGE_DIM, MPI_INT, &vectype); + MPI_Type_commit(&vectype); + if (rank == 0) { + for (i = 0; i < LARGE_SZ; i++) + sendbuf[i] = i; + MPI_Send(sendbuf, 1, vectype, 1, 5, MPI_COMM_WORLD); + } + else { + int idx = 0; + + memset(&s1, 0xab, sizeof(MPI_Status)); + memset(&s2, 0xab, sizeof(MPI_Status)); + /* the error field should remain unmodified */ + s1.MPI_ERROR = MPI_ERR_DIMS; + s2.MPI_ERROR = MPI_ERR_TOPOLOGY; + + msg = MPI_MESSAGE_NULL; + MPI_Mprobe(0, 5, MPI_COMM_WORLD, &msg, &s1); + check(s1.MPI_SOURCE == 0); + check(s1.MPI_TAG == 5); + check(s1.MPI_ERROR == MPI_ERR_DIMS); + check(msg != MPI_MESSAGE_NULL); + + count = -1; + MPI_Get_count(&s1, vectype, &count); + check(count == 1); + + memset(recvbuf, 0, LARGE_SZ * sizeof(int)); + MPI_Mrecv(recvbuf, 1, vectype, &msg, &s2); + for (i = 0; i < LARGE_DIM; i++) { + int j; + for (j = 0; j < LARGE_DIM - 1; j++) { + check(recvbuf[idx] == idx); + ++idx; + } + check(recvbuf[idx++] == 0); + } + check(s2.MPI_SOURCE == 0); + check(s2.MPI_TAG == 5); + check(s2.MPI_ERROR == MPI_ERR_TOPOLOGY); + check(msg == MPI_MESSAGE_NULL); + } + MPI_Type_free(&vectype); + + /* test 12: order test */ + if (rank == 0) { + MPI_Request lrequest[2]; + sendbuf[0] = 0xdeadbeef; + sendbuf[1] = 0xfeedface; + sendbuf[2] = 0xdeadbeef; + sendbuf[3] = 0xfeedface; + sendbuf[4] = 0xdeadbeef; + sendbuf[5] = 0xfeedface; + MPI_Isend(&sendbuf[0], 4, MPI_INT, 1, 6, MPI_COMM_WORLD, &lrequest[0]); + MPI_Isend(&sendbuf[4], 2, MPI_INT, 1, 6, MPI_COMM_WORLD, &lrequest[1]); + MPI_Waitall(2, &lrequest[0], MPI_STATUSES_IGNORE); + } + else { + memset(&s1, 0xab, sizeof(MPI_Status)); + memset(&s2, 0xab, sizeof(MPI_Status)); + /* the error field should remain unmodified */ + s1.MPI_ERROR = MPI_ERR_DIMS; + s2.MPI_ERROR = MPI_ERR_TOPOLOGY; + + msg = MPI_MESSAGE_NULL; + MPI_Mprobe(0, 6, MPI_COMM_WORLD, &msg, &s1); + check(s1.MPI_SOURCE == 0); + check(s1.MPI_TAG == 6); + check(s1.MPI_ERROR == MPI_ERR_DIMS); + check(msg != MPI_MESSAGE_NULL); + + count = -1; + MPI_Get_count(&s1, MPI_INT, &count); + check(count == 4); + + recvbuf[0] = 0x01234567; + recvbuf[1] = 0x89abcdef; + MPI_Recv(recvbuf, 2, MPI_INT, 0, 6, MPI_COMM_WORLD, &s2); + check(s2.MPI_SOURCE == 0); + check(s2.MPI_TAG == 6); + check(recvbuf[0] == 0xdeadbeef); + check(recvbuf[1] == 0xfeedface); + + recvbuf[0] = 0x01234567; + recvbuf[1] = 0x89abcdef; + recvbuf[2] = 0x01234567; + recvbuf[3] = 0x89abcdef; + s2.MPI_ERROR = MPI_ERR_TOPOLOGY; + + MPI_Mrecv(recvbuf, count, MPI_INT, &msg, &s2); + check(recvbuf[0] == 0xdeadbeef); + check(recvbuf[1] == 0xfeedface); + check(recvbuf[2] == 0xdeadbeef); + check(recvbuf[3] == 0xfeedface); + check(s2.MPI_SOURCE == 0); + check(s2.MPI_TAG == 6); + check(s2.MPI_ERROR == MPI_ERR_TOPOLOGY); + check(msg == MPI_MESSAGE_NULL); + } + + free(sendbuf); + free(recvbuf); + /* TODO MPI_ANY_SOURCE and MPI_ANY_TAG should be tested as well */ /* TODO a full range of message sizes should be tested too */ /* TODO threaded tests are also needed, but they should go in a separate @@ -378,9 +593,7 @@ int main(int argc, char **argv) check(msg == MPI_MESSAGE_NULL); } -#endif /* TEST_MPROBE_ROUTINES */ - -epilogue: + epilogue: MPI_Reduce((rank == 0 ? MPI_IN_PLACE : &errs), &errs, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); if (rank == 0) { if (errs) { @@ -395,4 +608,3 @@ epilogue: return 0; } - diff --git a/teshsuite/smpi/mpich3-test/pt2pt/pingping.c b/teshsuite/smpi/mpich3-test/pt2pt/pingping.c index 5d48fdcc50..bdc0b91032 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/pingping.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/pingping.c @@ -14,98 +14,104 @@ static char MTEST_Descrip[] = "Send flood test"; #define MAX_MSG_SIZE 40000 #define MAX_COUNT 20 -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0, err; int rank, size, source, dest; - int minsize = 2, count, nmsg, maxmsg; - MPI_Comm comm; + int minsize = 2, count, nmsg, maxmsg; + MPI_Comm comm; MTestDatatype sendtype, recvtype; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - /* The following illustrates the use of the routines to - run through a selection of communicators and datatypes. - Use subsets of these for tests that do not involve combinations - of communicators, datatypes, and counts of datatypes */ - while (MTestGetIntracommGeneral( &comm, minsize, 1 )) { - if (comm == MPI_COMM_NULL) continue; - /* Determine the sender and receiver */ - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); - source = 0; - dest = size - 1; - - /* To improve reporting of problems about operations, we - change the error handler to errors return */ - MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN ); + /* The following illustrates the use of the routines to + * run through a selection of communicators and datatypes. + * Use subsets of these for tests that do not involve combinations + * of communicators, datatypes, and counts of datatypes */ + while (MTestGetIntracommGeneral(&comm, minsize, 1)) { + if (comm == MPI_COMM_NULL) + continue; + /* Determine the sender and receiver */ + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); + source = 0; + dest = size - 1; - for (count = 1; count < MAX_COUNT; count = count * 2) { - while (MTestGetDatatypes( &sendtype, &recvtype, count )) { - int nbytes; - MPI_Type_size( sendtype.datatype, &nbytes ); + /* To improve reporting of problems about operations, we + * change the error handler to errors return */ + MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN); - /* We may want to limit the total message size sent */ - if (nbytes > MAX_MSG_SIZE) { - /* We do not need to free, as we haven't - initialized any of the buffers (?) */ - continue; - } - maxmsg = MAX_COUNT - count; - MTestPrintfMsg( 1, "Sending count = %d of sendtype %s of total size %d bytes\n", - count, MTestGetDatatypeName( &sendtype ), - nbytes*count ); - /* Make sure that everyone has a recv buffer */ - recvtype.InitBuf( &recvtype ); + for (count = 1; count < MAX_COUNT; count = count * 2) { - if (rank == source) { - sendtype.InitBuf( &sendtype ); - - for (nmsg=1; nmsg MAX_MSG_SIZE) { + /* We do not need to free, as we haven't + * initialized any of the buffers (?) */ + continue; + } + maxmsg = MAX_COUNT - count; + MTestPrintfMsg(1, "Sending count = %d of sendtype %s of total size %d bytes\n", + count, MTestGetDatatypeName(&sendtype), nbytes * count); + /* Make sure that everyone has a recv buffer */ + recvtype.InitBuf(&recvtype); + + if (rank == source) { + sendtype.InitBuf(&sendtype); + + for (nmsg = 1; nmsg < maxmsg; nmsg++) { + err = MPI_Send(sendtype.buf, sendtype.count, + sendtype.datatype, dest, 0, comm); + if (err) { + errs++; + if (errs < 10) { + MTestPrintError(err); + } + } + } + } + else if (rank == dest) { + for (nmsg = 1; nmsg < maxmsg; nmsg++) { + err = MPI_Recv(recvtype.buf, recvtype.count, + recvtype.datatype, source, 0, comm, MPI_STATUS_IGNORE); + if (err) { + errs++; + if (errs < 10) { + MTestPrintError(err); + } + } + + err = MTestCheckRecv(0, &recvtype); + if (err) { + if (errs < 10) { + printf + ("Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d, message iteration %d of %d\n", + MTestGetDatatypeName(&recvtype), + MTestGetDatatypeName(&sendtype), count, nmsg, maxmsg); + recvtype.printErrors = 1; + (void) MTestCheckRecv(0, &recvtype); + } + errs += err; + } + } + } + MTestFreeDatatype(&recvtype); + MTestFreeDatatype(&sendtype); + } + } + MTestFreeComm(&comm); } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/pt2pt/probe-unexp.c b/teshsuite/smpi/mpich3-test/pt2pt/probe-unexp.c index 43e2ed85a7..358d67c923 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/probe-unexp.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/probe-unexp.c @@ -11,7 +11,7 @@ #define NUM_MSGS_PER_BUF_SIZE 5 char buf[1 << MAX_BUF_SIZE_LG]; -/* +/* * This program verifies that MPI_Probe() is operating properly in the face of * unexpected messages arriving after MPI_Probe() has * been called. This program may hang if MPI_Probe() does not return when the @@ -24,137 +24,123 @@ int main(int argc, char **argv) int msg_size_lg; int errs = 0; int mpi_errno; - + MTest_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &p_size); MPI_Comm_rank(MPI_COMM_WORLD, &p_rank); /* To improve reporting of problems about operations, we - change the error handler to errors return */ - MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN ); - - - for (msg_size_lg = 0; msg_size_lg <= MAX_BUF_SIZE_LG; msg_size_lg++) - { - const int msg_size = 1 << msg_size_lg; - int msg_cnt; - - MTestPrintfMsg( 2, "testing messages of size %d\n", msg_size ); - for (msg_cnt = 0; msg_cnt < NUM_MSGS_PER_BUF_SIZE; msg_cnt++) - { - MPI_Status status; - const int tag = msg_size_lg * NUM_MSGS_PER_BUF_SIZE + msg_cnt; - - MTestPrintfMsg( 2, "Message count %d\n", msg_cnt ); - if (p_rank == 0) - { - int p; - - for (p = 1; p < p_size; p ++) - { - /* Wait for synchronization message */ - mpi_errno = MPI_Recv(NULL, 0, MPI_BYTE, MPI_ANY_SOURCE, - tag, MPI_COMM_WORLD, &status); - if (mpi_errno != MPI_SUCCESS && errs++ < 10) - { - MTestPrintError(mpi_errno); - } - - if (status.MPI_TAG != tag && errs++ < 10) - { - printf("ERROR: unexpected message tag from MPI_Recv(): lp=0, rp=%d, expected=%d, actual=%d, count=%d\n", - status.MPI_SOURCE, status.MPI_TAG, tag, msg_cnt); - } + * change the error handler to errors return */ + MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN); + + + for (msg_size_lg = 0; msg_size_lg <= MAX_BUF_SIZE_LG; msg_size_lg++) { + const int msg_size = 1 << msg_size_lg; + int msg_cnt; + + MTestPrintfMsg(2, "testing messages of size %d\n", msg_size); + for (msg_cnt = 0; msg_cnt < NUM_MSGS_PER_BUF_SIZE; msg_cnt++) { + MPI_Status status; + const int tag = msg_size_lg * NUM_MSGS_PER_BUF_SIZE + msg_cnt; + + MTestPrintfMsg(2, "Message count %d\n", msg_cnt); + if (p_rank == 0) { + int p; + + for (p = 1; p < p_size; p++) { + /* Wait for synchronization message */ + mpi_errno = MPI_Recv(NULL, 0, MPI_BYTE, MPI_ANY_SOURCE, + tag, MPI_COMM_WORLD, &status); + if (mpi_errno != MPI_SUCCESS && errs++ < 10) { + MTestPrintError(mpi_errno); + } + + if (status.MPI_TAG != tag && errs++ < 10) { + printf + ("ERROR: unexpected message tag from MPI_Recv(): lp=0, rp=%d, expected=%d, actual=%d, count=%d\n", + status.MPI_SOURCE, status.MPI_TAG, tag, msg_cnt); + } # if defined(VERBOSE) - { - printf("sending message: p=%d s=%d c=%d\n", - status.MPI_SOURCE, msg_size, msg_cnt); - } + { + printf("sending message: p=%d s=%d c=%d\n", + status.MPI_SOURCE, msg_size, msg_cnt); + } # endif - - /* Send unexpected message which hopefully MPI_Probe() is - already waiting for at the remote process */ - mpi_errno = MPI_Send (buf, msg_size, MPI_BYTE, - status.MPI_SOURCE, status.MPI_TAG, MPI_COMM_WORLD); - if (mpi_errno != MPI_SUCCESS && errs++ < 10) - { - MTestPrintError(mpi_errno); - } - } - } - else - { - int incoming_msg_size; - - /* Send synchronization message */ - mpi_errno = MPI_Send(NULL, 0, MPI_BYTE, 0, tag, MPI_COMM_WORLD); - if (mpi_errno != MPI_SUCCESS && errs++ < 10) - { - MTestPrintError(mpi_errno); - } - - /* Perform probe, hopefully before the master process can - send its reply */ - mpi_errno = MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, - MPI_COMM_WORLD, &status); - if (mpi_errno != MPI_SUCCESS && errs++ < 10) - { - MTestPrintError(mpi_errno); - } - mpi_errno = MPI_Get_count(&status, MPI_BYTE, &incoming_msg_size); - if (mpi_errno != MPI_SUCCESS && errs++ < 10) - { - MTestPrintError(mpi_errno); - } - if (status.MPI_SOURCE != 0 && errs++ < 10) - { - printf("ERROR: unexpected message source from MPI_Probe(): p=%d, expected=0, actual=%d, count=%d\n", - p_rank, status.MPI_SOURCE, msg_cnt); - } - if (status.MPI_TAG != tag && errs++ < 10) - { - printf("ERROR: unexpected message tag from MPI_Probe(): p=%d, expected=%d, actual=%d, count=%d\n", - p_rank, tag, status.MPI_TAG, msg_cnt); - } - if (incoming_msg_size != msg_size && errs++ < 10) - { - printf("ERROR: unexpected message size from MPI_Probe(): p=%d, expected=%d, actual=%d, count=%d\n", - p_rank, msg_size, incoming_msg_size, msg_cnt); - } - - /* Receive the probed message from the master process */ - mpi_errno = MPI_Recv(buf, msg_size, MPI_BYTE, 0, tag, - MPI_COMM_WORLD, &status); - if (mpi_errno != MPI_SUCCESS && errs++ < 10) - { - MTestPrintError(mpi_errno); - } - mpi_errno = MPI_Get_count(&status, MPI_BYTE, &incoming_msg_size); - if (mpi_errno != MPI_SUCCESS && errs++ < 10) - { - MTestPrintError(mpi_errno); - } - if (status.MPI_SOURCE != 0 && errs++ < 10) - { - printf("ERROR: unexpected message source from MPI_Recv(): p=%d, expected=0, actual=%d, count=%d\n", - p_rank, status.MPI_SOURCE, msg_cnt); - } - if (status.MPI_TAG != tag && errs++ < 10) - { - printf("ERROR: unexpected message tag from MPI_Recv(): p=%d, expected=%d, actual=%d, count=%d\n", - p_rank, tag, status.MPI_TAG, msg_cnt); - } - if (incoming_msg_size != msg_size && errs++ < 10) - { - printf("ERROR: unexpected message size from MPI_Recv(): p=%d, expected=%d, actual=%d, count=%d\n", - p_rank, msg_size, incoming_msg_size, msg_cnt); - } - } - } + + /* Send unexpected message which hopefully MPI_Probe() is + * already waiting for at the remote process */ + mpi_errno = MPI_Send(buf, msg_size, MPI_BYTE, + status.MPI_SOURCE, status.MPI_TAG, MPI_COMM_WORLD); + if (mpi_errno != MPI_SUCCESS && errs++ < 10) { + MTestPrintError(mpi_errno); + } + } + } + else { + int incoming_msg_size; + + /* Send synchronization message */ + mpi_errno = MPI_Send(NULL, 0, MPI_BYTE, 0, tag, MPI_COMM_WORLD); + if (mpi_errno != MPI_SUCCESS && errs++ < 10) { + MTestPrintError(mpi_errno); + } + + /* Perform probe, hopefully before the master process can + * send its reply */ + mpi_errno = MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status); + if (mpi_errno != MPI_SUCCESS && errs++ < 10) { + MTestPrintError(mpi_errno); + } + mpi_errno = MPI_Get_count(&status, MPI_BYTE, &incoming_msg_size); + if (mpi_errno != MPI_SUCCESS && errs++ < 10) { + MTestPrintError(mpi_errno); + } + if (status.MPI_SOURCE != 0 && errs++ < 10) { + printf + ("ERROR: unexpected message source from MPI_Probe(): p=%d, expected=0, actual=%d, count=%d\n", + p_rank, status.MPI_SOURCE, msg_cnt); + } + if (status.MPI_TAG != tag && errs++ < 10) { + printf + ("ERROR: unexpected message tag from MPI_Probe(): p=%d, expected=%d, actual=%d, count=%d\n", + p_rank, tag, status.MPI_TAG, msg_cnt); + } + if (incoming_msg_size != msg_size && errs++ < 10) { + printf + ("ERROR: unexpected message size from MPI_Probe(): p=%d, expected=%d, actual=%d, count=%d\n", + p_rank, msg_size, incoming_msg_size, msg_cnt); + } + + /* Receive the probed message from the master process */ + mpi_errno = MPI_Recv(buf, msg_size, MPI_BYTE, 0, tag, MPI_COMM_WORLD, &status); + if (mpi_errno != MPI_SUCCESS && errs++ < 10) { + MTestPrintError(mpi_errno); + } + mpi_errno = MPI_Get_count(&status, MPI_BYTE, &incoming_msg_size); + if (mpi_errno != MPI_SUCCESS && errs++ < 10) { + MTestPrintError(mpi_errno); + } + if (status.MPI_SOURCE != 0 && errs++ < 10) { + printf + ("ERROR: unexpected message source from MPI_Recv(): p=%d, expected=0, actual=%d, count=%d\n", + p_rank, status.MPI_SOURCE, msg_cnt); + } + if (status.MPI_TAG != tag && errs++ < 10) { + printf + ("ERROR: unexpected message tag from MPI_Recv(): p=%d, expected=%d, actual=%d, count=%d\n", + p_rank, tag, status.MPI_TAG, msg_cnt); + } + if (incoming_msg_size != msg_size && errs++ < 10) { + printf + ("ERROR: unexpected message size from MPI_Recv(): p=%d, expected=%d, actual=%d, count=%d\n", + p_rank, msg_size, incoming_msg_size, msg_cnt); + } + } + } } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/pt2pt/probenull.c b/teshsuite/smpi/mpich3-test/pt2pt/probenull.c index 547960522e..6ff87997a6 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/probenull.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/probenull.c @@ -7,7 +7,7 @@ #include "mpi.h" #include "mpitest.h" -/* +/* * This program checks that MPI_Iprobe and MPI_Probe correctly handle * a source of MPI_PROC_NULL */ @@ -20,40 +20,36 @@ int main(int argc, char **argv) MTest_Init(&argc, &argv); - MPI_Iprobe( MPI_PROC_NULL, 10, MPI_COMM_WORLD, &flag, &status ); + MPI_Iprobe(MPI_PROC_NULL, 10, MPI_COMM_WORLD, &flag, &status); if (!flag) { - errs++; - printf( "Iprobe of source=MPI_PROC_NULL returned flag=false\n" ); + errs++; + printf("Iprobe of source=MPI_PROC_NULL returned flag=false\n"); } else { - if (status.MPI_SOURCE != MPI_PROC_NULL) { - printf( "Status.MPI_SOURCE was %d, should be MPI_PROC_NULL\n", - status.MPI_SOURCE ); - errs++; - } - if (status.MPI_TAG != MPI_ANY_TAG) { - printf( "Status.MPI_TAG was %d, should be MPI_ANY_TAGL\n", - status.MPI_TAG ); - errs++; - } + if (status.MPI_SOURCE != MPI_PROC_NULL) { + printf("Status.MPI_SOURCE was %d, should be MPI_PROC_NULL\n", status.MPI_SOURCE); + errs++; + } + if (status.MPI_TAG != MPI_ANY_TAG) { + printf("Status.MPI_TAG was %d, should be MPI_ANY_TAGL\n", status.MPI_TAG); + errs++; + } } - /* If Iprobe failed, probe is likely to as well. Avoid a possible hang - by testing Probe only if Iprobe test passed */ + /* If Iprobe failed, probe is likely to as well. Avoid a possible hang + * by testing Probe only if Iprobe test passed */ if (errs == 0) { - MPI_Probe( MPI_PROC_NULL, 10, MPI_COMM_WORLD, &status ); - if (status.MPI_SOURCE != MPI_PROC_NULL) { - printf( "Status.MPI_SOURCE was %d, should be MPI_PROC_NULL\n", - status.MPI_SOURCE ); - errs++; - } - if (status.MPI_TAG != MPI_ANY_TAG) { - printf( "Status.MPI_TAG was %d, should be MPI_ANY_TAGL\n", - status.MPI_TAG ); - errs++; - } + MPI_Probe(MPI_PROC_NULL, 10, MPI_COMM_WORLD, &status); + if (status.MPI_SOURCE != MPI_PROC_NULL) { + printf("Status.MPI_SOURCE was %d, should be MPI_PROC_NULL\n", status.MPI_SOURCE); + errs++; + } + if (status.MPI_TAG != MPI_ANY_TAG) { + printf("Status.MPI_TAG was %d, should be MPI_ANY_TAGL\n", status.MPI_TAG); + errs++; + } } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/pt2pt/pscancel.c b/teshsuite/smpi/mpich3-test/pt2pt/pscancel.c index 08b6b2c11f..1938dadbb2 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/pscancel.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/pscancel.c @@ -12,271 +12,246 @@ static char MTEST_Descrip[] = "Test of various send cancel calls"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; - int rank, size, /* source, */ dest; - MPI_Comm comm; - MPI_Status status; - MPI_Request req; + int rank, size, source, dest; + MPI_Comm comm; + MPI_Status status; + MPI_Request req; static int bufsizes[4] = { 1, 100, 10000, 1000000 }; char *buf; - int cs, flag, n; + int cs, flag, n; #ifdef TEST_IRSEND - int veryPicky = 0; /* Set to 1 to test "quality of implementation" in - a tricky part of cancel */ + int veryPicky = 0; /* Set to 1 to test "quality of implementation" in + * a tricky part of cancel */ #endif - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); - /* source = 0; */ - dest = size - 1; + source = 0; + dest = size - 1; - for (cs=0; cs<4; cs++) { - if (rank == 0) { - n = bufsizes[cs]; - buf = (char *)malloc( n ); - if (!buf) { - fprintf( stderr, "Unable to allocate %d bytes\n", n ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - MPI_Send_init( buf, n, MPI_CHAR, dest, cs+n+1, comm, &req ); - MPI_Start( &req ); - MPI_Cancel( &req ); - MPI_Wait( &req, &status ); - MPI_Test_cancelled( &status, &flag ); - if (!flag) { - errs ++; - printf( "Failed to cancel a persistent send request\n" ); - fflush(stdout); - } - else - { - n = 0; - } - MPI_Request_free( &req ); - /* Send the size, zero for successfully cancelled */ - MPI_Send( &n, 1, MPI_INT, dest, 123, comm ); - /* Send the tag so the message can be received */ - n = cs+n+1; - MPI_Send( &n, 1, MPI_INT, dest, 123, comm ); - free( buf ); - } - else if (rank == dest) - { - int nn, tag; - char *btemp; - MPI_Recv( &nn, 1, MPI_INT, 0, 123, comm, &status ); - MPI_Recv( &tag, 1, MPI_INT, 0, 123, comm, &status ); - if (nn > 0) - { - /* If the message was not cancelled, receive it here */ - btemp = (char*)malloc( nn ); - if (!btemp) - { - fprintf( stderr, "Unable to allocate %d bytes\n", nn); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - MPI_Recv( btemp, nn, MPI_CHAR, 0, tag, comm, &status ); - free(btemp); - } - } - MPI_Barrier( comm ); + for (cs = 0; cs < 4; cs++) { + if (rank == 0) { + n = bufsizes[cs]; + buf = (char *) malloc(n); + if (!buf) { + fprintf(stderr, "Unable to allocate %d bytes\n", n); + MPI_Abort(MPI_COMM_WORLD, 1); + } + MPI_Send_init(buf, n, MPI_CHAR, dest, cs + n + 1, comm, &req); + MPI_Start(&req); + MPI_Cancel(&req); + MPI_Wait(&req, &status); + MPI_Test_cancelled(&status, &flag); + if (!flag) { + errs++; + printf("Failed to cancel a persistent send request\n"); + fflush(stdout); + } + else { + n = 0; + } + MPI_Request_free(&req); + /* Send the size, zero for successfully cancelled */ + MPI_Send(&n, 1, MPI_INT, dest, 123, comm); + /* Send the tag so the message can be received */ + n = cs + n + 1; + MPI_Send(&n, 1, MPI_INT, dest, 123, comm); + free(buf); + } + else if (rank == dest) { + int nn, tag; + char *btemp; + MPI_Recv(&nn, 1, MPI_INT, 0, 123, comm, &status); + MPI_Recv(&tag, 1, MPI_INT, 0, 123, comm, &status); + if (nn > 0) { + /* If the message was not cancelled, receive it here */ + btemp = (char *) malloc(nn); + if (!btemp) { + fprintf(stderr, "Unable to allocate %d bytes\n", nn); + MPI_Abort(MPI_COMM_WORLD, 1); + } + MPI_Recv(btemp, nn, MPI_CHAR, 0, tag, comm, &status); + free(btemp); + } + } + MPI_Barrier(comm); - if (rank == 0) { - char *bsendbuf; - int bsendbufsize; - int bf, bs; - n = bufsizes[cs]; - buf = (char *)malloc( n ); - if (!buf) { - fprintf( stderr, "Unable to allocate %d bytes\n", n ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - bsendbufsize = n + MPI_BSEND_OVERHEAD; - bsendbuf = (char *)malloc( bsendbufsize ); - if (!bsendbuf) { - fprintf( stderr, "Unable to allocate %d bytes for bsend\n", n ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - MPI_Buffer_attach( bsendbuf, bsendbufsize ); - MPI_Bsend_init( buf, n, MPI_CHAR, dest, cs+n+2, comm, &req ); - MPI_Start( &req ); - MPI_Cancel( &req ); - MPI_Wait( &req, &status ); - MPI_Test_cancelled( &status, &flag ); - if (!flag) { - errs ++; - printf( "Failed to cancel a persistent bsend request\n" ); - fflush(stdout); - } - else - { - n = 0; - } - MPI_Request_free( &req ); - /* Send the size, zero for successfully cancelled */ - MPI_Send( &n, 1, MPI_INT, dest, 123, comm ); - /* Send the tag so the message can be received */ - n = cs+n+2; - MPI_Send( &n, 1, MPI_INT, dest, 123, comm ); - free( buf ); - MPI_Buffer_detach( &bf, &bs ); - free( bsendbuf ); - } - else if (rank == dest) - { - int nn, tag; - char *btemp; - MPI_Recv( &nn, 1, MPI_INT, 0, 123, comm, &status ); - MPI_Recv( &tag, 1, MPI_INT, 0, 123, comm, &status ); - if (nn > 0) - { - /* If the message was not cancelled, receive it here */ - btemp = (char*)malloc( nn ); - if (!btemp) - { - fprintf( stderr, "Unable to allocate %d bytes\n", nn); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - MPI_Recv( btemp, nn, MPI_CHAR, 0, tag, comm, &status ); - free(btemp); - } - } - MPI_Barrier( comm ); + if (rank == 0) { + char *bsendbuf; + int bsendbufsize; + int bf, bs; + n = bufsizes[cs]; + buf = (char *) malloc(n); + if (!buf) { + fprintf(stderr, "Unable to allocate %d bytes\n", n); + MPI_Abort(MPI_COMM_WORLD, 1); + } + bsendbufsize = n + MPI_BSEND_OVERHEAD; + bsendbuf = (char *) malloc(bsendbufsize); + if (!bsendbuf) { + fprintf(stderr, "Unable to allocate %d bytes for bsend\n", n); + MPI_Abort(MPI_COMM_WORLD, 1); + } + MPI_Buffer_attach(bsendbuf, bsendbufsize); + MPI_Bsend_init(buf, n, MPI_CHAR, dest, cs + n + 2, comm, &req); + MPI_Start(&req); + MPI_Cancel(&req); + MPI_Wait(&req, &status); + MPI_Test_cancelled(&status, &flag); + if (!flag) { + errs++; + printf("Failed to cancel a persistent bsend request\n"); + fflush(stdout); + } + else { + n = 0; + } + MPI_Request_free(&req); + /* Send the size, zero for successfully cancelled */ + MPI_Send(&n, 1, MPI_INT, dest, 123, comm); + /* Send the tag so the message can be received */ + n = cs + n + 2; + MPI_Send(&n, 1, MPI_INT, dest, 123, comm); + free(buf); + MPI_Buffer_detach(&bf, &bs); + free(bsendbuf); + } + else if (rank == dest) { + int nn, tag; + char *btemp; + MPI_Recv(&nn, 1, MPI_INT, 0, 123, comm, &status); + MPI_Recv(&tag, 1, MPI_INT, 0, 123, comm, &status); + if (nn > 0) { + /* If the message was not cancelled, receive it here */ + btemp = (char *) malloc(nn); + if (!btemp) { + fprintf(stderr, "Unable to allocate %d bytes\n", nn); + MPI_Abort(MPI_COMM_WORLD, 1); + } + MPI_Recv(btemp, nn, MPI_CHAR, 0, tag, comm, &status); + free(btemp); + } + } + MPI_Barrier(comm); - /* Because this test is erroneous, we do not perform it unless - TEST_IRSEND is defined. */ + /* Because this test is erroneous, we do not perform it unless + * TEST_IRSEND is defined. */ #ifdef TEST_IRSEND - /* We avoid ready send to self because an implementation - is free to detect the error in delivering a message to - itself without a pending receive; we could also check - for an error return from the MPI_Irsend */ - if (rank == 0 && dest != rank) { - n = bufsizes[cs]; - buf = (char *)malloc( n ); - if (!buf) { - fprintf( stderr, "Unable to allocate %d bytes\n", n ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - MPI_Rsend_init( buf, n, MPI_CHAR, dest, cs+n+3, comm, &req ); - MPI_Start( &req ); - MPI_Cancel( &req ); - MPI_Wait( &req, &status ); - MPI_Test_cancelled( &status, &flag ); - /* This can be pretty ugly. The standard is clear (Section 3.8) - that either a sent message is received or the - sent message is successfully cancelled. Since this message - can never be received, the cancel must complete - successfully. - - However, since there is no matching receive, this - program is erroneous. In this case, we can't really - flag this as an error */ - if (!flag && veryPicky) { - errs ++; - printf( "Failed to cancel a persistent rsend request\n" ); - fflush(stdout); - } - if (flag) - { - n = 0; - } - MPI_Request_free( &req ); - /* Send the size, zero for successfully cancelled */ - MPI_Send( &n, 1, MPI_INT, dest, 123, comm ); - /* Send the tag so the message can be received */ - n = cs+n+3; - MPI_Send( &n, 1, MPI_INT, dest, 123, comm ); - free( buf ); - } - else if (rank == dest) - { - int n, tag; - char *btemp; - MPI_Recv( &n, 1, MPI_INT, 0, 123, comm, &status ); - MPI_Recv( &tag, 1, MPI_INT, 0, 123, comm, &status ); - if (n > 0) - { - /* If the message was not cancelled, receive it here */ - btemp = (char*)malloc( n ); - if (!btemp) - { - fprintf( stderr, "Unable to allocate %d bytes\n", n); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - MPI_Recv( btemp, n, MPI_CHAR, 0, tag, comm, &status ); - free(btemp); - } - } - MPI_Barrier( comm ); + /* We avoid ready send to self because an implementation + * is free to detect the error in delivering a message to + * itself without a pending receive; we could also check + * for an error return from the MPI_Irsend */ + if (rank == 0 && dest != rank) { + n = bufsizes[cs]; + buf = (char *) malloc(n); + if (!buf) { + fprintf(stderr, "Unable to allocate %d bytes\n", n); + MPI_Abort(MPI_COMM_WORLD, 1); + } + MPI_Rsend_init(buf, n, MPI_CHAR, dest, cs + n + 3, comm, &req); + MPI_Start(&req); + MPI_Cancel(&req); + MPI_Wait(&req, &status); + MPI_Test_cancelled(&status, &flag); + /* This can be pretty ugly. The standard is clear (Section 3.8) + * that either a sent message is received or the + * sent message is successfully cancelled. Since this message + * can never be received, the cancel must complete + * successfully. + * + * However, since there is no matching receive, this + * program is erroneous. In this case, we can't really + * flag this as an error */ + if (!flag && veryPicky) { + errs++; + printf("Failed to cancel a persistent rsend request\n"); + fflush(stdout); + } + if (flag) { + n = 0; + } + MPI_Request_free(&req); + /* Send the size, zero for successfully cancelled */ + MPI_Send(&n, 1, MPI_INT, dest, 123, comm); + /* Send the tag so the message can be received */ + n = cs + n + 3; + MPI_Send(&n, 1, MPI_INT, dest, 123, comm); + free(buf); + } + else if (rank == dest) { + int n, tag; + char *btemp; + MPI_Recv(&n, 1, MPI_INT, 0, 123, comm, &status); + MPI_Recv(&tag, 1, MPI_INT, 0, 123, comm, &status); + if (n > 0) { + /* If the message was not cancelled, receive it here */ + btemp = (char *) malloc(n); + if (!btemp) { + fprintf(stderr, "Unable to allocate %d bytes\n", n); + MPI_Abort(MPI_COMM_WORLD, 1); + } + MPI_Recv(btemp, n, MPI_CHAR, 0, tag, comm, &status); + free(btemp); + } + } + MPI_Barrier(comm); #endif - if (rank == 0) { - n = bufsizes[cs]; - buf = (char *)malloc( n ); - if (!buf) { - fprintf( stderr, "Unable to allocate %d bytes\n", n ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - MPI_Ssend_init( buf, n, MPI_CHAR, dest, cs+n+4, comm, &req ); - MPI_Start( &req ); - MPI_Cancel( &req ); - MPI_Wait( &req, &status ); - MPI_Test_cancelled( &status, &flag ); - if (!flag) { - errs ++; - printf( "Failed to cancel a persistent ssend request\n" ); - fflush(stdout); - } - else - { - n = 0; - } - MPI_Request_free( &req ); - /* Send the size, zero for successfully cancelled */ - MPI_Send( &n, 1, MPI_INT, dest, 123, comm ); - /* Send the tag so the message can be received */ - n = cs+n+4; - MPI_Send( &n, 1, MPI_INT, dest, 123, comm ); - free( buf ); - } - else if (rank == dest) - { - int nn, tag; - char *btemp; - MPI_Recv( &nn, 1, MPI_INT, 0, 123, comm, &status ); - MPI_Recv( &tag, 1, MPI_INT, 0, 123, comm, &status ); - if (nn > 0) - { - /* If the message was not cancelled, receive it here */ - btemp = (char*)malloc( nn ); - if (!btemp) - { - fprintf( stderr, "Unable to allocate %d bytes\n", nn); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - MPI_Recv( btemp, nn, MPI_CHAR, 0, tag, comm, &status ); - free(btemp); - } - } - MPI_Barrier( comm ); + if (rank == 0) { + n = bufsizes[cs]; + buf = (char *) malloc(n); + if (!buf) { + fprintf(stderr, "Unable to allocate %d bytes\n", n); + MPI_Abort(MPI_COMM_WORLD, 1); + } + MPI_Ssend_init(buf, n, MPI_CHAR, dest, cs + n + 4, comm, &req); + MPI_Start(&req); + MPI_Cancel(&req); + MPI_Wait(&req, &status); + MPI_Test_cancelled(&status, &flag); + if (!flag) { + errs++; + printf("Failed to cancel a persistent ssend request\n"); + fflush(stdout); + } + else { + n = 0; + } + MPI_Request_free(&req); + /* Send the size, zero for successfully cancelled */ + MPI_Send(&n, 1, MPI_INT, dest, 123, comm); + /* Send the tag so the message can be received */ + n = cs + n + 4; + MPI_Send(&n, 1, MPI_INT, dest, 123, comm); + free(buf); + } + else if (rank == dest) { + int nn, tag; + char *btemp; + MPI_Recv(&nn, 1, MPI_INT, 0, 123, comm, &status); + MPI_Recv(&tag, 1, MPI_INT, 0, 123, comm, &status); + if (nn > 0) { + /* If the message was not cancelled, receive it here */ + btemp = (char *) malloc(nn); + if (!btemp) { + fprintf(stderr, "Unable to allocate %d bytes\n", nn); + MPI_Abort(MPI_COMM_WORLD, 1); + } + MPI_Recv(btemp, nn, MPI_CHAR, 0, tag, comm, &status); + free(btemp); + } + } + MPI_Barrier(comm); } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/pt2pt/rcancel.c b/teshsuite/smpi/mpich3-test/pt2pt/rcancel.c index 398ed9abea..07e3b669ae 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/rcancel.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/rcancel.c @@ -12,75 +12,78 @@ static char MTEST_Descrip[] = "Test of various receive cancel calls, with multiple requests to cancel"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rank, size, source, dest; - MPI_Comm comm; - MPI_Status status; - MPI_Request req[4]; + MPI_Comm comm; + MPI_Status status; + MPI_Request req[4]; static int bufsizes[4] = { 1, 100, 10000, 1000000 }; char *bufs[4]; - int flag, i; + int flag, i; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); source = 0; - dest = size - 1; + dest = size - 1; if (rank == source) { - MPI_Send( MPI_BOTTOM, 0, MPI_CHAR, dest, 1, MPI_COMM_WORLD ); + MPI_Send(MPI_BOTTOM, 0, MPI_CHAR, dest, 1, MPI_COMM_WORLD); } else if (rank == dest) { - /* Create 3 requests to cancel, plus one to use. - Then receive one message and exit */ - for (i=0; i<4; i++) { - bufs[i] = (char *) malloc( bufsizes[i] ); - MPI_Irecv( bufs[i], bufsizes[i], MPI_CHAR, source, - i, MPI_COMM_WORLD, &req[i] ); - } - /* Now, cancel them in a more interesting order, to ensure that the - queue operation work properly */ - MPI_Cancel( &req[2] ); - MPI_Wait( &req[2], &status ); - MTestPrintfMsg( 1, "Completed wait on irecv[2]\n" ); - MPI_Test_cancelled( &status, &flag ); - if (!flag) { - errs ++; - printf( "Failed to cancel a Irecv[2] request\n" ); - fflush(stdout); - } - MPI_Cancel( &req[3] ); - MPI_Wait( &req[3], &status ); - MTestPrintfMsg( 1, "Completed wait on irecv[3]\n" ); - MPI_Test_cancelled( &status, &flag ); - if (!flag) { - errs ++; - printf( "Failed to cancel a Irecv[3] request\n" ); - fflush(stdout); - } - MPI_Cancel( &req[0] ); - MPI_Wait( &req[0], &status ); - MTestPrintfMsg( 1, "Completed wait on irecv[0]\n" ); - MPI_Test_cancelled( &status, &flag ); - if (!flag) { - errs ++; - printf( "Failed to cancel a Irecv[0] request\n" ); - fflush(stdout); - } - MPI_Wait( &req[1], &status ); - MPI_Test_cancelled( &status, &flag ); - if (flag) { - errs ++; - printf( "Incorrectly cancelled Irecv[1]\n" ); fflush(stdout); - } + /* Create 3 requests to cancel, plus one to use. + * Then receive one message and exit */ + for (i = 0; i < 4; i++) { + bufs[i] = (char *) malloc(bufsizes[i]); + MPI_Irecv(bufs[i], bufsizes[i], MPI_CHAR, source, i, MPI_COMM_WORLD, &req[i]); + } + /* Now, cancel them in a more interesting order, to ensure that the + * queue operation work properly */ + MPI_Cancel(&req[2]); + MPI_Wait(&req[2], &status); + MTestPrintfMsg(1, "Completed wait on irecv[2]\n"); + MPI_Test_cancelled(&status, &flag); + if (!flag) { + errs++; + printf("Failed to cancel a Irecv[2] request\n"); + fflush(stdout); + } + MPI_Cancel(&req[3]); + MPI_Wait(&req[3], &status); + MTestPrintfMsg(1, "Completed wait on irecv[3]\n"); + MPI_Test_cancelled(&status, &flag); + if (!flag) { + errs++; + printf("Failed to cancel a Irecv[3] request\n"); + fflush(stdout); + } + MPI_Cancel(&req[0]); + MPI_Wait(&req[0], &status); + MTestPrintfMsg(1, "Completed wait on irecv[0]\n"); + MPI_Test_cancelled(&status, &flag); + if (!flag) { + errs++; + printf("Failed to cancel a Irecv[0] request\n"); + fflush(stdout); + } + MPI_Wait(&req[1], &status); + MPI_Test_cancelled(&status, &flag); + if (flag) { + errs++; + printf("Incorrectly cancelled Irecv[1]\n"); + fflush(stdout); + } + for (i = 0; i < 4; i++) { + free(bufs[i]); + } } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/pt2pt/recv_any.c b/teshsuite/smpi/mpich3-test/pt2pt/recv_any.c new file mode 100644 index 0000000000..c3db3e23c8 --- /dev/null +++ b/teshsuite/smpi/mpich3-test/pt2pt/recv_any.c @@ -0,0 +1,80 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * (C) 2016 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ + +#include +#include +#include + +#define BUFSIZE 4 +#define ITER 10 + +/* This program tests MPI_Recv or MPI_Irecv + MPI_Wait with MPI_ANY_SOURCE by + * checking both the value of receive buffer and status.MPI_SOURCE in every + * iteration.*/ + +#define ERR_REPORT_EXIT(str,...) do { \ + fprintf(stderr, str, ## __VA_ARGS__);fflush(stderr); \ + MPI_Abort(MPI_COMM_WORLD, 1); \ + } while (0); + +int main(int argc, char *argv[]) +{ + int rank = 0, nprocs = 0; + int i = 0, x = 0, dst = 0, src = 0, tag = 0; + MPI_Status stat; +#if TEST_NB + MPI_Request req; +#endif + int sbuf[BUFSIZE], rbuf[BUFSIZE]; + + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &nprocs); + + /* initialize buffers */ + for (i = 0; i < BUFSIZE; i++) { + sbuf[i] = i + 1; + rbuf[i] = 0; + } + + dst = 0; + src = 1; + for (x = 0; x < ITER; x++) { + tag = x; + if (rank == dst) { +#if TEST_NB + MPI_Irecv(rbuf, sizeof(int) * BUFSIZE, MPI_CHAR, MPI_ANY_SOURCE, tag, MPI_COMM_WORLD, + &req); + MPI_Wait(&req, &stat); +#else + MPI_Recv(rbuf, sizeof(int) * BUFSIZE, MPI_CHAR, + MPI_ANY_SOURCE, tag, MPI_COMM_WORLD, &stat); +#endif + if (stat.MPI_SOURCE != src) { + ERR_REPORT_EXIT("[%d] Error: iter %d, stat.MPI_SOURCE=%d, expected %d\n", + rank, x, stat.MPI_SOURCE, src); + } + + for (i = 0; i < BUFSIZE; i++) { + if (rbuf[i] != i + 1) { + ERR_REPORT_EXIT("[%d] Error: iter %d, got rbuf[%d]=%d, expected %d\n", + rank, x, i, rbuf[i], i + 1); + } + } + } + else if (rank == src) { + MPI_Send(sbuf, sizeof(int) * BUFSIZE, MPI_CHAR, dst, tag, MPI_COMM_WORLD); + } + } + + if (rank == 0) { + printf(" No errors\n"); + fflush(stdout); + } + + MPI_Finalize(); + return 0; +} diff --git a/teshsuite/smpi/mpich3-test/pt2pt/rqfreeb.c b/teshsuite/smpi/mpich3-test/pt2pt/rqfreeb.c index 2d752ca645..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,104 +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 ); - exit(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(); diff --git a/teshsuite/smpi/mpich3-test/pt2pt/rqstatus.c b/teshsuite/smpi/mpich3-test/pt2pt/rqstatus.c index 102e9f8acd..304fcff55a 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/rqstatus.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/rqstatus.c @@ -12,103 +12,102 @@ static char MTEST_Descrip[] = "Test Request_get_status"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rank, size, source, dest; int buf[2], flag, count; - MPI_Comm comm; - MPI_Status status, status2; - MPI_Request req; + MPI_Comm comm; + MPI_Status status, status2; + MPI_Request req; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; /* Determine the sender and receiver */ - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); source = 0; - dest = size - 1; + dest = size - 1; /* Handling MPI_REQUEST_NULL in MPI_Request_get_status was only required - starting with MPI-2.2. */ + * starting with MPI-2.2. */ #if MTEST_HAVE_MIN_MPI_VERSION(2,2) - MPI_Request_get_status( MPI_REQUEST_NULL, &flag, &status ); + MPI_Request_get_status(MPI_REQUEST_NULL, &flag, &status); if (!flag) { errs++; - fprintf( stderr, "flag not true for MPI_REQUEST_NULL, flag=%d\n", flag ); + fprintf(stderr, "flag not true for MPI_REQUEST_NULL, flag=%d\n", flag); } if ((status.MPI_SOURCE != MPI_ANY_SOURCE) || - (status.MPI_TAG != MPI_ANY_TAG) || - (status.MPI_ERROR != MPI_SUCCESS)) - { + (status.MPI_TAG != MPI_ANY_TAG) || (status.MPI_ERROR != MPI_SUCCESS)) { errs++; - fprintf( stderr, "non-empty MPI_Status returned for MPI_REQUEST_NULL\n" ); + fprintf(stderr, "non-empty MPI_Status returned for MPI_REQUEST_NULL\n"); } /* also pass MPI_STATUS_IGNORE to make sure the implementation doesn't * blow up when it is passed as the status argument */ - MPI_Request_get_status( MPI_REQUEST_NULL, &flag, MPI_STATUS_IGNORE ); + MPI_Request_get_status(MPI_REQUEST_NULL, &flag, MPI_STATUS_IGNORE); if (!flag) { errs++; - fprintf( stderr, "flag not true for MPI_REQUEST_NULL with MPI_STATUS_IGNORE, flag=%d\n", flag ); + fprintf(stderr, "flag not true for MPI_REQUEST_NULL with MPI_STATUS_IGNORE, flag=%d\n", + flag); } #endif if (rank == source) { - buf[0] = size; - buf[1] = 3; - MPI_Ssend( buf, 2, MPI_INT, dest, 10, comm ); + buf[0] = size; + buf[1] = 3; + MPI_Ssend(buf, 2, MPI_INT, dest, 10, comm); } if (rank == dest) { - MPI_Irecv( buf, 2, MPI_INT, source, 10, comm, &req ); + MPI_Irecv(buf, 2, MPI_INT, source, 10, comm, &req); } - MPI_Barrier( comm ); + MPI_Barrier(comm); /* At this point, we know that the receive has at least started, - because of the Ssend. Check the status on the request */ + * because of the Ssend. Check the status on the request */ if (rank == dest) { - status.MPI_SOURCE = -1; - status.MPI_TAG = -1; - MPI_Request_get_status( req, &flag, &status ); - if (flag) { - if (status.MPI_TAG != 10) { - errs++; - fprintf( stderr, "Tag value %d should be 10\n", status.MPI_TAG ); - } - if (status.MPI_SOURCE != source) { - errs++; - fprintf( stderr, "Source value %d should be %d\n", status.MPI_SOURCE, source ); - } - MPI_Get_count( &status, MPI_INT, &count ); - if (count != 2) { - errs++; - fprintf( stderr, "Count value %d should be 2\n", count ); - } - } - else { - errs++; - fprintf( stderr, "Unexpected flag value from get_status\n" ); - } - /* Now, complete the request */ - MPI_Wait( &req, &status2 ); - /* Check that the status is correct */ - if (status2.MPI_TAG != 10) { - errs++; - fprintf( stderr, "(wait)Tag value %d should be 10\n", status2.MPI_TAG ); - } - if (status2.MPI_SOURCE != source) { - errs++; - fprintf( stderr, "(wait)Source value %d should be %d\n", status2.MPI_SOURCE, source ); - } - MPI_Get_count( &status2, MPI_INT, &count ); - if (count != 2) { - errs++; - fprintf( stderr, "(wait)Count value %d should be 2\n", count ); - } + status.MPI_SOURCE = -1; + status.MPI_TAG = -1; + MPI_Request_get_status(req, &flag, &status); + if (flag) { + if (status.MPI_TAG != 10) { + errs++; + fprintf(stderr, "Tag value %d should be 10\n", status.MPI_TAG); + } + if (status.MPI_SOURCE != source) { + errs++; + fprintf(stderr, "Source value %d should be %d\n", status.MPI_SOURCE, source); + } + MPI_Get_count(&status, MPI_INT, &count); + if (count != 2) { + errs++; + fprintf(stderr, "Count value %d should be 2\n", count); + } + } + else { + errs++; + fprintf(stderr, "Unexpected flag value from get_status\n"); + } + /* Now, complete the request */ + MPI_Wait(&req, &status2); + /* Check that the status is correct */ + if (status2.MPI_TAG != 10) { + errs++; + fprintf(stderr, "(wait)Tag value %d should be 10\n", status2.MPI_TAG); + } + if (status2.MPI_SOURCE != source) { + errs++; + fprintf(stderr, "(wait)Source value %d should be %d\n", status2.MPI_SOURCE, source); + } + MPI_Get_count(&status2, MPI_INT, &count); + if (count != 2) { + errs++; + fprintf(stderr, "(wait)Count value %d should be 2\n", count); + } } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/pt2pt/scancel.c b/teshsuite/smpi/mpich3-test/pt2pt/scancel.c index 7623be60e1..23e1bb464c 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/scancel.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/scancel.c @@ -12,269 +12,244 @@ static char MTEST_Descrip[] = "Test of various send cancel calls"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; - int rank, size, /* source, */ dest; - MPI_Comm comm; - MPI_Status status; - MPI_Request req; + int rank, size, source, dest; + MPI_Comm comm; + MPI_Status status; + MPI_Request req; static int bufsizes[4] = { 1, 100, 10000, 1000000 }; char *buf; #ifdef TEST_IRSEND - int veryPicky = 0; /* Set to 1 to test "quality of implementation" in - a tricky part of cancel */ + int veryPicky = 0; /* Set to 1 to test "quality of implementation" in + * a tricky part of cancel */ #endif - int cs, flag, n; + int cs, flag, n; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); - /* source = 0; */ - dest = size - 1; + source = 0; + dest = size - 1; - MTestPrintfMsg( 1, "Starting scancel test\n" ); - for (cs=0; cs<4; cs++) { - if (rank == 0) { - n = bufsizes[cs]; - buf = (char *)malloc( n ); - if (!buf) { - fprintf( stderr, "Unable to allocate %d bytes\n", n ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - MTestPrintfMsg( 1, "(%d) About to create isend and cancel\n",cs ); - MPI_Isend( buf, n, MPI_CHAR, dest, cs+n+1, comm, &req ); - MPI_Cancel( &req ); - MPI_Wait( &req, &status ); - MTestPrintfMsg( 1, "Completed wait on isend\n" ); - MPI_Test_cancelled( &status, &flag ); - if (!flag) { - errs ++; - printf( "Failed to cancel an Isend request\n" ); - fflush(stdout); - } - else - { - n = 0; - } - /* Send the size, zero for successfully cancelled */ - MPI_Send( &n, 1, MPI_INT, dest, 123, comm ); - /* Send the tag so the message can be received */ - n = cs+n+1; - MPI_Send( &n, 1, MPI_INT, dest, 123, comm ); - free( buf ); - } - else if (rank == dest) - { - int nn, tag; - char *btemp; - MPI_Recv( &nn, 1, MPI_INT, 0, 123, comm, &status ); - MPI_Recv( &tag, 1, MPI_INT, 0, 123, comm, &status ); - if (nn > 0) - { - /* If the message was not cancelled, receive it here */ - btemp = (char*)malloc( nn ); - if (!btemp) - { - fprintf( stderr, "Unable to allocate %d bytes\n", nn ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - MPI_Recv( btemp, nn, MPI_CHAR, 0, tag, comm, &status ); - free(btemp); - } - } - MPI_Barrier( comm ); + MTestPrintfMsg(1, "Starting scancel test\n"); + for (cs = 0; cs < 4; cs++) { + if (rank == 0) { + n = bufsizes[cs]; + buf = (char *) malloc(n); + if (!buf) { + fprintf(stderr, "Unable to allocate %d bytes\n", n); + MPI_Abort(MPI_COMM_WORLD, 1); + } + MTestPrintfMsg(1, "(%d) About to create isend and cancel\n", cs); + MPI_Isend(buf, n, MPI_CHAR, dest, cs + n + 1, comm, &req); + MPI_Cancel(&req); + MPI_Wait(&req, &status); + MTestPrintfMsg(1, "Completed wait on isend\n"); + MPI_Test_cancelled(&status, &flag); + if (!flag) { + errs++; + printf("Failed to cancel an Isend request\n"); + fflush(stdout); + } + else { + n = 0; + } + /* Send the size, zero for successfully cancelled */ + MPI_Send(&n, 1, MPI_INT, dest, 123, comm); + /* Send the tag so the message can be received */ + n = cs + n + 1; + MPI_Send(&n, 1, MPI_INT, dest, 123, comm); + free(buf); + } + else if (rank == dest) { + int nn, tag; + char *btemp; + MPI_Recv(&nn, 1, MPI_INT, 0, 123, comm, &status); + MPI_Recv(&tag, 1, MPI_INT, 0, 123, comm, &status); + if (nn > 0) { + /* If the message was not cancelled, receive it here */ + btemp = (char *) malloc(nn); + if (!btemp) { + fprintf(stderr, "Unable to allocate %d bytes\n", nn); + MPI_Abort(MPI_COMM_WORLD, 1); + } + MPI_Recv(btemp, nn, MPI_CHAR, 0, tag, comm, &status); + free(btemp); + } + } + MPI_Barrier(comm); - if (rank == 0) { - char *bsendbuf; - int bsendbufsize; - int bf, bs; - n = bufsizes[cs]; - buf = (char *)malloc( n ); - if (!buf) { - fprintf( stderr, "Unable to allocate %d bytes\n", n ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - bsendbufsize = n + MPI_BSEND_OVERHEAD; - bsendbuf = (char *)malloc( bsendbufsize ); - if (!bsendbuf) { - fprintf( stderr, "Unable to allocate %d bytes for bsend\n", n ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - MPI_Buffer_attach( bsendbuf, bsendbufsize ); - MTestPrintfMsg( 1, "About to create and cancel ibsend\n" ); - MPI_Ibsend( buf, n, MPI_CHAR, dest, cs+n+2, comm, &req ); - MPI_Cancel( &req ); - MPI_Wait( &req, &status ); - MPI_Test_cancelled( &status, &flag ); - if (!flag) { - errs ++; - printf( "Failed to cancel an Ibsend request\n" ); - fflush(stdout); - } - else - { - n = 0; - } - /* Send the size, zero for successfully cancelled */ - MPI_Send( &n, 1, MPI_INT, dest, 123, comm ); - /* Send the tag so the message can be received */ - n = cs+n+2; - MPI_Send( &n, 1, MPI_INT, dest, 123, comm ); - free( buf ); - MPI_Buffer_detach( &bf, &bs ); - free( bsendbuf ); - } - else if (rank == dest) - { - int nn, tag; - char *btemp; - MPI_Recv( &nn, 1, MPI_INT, 0, 123, comm, &status ); - MPI_Recv( &tag, 1, MPI_INT, 0, 123, comm, &status ); - if (nn > 0) - { - /* If the message was not cancelled, receive it here */ - btemp = (char*)malloc( nn ); - if (!btemp) - { - fprintf( stderr, "Unable to allocate %d bytes\n", nn); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - MPI_Recv( btemp, nn, MPI_CHAR, 0, tag, comm, &status ); - free(btemp); - } - } - MPI_Barrier( comm ); + if (rank == 0) { + char *bsendbuf; + int bsendbufsize; + int bf, bs; + n = bufsizes[cs]; + buf = (char *) malloc(n); + if (!buf) { + fprintf(stderr, "Unable to allocate %d bytes\n", n); + MPI_Abort(MPI_COMM_WORLD, 1); + } + bsendbufsize = n + MPI_BSEND_OVERHEAD; + bsendbuf = (char *) malloc(bsendbufsize); + if (!bsendbuf) { + fprintf(stderr, "Unable to allocate %d bytes for bsend\n", n); + MPI_Abort(MPI_COMM_WORLD, 1); + } + MPI_Buffer_attach(bsendbuf, bsendbufsize); + MTestPrintfMsg(1, "About to create and cancel ibsend\n"); + MPI_Ibsend(buf, n, MPI_CHAR, dest, cs + n + 2, comm, &req); + MPI_Cancel(&req); + MPI_Wait(&req, &status); + MPI_Test_cancelled(&status, &flag); + if (!flag) { + errs++; + printf("Failed to cancel an Ibsend request\n"); + fflush(stdout); + } + else { + n = 0; + } + /* Send the size, zero for successfully cancelled */ + MPI_Send(&n, 1, MPI_INT, dest, 123, comm); + /* Send the tag so the message can be received */ + n = cs + n + 2; + MPI_Send(&n, 1, MPI_INT, dest, 123, comm); + free(buf); + MPI_Buffer_detach(&bf, &bs); + free(bsendbuf); + } + else if (rank == dest) { + int nn, tag; + char *btemp; + MPI_Recv(&nn, 1, MPI_INT, 0, 123, comm, &status); + MPI_Recv(&tag, 1, MPI_INT, 0, 123, comm, &status); + if (nn > 0) { + /* If the message was not cancelled, receive it here */ + btemp = (char *) malloc(nn); + if (!btemp) { + fprintf(stderr, "Unable to allocate %d bytes\n", nn); + MPI_Abort(MPI_COMM_WORLD, 1); + } + MPI_Recv(btemp, nn, MPI_CHAR, 0, tag, comm, &status); + free(btemp); + } + } + MPI_Barrier(comm); - /* Because this test is erroneous, we do not perform it unless - TEST_IRSEND is defined. */ + /* Because this test is erroneous, we do not perform it unless + * TEST_IRSEND is defined. */ #ifdef TEST_IRSEND - /* We avoid ready send to self because an implementation - is free to detect the error in delivering a message to - itself without a pending receive; we could also check - for an error return from the MPI_Irsend */ - if (rank == 0 && dest != rank) { - n = bufsizes[cs]; - buf = (char *)malloc( n ); - if (!buf) { - fprintf( stderr, "Unable to allocate %d bytes\n", n ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - MTestPrintfMsg( 1, "About to create and cancel irsend\n" ); - MPI_Irsend( buf, n, MPI_CHAR, dest, cs+n+3, comm, &req ); - MPI_Cancel( &req ); - MPI_Wait( &req, &status ); - MPI_Test_cancelled( &status, &flag ); - /* This can be pretty ugly. The standard is clear (Section 3.8) - that either a sent message is received or the - sent message is successfully cancelled. Since this message - can never be received, the cancel must complete - successfully. - - However, since there is no matching receive, this - program is erroneous. In this case, we can't really - flag this as an error */ - if (!flag && veryPicky) { - errs ++; - printf( "Failed to cancel an Irsend request\n" ); - fflush(stdout); - } - if (flag) - { - n = 0; - } - /* Send the size, zero for successfully cancelled */ - MPI_Send( &n, 1, MPI_INT, dest, 123, comm ); - /* Send the tag so the message can be received */ - n = cs+n+3; - MPI_Send( &n, 1, MPI_INT, dest, 123, comm ); - free( buf ); - } - else if (rank == dest) - { - int n, tag; - char *btemp; - MPI_Recv( &n, 1, MPI_INT, 0, 123, comm, &status ); - MPI_Recv( &tag, 1, MPI_INT, 0, 123, comm, &status ); - if (n > 0) - { - /* If the message was not cancelled, receive it here */ - btemp = (char*)malloc( n ); - if (!btemp) - { - fprintf( stderr, "Unable to allocate %d bytes\n", n); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - MPI_Recv( btemp, n, MPI_CHAR, 0, tag, comm, &status ); - free(btemp); - } - } - MPI_Barrier( comm ); + /* We avoid ready send to self because an implementation + * is free to detect the error in delivering a message to + * itself without a pending receive; we could also check + * for an error return from the MPI_Irsend */ + if (rank == 0 && dest != rank) { + n = bufsizes[cs]; + buf = (char *) malloc(n); + if (!buf) { + fprintf(stderr, "Unable to allocate %d bytes\n", n); + MPI_Abort(MPI_COMM_WORLD, 1); + } + MTestPrintfMsg(1, "About to create and cancel irsend\n"); + MPI_Irsend(buf, n, MPI_CHAR, dest, cs + n + 3, comm, &req); + MPI_Cancel(&req); + MPI_Wait(&req, &status); + MPI_Test_cancelled(&status, &flag); + /* This can be pretty ugly. The standard is clear (Section 3.8) + * that either a sent message is received or the + * sent message is successfully cancelled. Since this message + * can never be received, the cancel must complete + * successfully. + * + * However, since there is no matching receive, this + * program is erroneous. In this case, we can't really + * flag this as an error */ + if (!flag && veryPicky) { + errs++; + printf("Failed to cancel an Irsend request\n"); + fflush(stdout); + } + if (flag) { + n = 0; + } + /* Send the size, zero for successfully cancelled */ + MPI_Send(&n, 1, MPI_INT, dest, 123, comm); + /* Send the tag so the message can be received */ + n = cs + n + 3; + MPI_Send(&n, 1, MPI_INT, dest, 123, comm); + free(buf); + } + else if (rank == dest) { + int n, tag; + char *btemp; + MPI_Recv(&n, 1, MPI_INT, 0, 123, comm, &status); + MPI_Recv(&tag, 1, MPI_INT, 0, 123, comm, &status); + if (n > 0) { + /* If the message was not cancelled, receive it here */ + btemp = (char *) malloc(n); + if (!btemp) { + fprintf(stderr, "Unable to allocate %d bytes\n", n); + MPI_Abort(MPI_COMM_WORLD, 1); + } + MPI_Recv(btemp, n, MPI_CHAR, 0, tag, comm, &status); + free(btemp); + } + } + MPI_Barrier(comm); #endif - if (rank == 0) { - n = bufsizes[cs]; - buf = (char *)malloc( n ); - if (!buf) { - fprintf( stderr, "Unable to allocate %d bytes\n", n ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - MTestPrintfMsg( 1, "About to create and cancel issend\n" ); - MPI_Issend( buf, n, MPI_CHAR, dest, cs+n+4, comm, &req ); - MPI_Cancel( &req ); - MPI_Wait( &req, &status ); - MPI_Test_cancelled( &status, &flag ); - if (!flag) { - errs ++; - printf( "Failed to cancel an Issend request\n" ); - fflush(stdout); - } - else - { - n = 0; - } - /* Send the size, zero for successfully cancelled */ - MPI_Send( &n, 1, MPI_INT, dest, 123, comm ); - /* Send the tag so the message can be received */ - n = cs+n+4; - MPI_Send( &n, 1, MPI_INT, dest, 123, comm ); - free( buf ); - } - else if (rank == dest) - { - int nn, tag; - char *btemp; - MPI_Recv( &nn, 1, MPI_INT, 0, 123, comm, &status ); - MPI_Recv( &tag, 1, MPI_INT, 0, 123, comm, &status ); - if (nn > 0) - { - /* If the message was not cancelled, receive it here */ - btemp = (char*)malloc( nn ); - if (!btemp) - { - fprintf( stderr, "Unable to allocate %d bytes\n", nn); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - MPI_Recv( btemp, nn, MPI_CHAR, 0, tag, comm, &status ); - free(btemp); - } - } - MPI_Barrier( comm ); + if (rank == 0) { + n = bufsizes[cs]; + buf = (char *) malloc(n); + if (!buf) { + fprintf(stderr, "Unable to allocate %d bytes\n", n); + MPI_Abort(MPI_COMM_WORLD, 1); + } + MTestPrintfMsg(1, "About to create and cancel issend\n"); + MPI_Issend(buf, n, MPI_CHAR, dest, cs + n + 4, comm, &req); + MPI_Cancel(&req); + MPI_Wait(&req, &status); + MPI_Test_cancelled(&status, &flag); + if (!flag) { + errs++; + printf("Failed to cancel an Issend request\n"); + fflush(stdout); + } + else { + n = 0; + } + /* Send the size, zero for successfully cancelled */ + MPI_Send(&n, 1, MPI_INT, dest, 123, comm); + /* Send the tag so the message can be received */ + n = cs + n + 4; + MPI_Send(&n, 1, MPI_INT, dest, 123, comm); + free(buf); + } + else if (rank == dest) { + int nn, tag; + char *btemp; + MPI_Recv(&nn, 1, MPI_INT, 0, 123, comm, &status); + MPI_Recv(&tag, 1, MPI_INT, 0, 123, comm, &status); + if (nn > 0) { + /* If the message was not cancelled, receive it here */ + btemp = (char *) malloc(nn); + if (!btemp) { + fprintf(stderr, "Unable to allocate %d bytes\n", nn); + MPI_Abort(MPI_COMM_WORLD, 1); + } + MPI_Recv(btemp, nn, MPI_CHAR, 0, tag, comm, &status); + free(btemp); + } + } + MPI_Barrier(comm); } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/pt2pt/scancel2.c b/teshsuite/smpi/mpich3-test/pt2pt/scancel2.c index 8da02570da..7492ecfcaf 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/scancel2.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/scancel2.c @@ -12,73 +12,70 @@ static char MTEST_Descrip[] = "Test of send cancel (failure) calls"; */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rank, size, source, dest; - MPI_Comm comm; - MPI_Status status; - MPI_Request req; + MPI_Comm comm; + MPI_Status status; + MPI_Request req; static int bufsizes[4] = { 1, 100, 10000, 1000000 }; char *buf; - int cs, flag, n; + int cs, flag, n; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); source = 0; - dest = size - 1; + dest = size - 1; - MTestPrintfMsg( 1, "Starting scancel test\n" ); + MTestPrintfMsg(1, "Starting scancel test\n"); - for (cs=0; cs<4; cs++) { - n = bufsizes[cs]; - buf = (char *)malloc( n ); - if (!buf) { - fprintf( stderr, "Unable to allocate %d bytes\n", n ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } + for (cs = 0; cs < 4; cs++) { + n = bufsizes[cs]; + buf = (char *) malloc(n); + MTEST_VG_MEM_INIT(buf, n); + if (!buf) { + fprintf(stderr, "Unable to allocate %d bytes\n", n); + MPI_Abort(MPI_COMM_WORLD, 1); + } - if (rank == source) { - MTestPrintfMsg( 1, "(%d) About to create isend and cancel\n",cs ); - MPI_Isend( buf, n, MPI_CHAR, dest, cs+n+1, comm, &req ); - MPI_Barrier( comm ); - MPI_Cancel( &req ); - MPI_Wait( &req, &status ); - MTestPrintfMsg( 1, "Completed wait on isend\n" ); - MPI_Test_cancelled( &status, &flag ); - if (flag) { - errs ++; - printf( "Cancelled a matched Isend request (msg size = %d)!\n", - n ); - fflush(stdout); - } - else - { - n = 0; - } - /* Send the size, zero for not cancelled (success) */ - MPI_Send( &n, 1, MPI_INT, dest, 123, comm ); - } - else if (rank == dest) - { - MPI_Recv( buf, n, MPI_CHAR, source, cs+n+1, comm, &status ); - MPI_Barrier( comm ); - MPI_Recv( &n, 1, MPI_INT, source, 123, comm, &status ); - } - else { - MPI_Barrier( comm ); - } + if (rank == source) { + MTestPrintfMsg(1, "(%d) About to create isend and cancel\n", cs); + MPI_Isend(buf, n, MPI_CHAR, dest, cs + n + 1, comm, &req); + MPI_Barrier(comm); + MPI_Cancel(&req); + MPI_Wait(&req, &status); + MTestPrintfMsg(1, "Completed wait on isend\n"); + MPI_Test_cancelled(&status, &flag); + if (flag) { + errs++; + printf("Cancelled a matched Isend request (msg size = %d)!\n", n); + fflush(stdout); + } + else { + n = 0; + } + /* Send the size, zero for not cancelled (success) */ + MPI_Send(&n, 1, MPI_INT, dest, 123, comm); + } + else if (rank == dest) { + MPI_Recv(buf, n, MPI_CHAR, source, cs + n + 1, comm, &status); + MPI_Barrier(comm); + MPI_Recv(&n, 1, MPI_INT, source, 123, comm, &status); + } + else { + MPI_Barrier(comm); + } - MPI_Barrier( comm ); - free( buf ); + MPI_Barrier(comm); + free(buf); } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; } diff --git a/teshsuite/smpi/mpich3-test/pt2pt/scancel_unmatch.c b/teshsuite/smpi/mpich3-test/pt2pt/scancel_unmatch.c new file mode 100644 index 0000000000..350e3874c3 --- /dev/null +++ b/teshsuite/smpi/mpich3-test/pt2pt/scancel_unmatch.c @@ -0,0 +1,61 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * (C) 2015 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ + +#include "mpi.h" +#include +#include +#include "mpitest.h" + +/* +static char MTEST_Descrip[] = "Test message reception ordering issues +after cancelling a send"; +*/ + +int main(int argc, char *argv[]) +{ + + int a, b, flag = 0, errs = 0; + MPI_Request requests[2]; + MPI_Status statuses[2]; + + MPI_Init(&argc, &argv); + + int rank, size; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); + + int source = 0; + int dest = size - 1; + + if (rank == 0) { + a = 10; + b = 20; + MPI_Isend(&a, 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &requests[0]); + MPI_Isend(&b, 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &requests[1]); + MPI_Cancel(&requests[1]); + MPI_Wait(&requests[1], &statuses[1]); + MPI_Test_cancelled(&statuses[1], &flag); + + if (!flag) { + printf("Failed to cancel send"); + errs++; + } + MPI_Barrier(MPI_COMM_WORLD); + MPI_Wait(&requests[0], MPI_STATUS_IGNORE); + } + else if (rank == 1) { + MPI_Barrier(MPI_COMM_WORLD); + MPI_Recv(&a, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + if (a == 20) { + printf("Failed! got the data from the wrong send!\n"); + errs++; + } + } + + MTest_Finalize(errs); + MPI_Finalize(); + return 0; +} diff --git a/teshsuite/smpi/mpich3-test/pt2pt/sendall.c b/teshsuite/smpi/mpich3-test/pt2pt/sendall.c index 2f87e47eb0..5e679161d1 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/sendall.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/sendall.c @@ -10,9 +10,9 @@ #include "mpi.h" #include "mpitest.h" -/* +/* * This test makes sure that each process can send to each other process. - * If there are bugs in the handling of request completions or in + * If there are bugs in the handling of request completions or in * queue operations, then this test may fail on them (it did with * early EagerShort handling). */ @@ -23,61 +23,59 @@ static int buffer[MAXPES][MYBUFSIZE]; #define NUM_RUNS 10 -int main ( int argc, char *argv[] ) +int main(int argc, char *argv[]) { - int i; - int count, size; - int self, npes; - double secs; - MPI_Request request[MAXPES]; - MPI_Status status; - - MTest_Init (&argc, &argv); - MPI_Comm_rank (MPI_COMM_WORLD, &self); - MPI_Comm_size (MPI_COMM_WORLD, &npes); - - if (npes > MAXPES) { - fprintf( stderr, "This program requires a comm_world no larger than %d", - MAXPES ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); - } - - for (size = 1; size <= MYBUFSIZE ; size += size) { - secs = -MPI_Wtime (); - for (count = 0; count < NUM_RUNS; count++) { - MPI_Barrier (MPI_COMM_WORLD); - - for (i = 0; i < npes; i++) { - if (i != self) - MPI_Irecv (buffer[i], size, MPI_INT, i, - MPI_ANY_TAG, MPI_COMM_WORLD, &request[i]); - } - - for (i = 0; i < npes; i++) { - if (i != self) - MPI_Send (buffer[self], size, MPI_INT, i, 0, MPI_COMM_WORLD); - } - - for (i = 0; i < npes; i++) { - if (i != self) - MPI_Wait (&request[i], &status); - } - - } - MPI_Barrier (MPI_COMM_WORLD); - secs += MPI_Wtime (); - - if (self == 0) { - secs = secs / (double) NUM_RUNS; - MTestPrintfMsg( 1, "length = %d ints\n", size ); - } + int i; + int count, size; + int self, npes; + double secs; + MPI_Request request[MAXPES]; + MPI_Status status; + + MTest_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &self); + MPI_Comm_size(MPI_COMM_WORLD, &npes); + + if (npes > MAXPES) { + fprintf(stderr, "This program requires a comm_world no larger than %d", MAXPES); + MPI_Abort(MPI_COMM_WORLD, 1); + } + + for (size = 1; size <= MYBUFSIZE; size += size) { + secs = -MPI_Wtime(); + for (count = 0; count < NUM_RUNS; count++) { + MPI_Barrier(MPI_COMM_WORLD); + + for (i = 0; i < npes; i++) { + if (i != self) + MPI_Irecv(buffer[i], size, MPI_INT, i, + MPI_ANY_TAG, MPI_COMM_WORLD, &request[i]); + } + + for (i = 0; i < npes; i++) { + if (i != self) + MPI_Send(buffer[self], size, MPI_INT, i, 0, MPI_COMM_WORLD); + } + + for (i = 0; i < npes; i++) { + if (i != self) + MPI_Wait(&request[i], &status); + } + + } + MPI_Barrier(MPI_COMM_WORLD); + secs += MPI_Wtime(); + + if (self == 0) { + secs = secs / (double) NUM_RUNS; + MTestPrintfMsg(1, "length = %d ints\n", size); + } } - /* Simple completion is all that we normally ask of this program */ + /* Simple completion is all that we normally ask of this program */ - MTest_Finalize( 0 ); + MTest_Finalize(0); - MPI_Finalize(); - return 0; + MPI_Finalize(); + return 0; } diff --git a/teshsuite/smpi/mpich3-test/pt2pt/sendflood.c b/teshsuite/smpi/mpich3-test/pt2pt/sendflood.c index e2fed07b26..d03a868847 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/sendflood.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/sendflood.c @@ -10,8 +10,8 @@ /* * Run this test with 8 processes. This test was submitted by xxx - * as a result of problems seen with the ch3:shm device on a Solaris - * system. The symptom is that the test hangs; this is due to losing + * as a result of problems seen with the ch3:shm device on a Solaris + * system. The symptom is that the test hangs; this is due to losing * a message, probably due to a race condition in a message-queue update. * As a test for race conditions, it may need to be run multiple times * to expose a problem if a problem does exist. @@ -25,132 +25,128 @@ static int verbose = 0; static int loopProgress = 0; -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { - int nProc, rank ; - int i, j, status ; - FILE *pf=0 ; + int nProc, rank; + int i, j, status; + FILE *pf = 0; - MPI_Init( &argc, &argv ) ; - MPI_Comm_size( MPI_COMM_WORLD, &nProc ) ; - MPI_Comm_rank( MPI_COMM_WORLD, &rank ) ; + MPI_Init(&argc, &argv); + MPI_Comm_size(MPI_COMM_WORLD, &nProc); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); - for (i=1; i 1\n"); - errs++; - goto fn_exit; + if (verbose) + fprintf(stderr, "comm size must be > 1\n"); + errs++; + goto fn_exit; } buf = malloc(64 * 129); if (buf == NULL) { - if (verbose) fprintf(stderr, "error allocating buffer\n"); - errs++; - goto fn_exit; + if (verbose) + fprintf(stderr, "error allocating buffer\n"); + errs++; + goto fn_exit; } for (i = 8; i < 64; i += 4) { - MPI_Type_vector(i, 128, 129, MPI_CHAR, &newtype); - - MPI_Type_commit(&newtype); - memset(buf, 0, 64*129); - - if (rank == 0) { - /* init buffer */ - for (j=0; j < i; j++) { - int k; - for (k=0; k < 129; k++) { - buf[129*j + k] = (char) j; - } - } - - /* send */ - MPI_Send(buf, 1, newtype, 1, i, MPI_COMM_WORLD); - } - else if (rank == 1) { - /* recv */ - MPI_Recv(buf, 1, newtype, 0, i, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - - /* check buffer */ - for (j=0; j < i; j++) { - int k; - for (k=0; k < 129; k++) { - if (k < 128 && buf[129*j + k] != (char) j) { - if (verbose) fprintf(stderr, - "(i=%d, pos=%d) should be %d but is %d\n", - i, 129*j + k, j, (int) buf[129*j + k]); - errs++; - } - else if (k == 128 && buf[129*j + k] != (char) 0) { - if (verbose) fprintf(stderr, - "(i=%d, pos=%d) should be %d but is %d\n", - i, 129*j + k, 0, (int) buf[129*j + k]); - errs++; - } - } - } - } - - MPI_Type_free(&newtype); + MPI_Type_vector(i, 128, 129, MPI_CHAR, &newtype); + + MPI_Type_commit(&newtype); + memset(buf, 0, 64 * 129); + + if (rank == 0) { + /* init buffer */ + for (j = 0; j < i; j++) { + int k; + for (k = 0; k < 129; k++) { + buf[129 * j + k] = (char) j; + } + } + + /* send */ + MPI_Send(buf, 1, newtype, 1, i, MPI_COMM_WORLD); + } + else if (rank == 1) { + /* recv */ + MPI_Recv(buf, 1, newtype, 0, i, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + + /* check buffer */ + for (j = 0; j < i; j++) { + int k; + for (k = 0; k < 129; k++) { + if (k < 128 && buf[129 * j + k] != (char) j) { + if (verbose) + fprintf(stderr, + "(i=%d, pos=%d) should be %d but is %d\n", + i, 129 * j + k, j, (int) buf[129 * j + k]); + errs++; + } + else if (k == 128 && buf[129 * j + k] != (char) 0) { + if (verbose) + fprintf(stderr, + "(i=%d, pos=%d) should be %d but is %d\n", + i, 129 * j + k, 0, (int) buf[129 * j + k]); + errs++; + } + } + } + } + + MPI_Type_free(&newtype); } if (rank == 0) { - int recv_errs = 0; - - MPI_Recv(&recv_errs, 1, MPI_INT, 1, 0, MPI_COMM_WORLD, - MPI_STATUS_IGNORE); - if (recv_errs) { - if (verbose) fprintf(stderr, "%d errors reported from receiver\n", - recv_errs); - errs += recv_errs; - } + int recv_errs = 0; + + MPI_Recv(&recv_errs, 1, MPI_INT, 1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + if (recv_errs) { + if (verbose) + fprintf(stderr, "%d errors reported from receiver\n", recv_errs); + errs += recv_errs; + } } else if (rank == 1) { - MPI_Send(&errs, 1, MPI_INT, 0, 0, MPI_COMM_WORLD); + MPI_Send(&errs, 1, MPI_INT, 0, 0, MPI_COMM_WORLD); } - - fn_exit: + + fn_exit: free(buf); /* print message and exit */ if (errs) { - if (rank == 0) fprintf(stderr, "Found %d errors\n", errs); + if (rank == 0) + fprintf(stderr, "Found %d errors\n", errs); } else { - if (rank == 0) printf(" No Errors\n"); + if (rank == 0) + printf(" No Errors\n"); } MPI_Finalize(); return 0; @@ -119,18 +124,18 @@ int main( int argc, char *argv[] ) static int parse_args(int argc, char **argv) { /* - int ret; - - while ((ret = getopt(argc, argv, "v")) >= 0) - { - switch (ret) { - case 'v': - verbose = 1; - break; - } - } - */ + * int ret; + * + * while ((ret = getopt(argc, argv, "v")) >= 0) + * { + * switch (ret) { + * case 'v': + * verbose = 1; + * break; + * } + * } + */ if (argc > 1 && strcmp(argv[1], "-v") == 0) - verbose = 1; + verbose = 1; return 0; } diff --git a/teshsuite/smpi/mpich3-test/pt2pt/sendrecv3.c b/teshsuite/smpi/mpich3-test/pt2pt/sendrecv3.c index 4da5c86305..28deb55ab1 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/sendrecv3.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/sendrecv3.c @@ -14,94 +14,87 @@ static char MTEST_Descrip[] = "Head to head send-recv to test backoff in device */ #define MAX_NMSGS 100 -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int rank, size, source, dest, partner; - int i, testnum; + int i, testnum; double tsend; static int msgsizes[] = { 100, 1000, 10000, 100000, -1 }; - static int nmsgs[] = { 100, 10, 10, 4 }; - MPI_Comm comm; + static int nmsgs[] = { 100, 10, 10, 4 }; + MPI_Comm comm; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; - MPI_Comm_rank( comm, &rank ); - MPI_Comm_size( comm, &size ); + MPI_Comm_rank(comm, &rank); + MPI_Comm_size(comm, &size); source = 0; - dest = 1; + dest = 1; if (size < 2) { - printf( "This test requires at least 2 processes\n" ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); + printf("This test requires at least 2 processes\n"); + MPI_Abort(MPI_COMM_WORLD, 1); } - for (testnum=0; msgsizes[testnum] > 0; testnum++) { - if (rank == source || rank == dest) { - int nmsg = nmsgs[testnum]; - int msgSize = msgsizes[testnum]; - MPI_Request r[MAX_NMSGS]; - int *buf[MAX_NMSGS]; + for (testnum = 0; msgsizes[testnum] > 0; testnum++) { + if (rank == source || rank == dest) { + int nmsg = nmsgs[testnum]; + int msgSize = msgsizes[testnum]; + MPI_Request r[MAX_NMSGS]; + int *buf[MAX_NMSGS]; - for (i=0; i 0.5) { - printf( "Isends for %d messages of size %d took too long (%f seconds)\n", nmsg, msgSize, tsend ); - errs++; - } - MTestPrintfMsg( 1, "%d Isends for size = %d took %f seconds\n", - nmsg, msgSize, tsend ); + if (tsend > 0.5) { + printf("Isends for %d messages of size %d took too long (%f seconds)\n", nmsg, + msgSize, tsend); + errs++; + } + MTestPrintfMsg(1, "%d Isends for size = %d took %f seconds\n", nmsg, msgSize, tsend); - for (i=0; i= 0) - { - switch (ret) { - case 'v': - verbose = 1; - break; - } - } - */ + * int ret; + * + * while ((ret = getopt(argc, argv, "v")) >= 0) + * { + * switch (ret) { + * case 'v': + * verbose = 1; + * break; + * } + * } + */ if (argc > 1 && strcmp(argv[1], "-v") == 0) - verbose = 1; + verbose = 1; return 0; } diff --git a/teshsuite/smpi/mpich3-test/pt2pt/waittestnull.c b/teshsuite/smpi/mpich3-test/pt2pt/waittestnull.c index d23c91d7d3..6de71e3856 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/waittestnull.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/waittestnull.c @@ -7,8 +7,8 @@ #include "mpi.h" #include "mpitest.h" -/* - * This program checks that the various MPI_Test and MPI_Wait routines +/* + * This program checks that the various MPI_Test and MPI_Wait routines * allow both null requests and in the multiple completion cases, empty * lists of requests. */ @@ -17,65 +17,65 @@ int main(int argc, char **argv) { int errs = 0; MPI_Status status, *status_array = 0; - int count = 0, flag, idx, rc, errlen, *indices=0, outcnt; + int count = 0, flag, idx, rc, errlen, *indices = 0, outcnt; MPI_Request *reqs = 0; char errmsg[MPI_MAX_ERROR_STRING]; MTest_Init(&argc, &argv); - MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN ); + MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN); - rc = MPI_Testall( count, reqs, &flag, status_array ); + rc = MPI_Testall(count, reqs, &flag, status_array); if (rc != MPI_SUCCESS) { - MPI_Error_string( rc, errmsg, &errlen ); - printf( "MPI_Testall returned failure: %s\n", errmsg ); - errs ++; + MPI_Error_string(rc, errmsg, &errlen); + printf("MPI_Testall returned failure: %s\n", errmsg); + errs++; } else if (!flag) { - printf( "MPI_Testall( 0, ... ) did not return a true flag\n") ; - errs++; + printf("MPI_Testall(0, ...) did not return a true flag\n"); + errs++; } - rc = MPI_Waitall( count, reqs, status_array ); + rc = MPI_Waitall(count, reqs, status_array); if (rc != MPI_SUCCESS) { - MPI_Error_string( rc, errmsg, &errlen ); - printf( "MPI_Waitall returned failure: %s\n", errmsg ); - errs ++; + MPI_Error_string(rc, errmsg, &errlen); + printf("MPI_Waitall returned failure: %s\n", errmsg); + errs++; } - rc = MPI_Testany( count, reqs, &idx, &flag, &status ); + rc = MPI_Testany(count, reqs, &idx, &flag, &status); if (rc != MPI_SUCCESS) { - MPI_Error_string( rc, errmsg, &errlen ); - printf( "MPI_Testany returned failure: %s\n", errmsg ); - errs ++; + MPI_Error_string(rc, errmsg, &errlen); + printf("MPI_Testany returned failure: %s\n", errmsg); + errs++; } else if (!flag) { - printf( "MPI_Testany( 0, ... ) did not return a true flag\n") ; - errs++; + printf("MPI_Testany(0, ...) did not return a true flag\n"); + errs++; } - rc = MPI_Waitany( count, reqs, &idx, &status ); + rc = MPI_Waitany(count, reqs, &idx, &status); if (rc != MPI_SUCCESS) { - MPI_Error_string( rc, errmsg, &errlen ); - printf( "MPI_Waitany returned failure: %s\n", errmsg ); - errs ++; + MPI_Error_string(rc, errmsg, &errlen); + printf("MPI_Waitany returned failure: %s\n", errmsg); + errs++; } - rc = MPI_Testsome( count, reqs, &outcnt, indices, status_array ); + rc = MPI_Testsome(count, reqs, &outcnt, indices, status_array); if (rc != MPI_SUCCESS) { - MPI_Error_string( rc, errmsg, &errlen ); - printf( "MPI_Testsome returned failure: %s\n", errmsg ); - errs ++; + MPI_Error_string(rc, errmsg, &errlen); + printf("MPI_Testsome returned failure: %s\n", errmsg); + errs++; } - rc = MPI_Waitsome( count, reqs, &outcnt, indices, status_array ); + rc = MPI_Waitsome(count, reqs, &outcnt, indices, status_array); if (rc != MPI_SUCCESS) { - MPI_Error_string( rc, errmsg, &errlen ); - printf( "MPI_Waitsome returned failure: %s\n", errmsg ); - errs ++; + MPI_Error_string(rc, errmsg, &errlen); + printf("MPI_Waitsome returned failure: %s\n", errmsg); + errs++; } - - MTest_Finalize( errs ); + + MTest_Finalize(errs); MPI_Finalize(); return 0; } -- 2.20.1