- 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 );
- }
- 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. */
+ 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);