X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/db17323a11a3089f492c2cae1be7913673689d5c..c81c99a491282f76757c2673961e3cdee6853539:/teshsuite/smpi/mpich3-test/pt2pt/bsendpending.c diff --git a/teshsuite/smpi/mpich3-test/pt2pt/bsendpending.c b/teshsuite/smpi/mpich3-test/pt2pt/bsendpending.c new file mode 100644 index 0000000000..cc7cc5acd1 --- /dev/null +++ b/teshsuite/smpi/mpich3-test/pt2pt/bsendpending.c @@ -0,0 +1,142 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * + * (C) 2003 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ +#include "mpi.h" +#include +#include +#include "mpitest.h" + +/* +static char MTEST_Descrip[] = "Test the handling of BSend operations when a detach occurs before the bsend data has been sent."; +*/ + +int main( int argc, char *argv[] ) +{ + int errs = 0; + int rank, size, source, dest; + unsigned char *buf, *bufp; + int minsize = 2; + int i, msgsize, bufsize, outsize; + unsigned char *msg1, *msg2, *msg3; + MPI_Comm comm; + MPI_Status status1, status2, status3; + + 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 */ + msgsize = 128 * 1024; + msg1 = (unsigned char *)malloc( 3 * msgsize ); + msg2 = msg1 + msgsize; + msg3 = msg2 + msgsize; + 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; + + /* Here is the test: The sender */ + if (rank == source) { + /* Get a bsend buffer. Make it large enough that the Bsend + internals will (probably) not use a eager send for the data. + Have three such messages */ + bufsize = 3 * (MPI_BSEND_OVERHEAD + msgsize); + buf = (unsigned char *)malloc( bufsize ); + if (!buf) { + fprintf( stderr, "Unable to allocate a buffer of %d bytes\n", + bufsize ); + MPI_Abort( MPI_COMM_WORLD, 1 ); + } + + MPI_Buffer_attach( buf, bufsize ); + + /* Initialize the buffers */ + for (i=0; i