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)
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)
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<MAX_MSGS; i++) {
- for (j=0; j<MAX_MSGS; j++) {
- buf[i][j] = i*MAX_MSGS + j;
- }
- }
- MPI_Barrier( MPI_COMM_WORLD );
- for (i=0; i<MAX_MSGS; i++) {
- MPI_Send( buf[i], MAX_MSGS-i, MPI_INT, worker, 3, comm );
- }
+ /* Initialize the send buffer */
+ for (i = 0; i < MAX_MSGS; i++) {
+ for (j = 0; j < MAX_MSGS; j++) {
+ buf[i][j] = i * MAX_MSGS + j;
+ }
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+ for (i = 0; i < MAX_MSGS; i++) {
+ MPI_Send(buf[i], MAX_MSGS - i, MPI_INT, worker, 3, comm);
+ }
}
else if (wrank == worker) {
- /* Initialize the recv buffer */
- for (i=0; i<MAX_MSGS; i++) {
- for (j=0; j<MAX_MSGS; j++) {
- buf[i][j] = -1;
- }
- }
- for (i=0; i<MAX_MSGS; i++) {
- MPI_Irecv( buf[i], MAX_MSGS-i, MPI_INT, MPI_ANY_SOURCE,
- MPI_ANY_TAG, comm, &r[i] );
- }
- MPI_Barrier( MPI_COMM_WORLD );
- for (i=0; i<MAX_MSGS; i++) {
- MPI_Waitany( MAX_MSGS, r, &idx, &status );
- /* Message idx should have length MAX_MSGS-idx */
- MPI_Get_count( &status, MPI_INT, &count );
- if (count != MAX_MSGS-idx) {
- errs++;
- }
- else {
- /* Check for the correct answers */
- for (j=0; j < MAX_MSGS-idx; j++) {
- if (buf[idx][j] != idx * MAX_MSGS + j) {
- errs ++;
- printf( "Message %d [%d] is %d, should be %d\n",
- idx, j, buf[idx][j], idx * MAX_MSGS + j );
- }
- }
- }
- }
+ /* Initialize the recv buffer */
+ for (i = 0; i < MAX_MSGS; i++) {
+ for (j = 0; j < MAX_MSGS; j++) {
+ buf[i][j] = -1;
+ }
+ }
+ for (i = 0; i < MAX_MSGS; i++) {
+ MPI_Irecv(buf[i], MAX_MSGS - i, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, comm, &r[i]);
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+ for (i = 0; i < MAX_MSGS; i++) {
+ MPI_Waitany(MAX_MSGS, r, &idx, &status);
+ /* Message idx should have length MAX_MSGS-idx */
+ MPI_Get_count(&status, MPI_INT, &count);
+ if (count != MAX_MSGS - idx) {
+ errs++;
+ }
+ else {
+ /* Check for the correct answers */
+ for (j = 0; j < MAX_MSGS - idx; j++) {
+ if (buf[idx][j] != idx * MAX_MSGS + j) {
+ errs++;
+ printf("Message %d [%d] is %d, should be %d\n",
+ idx, j, buf[idx][j], idx * MAX_MSGS + j);
+ }
+ }
+ }
+ }
}
else {
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
}
-
- MTest_Finalize( errs );
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
MPI_Get_elements_x(&stat, MPI_BYTE, &bcount2);
MPI_Test_cancelled(&stat, &cancelled2);
if (bcount != bcount2) {
- fprintf(stderr, "Count Error: expected %lx, got %lx\n", bcount, bcount2);
+ fprintf(stderr, "Count Error: expected %llx, got %llx\n",
+ (long long int) bcount, (long long int) bcount2);
nerrs++;
}
if (cancelled != cancelled2) {
static char MTEST_Descrip[] = "Use of MPI_BOTTOM in communication";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size, source, dest, len, ii;
- MPI_Comm comm;
- MPI_Status status;
- MPI_Datatype newtype, oldtype;
- MPI_Aint disp;
+ MPI_Comm comm;
+ MPI_Status status;
+ MPI_Datatype newtype, oldtype;
+ MPI_Aint disp;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Get_address( &ii, &disp );
+ MPI_Get_address(&ii, &disp);
- len = 1;
+ len = 1;
oldtype = MPI_INT;
- MPI_Type_create_struct( 1, &len, &disp, &oldtype, &newtype );
- MPI_Type_commit( &newtype );
+ MPI_Type_create_struct(1, &len, &disp, &oldtype, &newtype);
+ MPI_Type_commit(&newtype);
comm = MPI_COMM_WORLD;
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
if (size < 2) {
- errs++;
- fprintf( stderr, "This test requires at least two processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- exit(1);
+ errs++;
+ fprintf(stderr, "This test requires at least two processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
source = 0;
dest = 1;
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
if (rank == source) {
- ii = 2;
- err = MPI_Send( MPI_BOTTOM, 1, newtype, dest, 0, comm );
- if (err) {
- errs++;
- MTestPrintError( err );
- printf( "MPI_Send did not return MPI_SUCCESS\n" );
- }
+ ii = 2;
+ err = MPI_Send(MPI_BOTTOM, 1, newtype, dest, 0, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ printf("MPI_Send did not return MPI_SUCCESS\n");
+ }
}
else if (rank == dest) {
- ii = -1;
- err = MPI_Recv( MPI_BOTTOM, 1, newtype, source, 0, comm, &status );
- if (err) {
- MTestPrintError( err );
- errs++;
- printf( "MPI_Recv did not return MPI_SUCCESS\n" );
- }
- if (ii != 2) {
- errs++;
- printf( "Received %d but expected %d\n", ii, 2 );
- }
+ ii = -1;
+ err = MPI_Recv(MPI_BOTTOM, 1, newtype, source, 0, comm, &status);
+ if (err) {
+ MTestPrintError(err);
+ errs++;
+ printf("MPI_Recv did not return MPI_SUCCESS\n");
+ }
+ if (ii != 2) {
+ errs++;
+ printf("Received %d but expected %d\n", ii, 2);
+ }
}
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_ARE_FATAL );
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_ARE_FATAL);
- MPI_Type_free( &newtype );
+ MPI_Type_free(&newtype);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
#include <string.h>
#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;
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;
}
#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<size; i++) {
- for (j=0; j<10; j++) {
- int k;
- status.MPI_TAG = -10;
- status.MPI_SOURCE = -20;
- MPI_Recv( b, 10, MPI_INT, i, 27+j, MPI_COMM_WORLD, &status );
-
- if (status.MPI_TAG != 27+j) {
- errs ++;
- printf( "Wrong tag = %d\n", status.MPI_TAG );
- }
- if (status.MPI_SOURCE != i) {
- errs++;
- printf( "Wrong source = %d\n", status.MPI_SOURCE );
- }
- for (k=0; k<10; k++) {
- if (b[k] != (i + 10 * j) * size + k) {
- errs++;
- printf( "received b[%d] = %d from %d tag %d\n",
- k, b[k], i, 27+j );
- }
- }
- }
- }
+ for (i = 0; i < size; i++) {
+ for (j = 0; j < 10; j++) {
+ int k;
+ status.MPI_TAG = -10;
+ status.MPI_SOURCE = -20;
+ MPI_Recv(b, 10, MPI_INT, i, 27 + j, MPI_COMM_WORLD, &status);
+
+ if (status.MPI_TAG != 27 + j) {
+ errs++;
+ printf("Wrong tag = %d\n", status.MPI_TAG);
+ }
+ if (status.MPI_SOURCE != i) {
+ errs++;
+ printf("Wrong source = %d\n", status.MPI_SOURCE);
+ }
+ for (k = 0; k < 10; k++) {
+ if (b[k] != (i + 10 * j) * size + k) {
+ errs++;
+ printf("received b[%d] = %d from %d tag %d\n", k, b[k], i, 27 + j);
+ }
+ }
+ }
+ }
}
- MPI_Buffer_detach( &bptr, &bl );
-
- MTest_Finalize( errs );
+ MPI_Buffer_detach(&bptr, &bl);
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
#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 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 );
+ 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++) {
- MPI_Bsend_init( a, 10, MPI_INT, 0, 27+j, MPI_COMM_WORLD, &request );
- for (i=0; i<10; i++) {
- a[i] = (rank + 10 * j) * size + i;
- }
- MPI_Start( &request );
- MPI_Wait( &request, &status );
- MPI_Request_free( &request );
+ for (j = 0; j < 10; j++) {
+ MPI_Bsend_init(a, 10, MPI_INT, 0, 27 + j, MPI_COMM_WORLD, &request);
+ for (i = 0; i < 10; i++) {
+ a[i] = (rank + 10 * j) * size + i;
+ }
+ MPI_Start(&request);
+ MPI_Wait(&request, &status);
+ MPI_Request_free(&request);
}
if (rank == 0) {
- for (i=0; i<size; i++) {
- for (j=0; j<10; j++) {
- int k;
- status.MPI_TAG = -10;
- status.MPI_SOURCE = -20;
- MPI_Recv( b, 10, MPI_INT, i, 27+j, MPI_COMM_WORLD, &status );
-
- if (status.MPI_TAG != 27+j) {
- errs++;
- printf( "Wrong tag = %d\n", status.MPI_TAG );
- }
- if (status.MPI_SOURCE != i) {
- errs++;
- printf( "Wrong source = %d\n", status.MPI_SOURCE );
- }
- for (k=0; k<10; k++) {
- if (b[k] != (i + 10 * j) * size + k) {
- errs++;
- printf( "received b[%d] = %d from %d tag %d\n",
- k, b[k], i, 27+j );
- }
- }
- }
- }
+ for (i = 0; i < size; i++) {
+ for (j = 0; j < 10; j++) {
+ int k;
+ status.MPI_TAG = -10;
+ status.MPI_SOURCE = -20;
+ MPI_Recv(b, 10, MPI_INT, i, 27 + j, MPI_COMM_WORLD, &status);
+
+ if (status.MPI_TAG != 27 + j) {
+ errs++;
+ printf("Wrong tag = %d\n", status.MPI_TAG);
+ }
+ if (status.MPI_SOURCE != i) {
+ errs++;
+ printf("Wrong source = %d\n", status.MPI_SOURCE);
+ }
+ for (k = 0; k < 10; k++) {
+ if (b[k] != (i + 10 * j) * size + k) {
+ errs++;
+ printf("received b[%d] = %d from %d tag %d\n", k, b[k], i, 27 + j);
+ }
+ }
+ }
+ }
}
- MPI_Buffer_detach( &bptr, &bl );
-
- MTest_Finalize( errs );
+ MPI_Buffer_detach(&bptr, &bl);
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
*/
#include <stdio.h>
#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<size; i++) {
- for (j=0; j<10; j++) {
- int k;
- status.MPI_TAG = -10;
- status.MPI_SOURCE = -20;
- MPI_Recv( b, 10, MPI_INT, i, 27+j, MPI_COMM_WORLD, &status );
-
- if (status.MPI_TAG != 27+j) {
- errs++;
- printf( "Wrong tag = %d\n", status.MPI_TAG );
- }
- if (status.MPI_SOURCE != i) {
- errs++;
- printf( "Wrong source = %d\n", status.MPI_SOURCE );
- }
- for (k=0; k<10; k++) {
- if (b[k] != (i + 10 * j) * size + k) {
- errs ++;
- printf( "received b[%d] = %d from %d tag %d\n",
- k, b[k], i, 27+j );
- }
- }
- }
- }
+ for (i = 0; i < size; i++) {
+ for (j = 0; j < 10; j++) {
+ int k;
+ status.MPI_TAG = -10;
+ status.MPI_SOURCE = -20;
+ MPI_Recv(b, 10, MPI_INT, i, 27 + j, MPI_COMM_WORLD, &status);
+
+ if (status.MPI_TAG != 27 + j) {
+ errs++;
+ printf("Wrong tag = %d\n", status.MPI_TAG);
+ }
+ if (status.MPI_SOURCE != i) {
+ errs++;
+ printf("Wrong source = %d\n", status.MPI_SOURCE);
+ }
+ for (k = 0; k < 10; k++) {
+ if (b[k] != (i + 10 * j) * size + k) {
+ errs++;
+ printf("received b[%d] = %d from %d tag %d\n", k, b[k], i, 27 + j);
+ }
+ }
+ }
+ }
}
- MPI_Buffer_detach( &bptr, &bl );
+ MPI_Buffer_detach(&bptr, &bl);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
*/
#include <stdio.h>
#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<size; i++) {
- for (j=0; j<10; j++) {
- int k;
- status.MPI_TAG = -10;
- status.MPI_SOURCE = -20;
- MPI_Recv( b, 10, MPI_INT, i, 27+j, comm, &status );
-
- if (status.MPI_TAG != 27+j) {
- errs++;
- printf( "Wrong tag = %d\n", status.MPI_TAG );
- }
- if (status.MPI_SOURCE != i) {
- errs++;
- printf( "Wrong source = %d\n", status.MPI_SOURCE );
- }
- for (k=0; k<10; k++) {
- if (b[k] != (i + 10 * j) * size + k) {
- errs++;
- printf( "received b[%d] = %d from %d tag %d\n",
- k, b[k], i, 27+j );
- }
- }
- }
- }
+ for (i = 0; i < size; i++) {
+ for (j = 0; j < 10; j++) {
+ int k;
+ status.MPI_TAG = -10;
+ status.MPI_SOURCE = -20;
+ MPI_Recv(b, 10, MPI_INT, i, 27 + j, comm, &status);
+
+ if (status.MPI_TAG != 27 + j) {
+ errs++;
+ printf("Wrong tag = %d\n", status.MPI_TAG);
+ }
+ if (status.MPI_SOURCE != i) {
+ errs++;
+ printf("Wrong source = %d\n", status.MPI_SOURCE);
+ }
+ for (k = 0; k < 10; k++) {
+ if (b[k] != (i + 10 * j) * size + k) {
+ errs++;
+ printf("received b[%d] = %d from %d tag %d\n", k, b[k], i, 27 + j);
+ }
+ }
+ }
+ }
}
- MPI_Buffer_detach( &bptr, &bl );
+ MPI_Buffer_detach(&bptr, &bl);
MPI_Comm_free(&scomm);
MPI_Comm_free(&comm);
- MTest_Finalize( errs );
-
+ MTest_Finalize(errs);
+
MPI_Finalize();
return 0;
}
#include "mpi.h"
#include "mpitest.h"
-/* Test bsend with a buffer with arbitrary alignment */
+/* Test bsend with a buffer with arbitray alignment */
#define BUFSIZE 2000*4
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Status status;
int a[10], b[10];
int align;
- char buf[BUFSIZE+8], *bptr;
+ char buf[BUFSIZE + 8], *bptr;
int 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 );
+ MTest_Init(0, 0);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
for (align = 0; align < 7; align++) {
- MPI_Buffer_attach( buf+align, 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<size; i++) {
- for (j=0; j<10; j++) {
- int k;
- status.MPI_TAG = -10;
- status.MPI_SOURCE = -20;
- MPI_Recv( b, 10, MPI_INT, i, 27+j, MPI_COMM_WORLD, &status );
-
- if (status.MPI_TAG != 27+j) {
- errs ++;
- printf( "Wrong tag = %d\n", status.MPI_TAG );
- }
- if (status.MPI_SOURCE != i) {
- errs++;
- printf( "Wrong source = %d\n", status.MPI_SOURCE );
- }
- for (k=0; k<10; k++) {
- if (b[k] != (i + 10 * j) * size + k) {
- errs++;
- printf( "(Align=%d) received b[%d] = %d (expected %d) from %d tag %d\n",
- align, k, b[k], (i+10*j), i, 27+j );
- }
- }
- }
- }
- }
- MPI_Buffer_detach( &bptr, &bl );
- if (bptr != buf+align) {
- errs++;
- printf( "Did not recieve the same buffer on detach that was provided on init (%p vs %p)\n", bptr, buf );
- }
+ MPI_Buffer_attach(buf + align, 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 < size; i++) {
+ for (j = 0; j < 10; j++) {
+ int k;
+ status.MPI_TAG = -10;
+ status.MPI_SOURCE = -20;
+ MPI_Recv(b, 10, MPI_INT, i, 27 + j, MPI_COMM_WORLD, &status);
+
+ if (status.MPI_TAG != 27 + j) {
+ errs++;
+ printf("Wrong tag = %d\n", status.MPI_TAG);
+ }
+ if (status.MPI_SOURCE != i) {
+ errs++;
+ printf("Wrong source = %d\n", status.MPI_SOURCE);
+ }
+ for (k = 0; k < 10; k++) {
+ if (b[k] != (i + 10 * j) * size + k) {
+ errs++;
+ printf("(Align=%d) received b[%d] = %d (expected %d) from %d tag %d\n",
+ align, k, b[k], (i + 10 * j), i, 27 + j);
+ }
+ }
+ }
+ }
+ }
+ MPI_Buffer_detach(&bptr, &bl);
+ if (bptr != buf + align) {
+ errs++;
+ printf
+ ("Did not recieve the same buffer on detach that was provided on init (%p vs %p)\n",
+ bptr, buf);
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
* Notes on the test.
*
* To ensure that messages remain in the bsend buffer until received,
- * messages are sent with size MSG_SIZE (ints).
+ * messages are sent with size MSG_SIZE (ints).
*/
#define MSG_SIZE 17000
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int b1[MSG_SIZE], b2[MSG_SIZE], b3[MSG_SIZE], b4[MSG_SIZE];
MPI_Comm comm;
MPI_Status status;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
if (size < 2) {
- errs++;
- fprintf( stderr, "At least 2 processes required\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- exit(1);
+ errs++;
+ fprintf(stderr, "At least 2 processes required\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- src = 0;
+ src = 0;
dest = 1;
if (rank == src) {
- int *buf, bufsize, bsize;
-
- bufsize = 4 * (MSG_SIZE * sizeof(int) + MPI_BSEND_OVERHEAD);
- buf = (int *)malloc( bufsize );
- if (!buf) {
- fprintf( stderr, "Could not allocate buffer of %d bytes\n",
- bufsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- exit(1);
- }
- MPI_Buffer_attach( buf, bufsize );
-
- /* Initialize data */
- for (i=0; i<MSG_SIZE; i++) {
- b1[i] = i;
- b2[i] = MSG_SIZE + i;
- b3[i] = 2 * MSG_SIZE + i;
- b4[i] = 3 * MSG_SIZE + i;
- }
- /* Send and reset buffers after bsend returns */
- MPI_Bsend( b1, MSG_SIZE, MPI_INT, dest, 0, comm );
- for (i=0; i<MSG_SIZE; i++) b1[i] = -b1[i];
- MPI_Bsend( b2, MSG_SIZE, MPI_INT, dest, 1, comm );
- for (i=0; i<MSG_SIZE; i++) b2[i] = -b2[i];
- MPI_Bsend( b3, MSG_SIZE, MPI_INT, dest, 2, comm );
- for (i=0; i<MSG_SIZE; i++) b3[i] = -b3[i];
- MPI_Bsend( b4, MSG_SIZE, MPI_INT, dest, 3, comm );
- for (i=0; i<MSG_SIZE; i++) b4[i] = -b4[i];
-
- MPI_Barrier( comm );
- /* Detach waits until all messages received */
- MPI_Buffer_detach( &buf, &bsize );
+ int *buf, bufsize, bsize;
+
+ bufsize = 4 * (MSG_SIZE * sizeof(int) + MPI_BSEND_OVERHEAD);
+ buf = (int *) malloc(bufsize);
+ if (!buf) {
+ fprintf(stderr, "Could not allocate buffer of %d bytes\n", bufsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MPI_Buffer_attach(buf, bufsize);
+
+ /* Initialize data */
+ for (i = 0; i < MSG_SIZE; i++) {
+ b1[i] = i;
+ b2[i] = MSG_SIZE + i;
+ b3[i] = 2 * MSG_SIZE + i;
+ b4[i] = 3 * MSG_SIZE + i;
+ }
+ /* Send and reset buffers after bsend returns */
+ MPI_Bsend(b1, MSG_SIZE, MPI_INT, dest, 0, comm);
+ for (i = 0; i < MSG_SIZE; i++)
+ b1[i] = -b1[i];
+ MPI_Bsend(b2, MSG_SIZE, MPI_INT, dest, 1, comm);
+ for (i = 0; i < MSG_SIZE; i++)
+ b2[i] = -b2[i];
+ MPI_Bsend(b3, MSG_SIZE, MPI_INT, dest, 2, comm);
+ for (i = 0; i < MSG_SIZE; i++)
+ b3[i] = -b3[i];
+ MPI_Bsend(b4, MSG_SIZE, MPI_INT, dest, 3, comm);
+ for (i = 0; i < MSG_SIZE; i++)
+ b4[i] = -b4[i];
+
+ MPI_Barrier(comm);
+ /* Detach waits until all messages received */
+ MPI_Buffer_detach(&buf, &bsize);
+ free(buf);
}
else if (rank == dest) {
-
- MPI_Barrier( comm );
- MPI_Recv( b2, MSG_SIZE, MPI_INT, src, 1, comm, &status );
- MPI_Recv( b1, MSG_SIZE, MPI_INT, src, 0, comm, &status );
- MPI_Recv( b4, MSG_SIZE, MPI_INT, src, 3, comm, &status );
- MPI_Recv( b3, MSG_SIZE, MPI_INT, src, 2, comm, &status );
-
- /* Check received data */
- for (i=0; i<MSG_SIZE; i++) {
- if (b1[i] != i) {
- errs++;
- if (errs < 16) printf( "b1[%d] is %d\n", i, b1[i] );
- }
- if (b2[i] != MSG_SIZE + i) {
- errs++;
- if (errs < 16) printf( "b2[%d] is %d\n", i, b2[i] );
- }
- if (b3[i] != 2 * MSG_SIZE + i) {
- errs++;
- if (errs < 16) printf( "b3[%d] is %d\n", i, b3[i] );
- }
- if (b4[i] != 3 * MSG_SIZE + i) {
- errs++;
- if (errs < 16) printf( "b4[%d] is %d\n", i, b4[i] );
- }
- }
+
+ MPI_Barrier(comm);
+ MPI_Recv(b2, MSG_SIZE, MPI_INT, src, 1, comm, &status);
+ MPI_Recv(b1, MSG_SIZE, MPI_INT, src, 0, comm, &status);
+ MPI_Recv(b4, MSG_SIZE, MPI_INT, src, 3, comm, &status);
+ MPI_Recv(b3, MSG_SIZE, MPI_INT, src, 2, comm, &status);
+
+ /* Check received data */
+ for (i = 0; i < MSG_SIZE; i++) {
+ if (b1[i] != i) {
+ errs++;
+ if (errs < 16)
+ printf("b1[%d] is %d\n", i, b1[i]);
+ }
+ if (b2[i] != MSG_SIZE + i) {
+ errs++;
+ if (errs < 16)
+ printf("b2[%d] is %d\n", i, b2[i]);
+ }
+ if (b3[i] != 2 * MSG_SIZE + i) {
+ errs++;
+ if (errs < 16)
+ printf("b3[%d] is %d\n", i, b3[i]);
+ }
+ if (b4[i] != 3 * MSG_SIZE + i) {
+ errs++;
+ if (errs < 16)
+ printf("b4[%d] is %d\n", i, b4[i]);
+ }
+ }
}
else {
- MPI_Barrier( comm );
+ MPI_Barrier(comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
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 main(int argc, char *argv[])
{
int errs = 0;
int rank, size, source, dest;
unsigned char *buf, *bufp;
- int minsize = 2;
+ int minsize = 2;
int i, msgsize, bufsize, outsize;
unsigned char *msg1, *msg2, *msg3;
- MPI_Comm comm;
- MPI_Status status1, status2, status3;
+ MPI_Comm comm;
+ MPI_Status status1, status2, status3;
- 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 */
+ /* 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 );
+ 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 );
- exit(1);
- }
-
- MPI_Buffer_attach( buf, bufsize );
-
- /* Initialize the buffers */
- for (i=0; i<msgsize; i++) {
- msg1[i] = 0xff ^ (i & 0xff);
- msg2[i] = 0xff ^ (3*i & 0xff);
- msg3[i] = 0xff ^ (5*i & 0xff);
- }
-
- /* Initiate the bsends */
- MPI_Bsend( msg1, msgsize, MPI_UNSIGNED_CHAR, dest, 0, comm );
- MPI_Bsend( msg2, msgsize, MPI_UNSIGNED_CHAR, dest, 0, comm );
- MPI_Bsend( msg3, msgsize, MPI_UNSIGNED_CHAR, dest, 0, comm );
-
- /* Synchronize with our partner */
- MPI_Sendrecv( NULL, 0, MPI_UNSIGNED_CHAR, dest, 10,
- NULL, 0, MPI_UNSIGNED_CHAR, dest, 10, comm, MPI_STATUS_IGNORE );
-
- /* Detach the buffers. There should be pending operations */
- MPI_Buffer_detach ( &bufp, &outsize );
- if (bufp != buf) {
- fprintf( stderr, "Wrong buffer returned\n" );
- errs++;
- }
- if (outsize != bufsize) {
- fprintf( stderr, "Wrong buffer size returned\n" );
- errs++;
- }
- }
- else if (rank == dest) {
- double tstart;
-
- /* Clear the message buffers */
- for (i=0; i<msgsize; i++) {
- msg1[i] = 0;
- msg2[i] = 0;
- msg3[i] = 0;
- }
-
- /* Wait for the synchronize */
- MPI_Sendrecv( NULL, 0, MPI_UNSIGNED_CHAR, source, 10,
- NULL, 0, MPI_UNSIGNED_CHAR, source, 10, comm, MPI_STATUS_IGNORE );
-
- /* Wait 2 seconds */
- tstart = MPI_Wtime();
- while (MPI_Wtime() - tstart < 2.0) ;
-
- /* Now receive the messages */
- MPI_Recv( msg1, msgsize, MPI_UNSIGNED_CHAR, source, 0, comm, &status1 );
- MPI_Recv( msg2, msgsize, MPI_UNSIGNED_CHAR, source, 0, comm, &status2 );
- MPI_Recv( msg3, msgsize, MPI_UNSIGNED_CHAR, source, 0, comm, &status3 );
-
- /* Check that we have the correct data */
- for (i=0; i<msgsize; i++) {
- if (msg1[i] != (0xff ^ (i & 0xff))) {
- if (errs < 10) {
- fprintf( stderr, "msg1[%d] = %d\n", i, msg1[i] );
- }
- errs++;
- }
- if (msg2[i] != (0xff ^ (3*i & 0xff))) {
- if (errs < 10) {
- fprintf( stderr, "msg2[%d] = %d\n", i, msg2[i] );
- }
- errs++;
- }
- if (msg3[i] != (0xff ^ (5*i & 0xff))) {
- if (errs < 10) {
- fprintf( stderr, "msg2[%d] = %d\n", i, msg2[i] );
- }
- errs++;
- }
- }
-
- }
-
-
- MTestFreeComm( &comm );
+ 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 < msgsize; i++) {
+ msg1[i] = 0xff ^ (i & 0xff);
+ msg2[i] = 0xff ^ (3 * i & 0xff);
+ msg3[i] = 0xff ^ (5 * i & 0xff);
+ }
+
+ /* Initiate the bsends */
+ MPI_Bsend(msg1, msgsize, MPI_UNSIGNED_CHAR, dest, 0, comm);
+ MPI_Bsend(msg2, msgsize, MPI_UNSIGNED_CHAR, dest, 0, comm);
+ MPI_Bsend(msg3, msgsize, MPI_UNSIGNED_CHAR, dest, 0, comm);
+
+ /* Synchronize with our partner */
+ MPI_Sendrecv(NULL, 0, MPI_UNSIGNED_CHAR, dest, 10,
+ NULL, 0, MPI_UNSIGNED_CHAR, dest, 10, comm, MPI_STATUS_IGNORE);
+
+ /* Detach the buffers. There should be pending operations */
+ MPI_Buffer_detach(&bufp, &outsize);
+ if (bufp != buf) {
+ fprintf(stderr, "Wrong buffer returned\n");
+ errs++;
+ }
+ if (outsize != bufsize) {
+ fprintf(stderr, "Wrong buffer size returned\n");
+ errs++;
+ }
+ free(buf);
+ }
+ else if (rank == dest) {
+ double tstart;
+
+ /* Clear the message buffers */
+ for (i = 0; i < msgsize; i++) {
+ msg1[i] = 0;
+ msg2[i] = 0;
+ msg3[i] = 0;
+ }
+
+ /* Wait for the synchronize */
+ MPI_Sendrecv(NULL, 0, MPI_UNSIGNED_CHAR, source, 10,
+ NULL, 0, MPI_UNSIGNED_CHAR, source, 10, comm, MPI_STATUS_IGNORE);
+
+ /* Wait 2 seconds */
+ tstart = MPI_Wtime();
+ while (MPI_Wtime() - tstart < 2.0);
+
+ /* Now receive the messages */
+ MPI_Recv(msg1, msgsize, MPI_UNSIGNED_CHAR, source, 0, comm, &status1);
+ MPI_Recv(msg2, msgsize, MPI_UNSIGNED_CHAR, source, 0, comm, &status2);
+ MPI_Recv(msg3, msgsize, MPI_UNSIGNED_CHAR, source, 0, comm, &status3);
+
+ /* Check that we have the correct data */
+ for (i = 0; i < msgsize; i++) {
+ if (msg1[i] != (0xff ^ (i & 0xff))) {
+ if (errs < 10) {
+ fprintf(stderr, "msg1[%d] = %d\n", i, msg1[i]);
+ }
+ errs++;
+ }
+ if (msg2[i] != (0xff ^ (3 * i & 0xff))) {
+ if (errs < 10) {
+ fprintf(stderr, "msg2[%d] = %d\n", i, msg2[i]);
+ }
+ errs++;
+ }
+ if (msg3[i] != (0xff ^ (5 * i & 0xff))) {
+ if (errs < 10) {
+ fprintf(stderr, "msg2[%d] = %d\n", i, msg2[i]);
+ }
+ errs++;
+ }
+ }
+
+ }
+
+
+ MTestFreeComm(&comm);
}
- free( msg1 );
+ free(msg1);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2014 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#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();
+}
#include <stdio.h>
#include <stdlib.h>
#include "mpitest.h"
-#include <string.h> /* For memset */
+#include <string.h> /* 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;
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2016 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <mpi.h>
+
+#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;
+}
#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; i<MAX_MSGS; i++) {
- bufs[i] = (int *)malloc( extent );
- if (!bufs[i]) {
- fprintf( stderr, "Unable to allocate buffer %d of size %ld\n",
- i, (long)extent );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- exit(1);
- }
+ MPI_Type_extent(dtype, &extent);
+ for (i = 0; i < MAX_MSGS; i++) {
+ bufs[i] = (int *) malloc(extent);
+ if (!bufs[i]) {
+ fprintf(stderr, "Unable to allocate buffer %d of size %ld\n", i, (long) extent);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MTEST_VG_MEM_INIT(bufs[i], extent);
}
- buf = (int *)malloc( 10 * 30 * sizeof(int) );
-
- MPI_Barrier( MPI_COMM_WORLD );
+ buf = (int *) malloc(10 * 30 * sizeof(int));
+
+ MPI_Barrier(MPI_COMM_WORLD);
if (rank == dest) {
- MTestSleep( 2 );
- for (i=0; i<MAX_MSGS; i++) {
- MPI_Recv( buf, 10*30, MPI_INT, source, i, comm,
- MPI_STATUS_IGNORE );
- }
+ MTestSleep(2);
+ for (i = 0; i < MAX_MSGS; i++) {
+ MPI_Recv(buf, 10 * 30, MPI_INT, source, i, comm, MPI_STATUS_IGNORE);
+ }
}
- else if (rank == source ) {
- for (i=0; i<MAX_MSGS; i++) {
- MPI_Isend( bufs[i], 1, dtype, dest, i, comm, &req[i] );
- }
- MPI_Waitall( MAX_MSGS, req, MPI_STATUSES_IGNORE );
+ else if (rank == source) {
+ for (i = 0; i < MAX_MSGS; i++) {
+ MPI_Isend(bufs[i], 1, dtype, dest, i, comm, &req[i]);
+ }
+ MPI_Waitall(MAX_MSGS, req, MPI_STATUSES_IGNORE);
}
- MPI_Type_free( &dtype );
- MTest_Finalize( errs );
+ MPI_Type_free(&dtype);
+ for (i = 0; i < MAX_MSGS; i++) {
+ free(bufs[i]);
+ }
+ free(buf);
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
*/
-int query_fn( void *extra_state, MPI_Status *status );
-int query_fn( void *extra_state, MPI_Status *status )
+int query_fn(void *extra_state, MPI_Status * status);
+int query_fn(void *extra_state, MPI_Status * status)
{
/* Set a default status */
status->MPI_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;
}
* 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;
}
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; i<remote_size; i++) {
- buf = -1;
- MPI_Recv( &buf, 1, MPI_INT, i, 0, comm, &status );
- if (buf != i) {
- errs++;
- fprintf( stderr, "buf = %d, should be %d\n", buf, i );
- }
- }
- }
- }
- /* Now, reverse it and send back */
- 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; i<remote_size; i++) {
- buf = -1;
- MPI_Recv( &buf, 1, MPI_INT, i, 0, comm, &status );
- if (buf != i) {
- errs++;
- fprintf( stderr, "buf = %d, should be %d\n", buf, i );
- }
- }
- }
- }
+ 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; i < remote_size; i++) {
+ buf = -1;
+ MPI_Recv(&buf, 1, MPI_INT, i, 0, comm, &status);
+ if (buf != i) {
+ errs++;
+ fprintf(stderr, "buf = %d, should be %d\n", buf, i);
+ }
+ }
+ }
+ }
+ /* Now, reverse it and send back */
+ 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; i < remote_size; i++) {
+ buf = -1;
+ MPI_Recv(&buf, 1, MPI_INT, i, 0, comm, &status);
+ if (buf != i) {
+ errs++;
+ fprintf(stderr, "buf = %d, should be %d\n", buf, i);
+ }
+ }
+ }
+ }
MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
#include "mpitest.h"
/* This test program checks that the point-to-point completion routines
- can be applied to an inactive persistent request, as required by the
- MPI-1 standard. See section 3.7.3, for example,
+ can be applied to an inactive persistent request, as required by the
+ MPI-1 standard. See section 3.7.3, for example,
- One is allowed to call MPI TEST with a null or inactive request argument.
+ One is allowed to call MPI TEST with a null or inactive request argument.
In such a case the operation returns with flag = true and empty status.
*/
-int StatusEmpty( MPI_Status *s );
-int StatusEmpty( MPI_Status *s )
+int StatusEmpty(MPI_Status * s);
+int StatusEmpty(MPI_Status * s)
{
int errs = 0;
int count = 10;
if (s->MPI_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;
int main(int argc, char *argv[])
{
MPI_Request r;
- MPI_Status s;
+ MPI_Status s;
int errs = 0;
int flag;
int buf[10];
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<size; i++) {
- MPI_Irecv( rbuf, 10, MPI_INT, i, tag, MPI_COMM_WORLD, &rr[i] );
- }
- MPI_Start( &r );
- MPI_Wait( &r, &s );
- MPI_Waitall( size, rr, MPI_STATUSES_IGNORE );
+ int i;
+ MPI_Request *rr = (MPI_Request *) malloc(size * sizeof(MPI_Request));
+ for (i = 0; i < size; i++) {
+ MPI_Irecv(rbuf, 10, MPI_INT, i, tag, MPI_COMM_WORLD, &rr[i]);
+ }
+ MPI_Start(&r);
+ MPI_Wait(&r, &s);
+ MPI_Waitall(size, rr, MPI_STATUSES_IGNORE);
+ free(rr);
}
else {
- MPI_Start( &r );
- MPI_Wait( &r, &s );
+ MPI_Start(&r);
+ MPI_Wait(&r, &s);
}
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");
}
-
- MPI_Request_free( &r );
+
+ MPI_Request_free(&r);
/* Create a persistent receive request */
- MPI_Recv_init( buf, 10, MPI_INT, dest, tag, MPI_COMM_WORLD, &r );
+ MPI_Recv_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 (recv)\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 (recv)\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 (recv)\n" );
+ if (!StatusEmpty(&s)) {
+ errs++;
+ printf("Status not empty after MPI_Test (recv)\n");
}
s.MPI_TAG = 10;
s.MPI_SOURCE = 10;
- MPI_Wait( &r, &s );
- if (!StatusEmpty( &s )) {
- errs++;
- printf( "Status not empty after MPI_Wait (recv)\n" );
+ MPI_Wait(&r, &s);
+ if (!StatusEmpty(&s)) {
+ errs++;
+ printf("Status not empty after MPI_Wait (recv)\n");
}
- MPI_Request_free( &r );
-
- MTest_Finalize( errs );
+ MPI_Request_free(&r);
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
--- /dev/null
+/* -*- 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 <stdlib.h>
+#include <stdio.h>
+#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;
+
+}
#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;
}
#include "mpi.h"
#include "mpitest.h"
-int main( int argc, char * argv[] )
+int main(int argc, char *argv[])
{
int rank;
int sendMsg = 123;
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;
}
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);
printf(" No Errors\n");
MPI_Finalize();
- return 0;
}
#include <stdlib.h>
#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<cnt; i++) cols[i] = i;
- /* printf("[%d] sending...\n",rank);*/
- /* ierr = */ MPI_Send(cols,cnt,MPI_LONG_LONG_INT,1,0,MPI_COMM_WORLD);
- /* ierr = */ MPI_Send(cols,cnt,MPI_LONG_LONG_INT,2,0,MPI_COMM_WORLD);
- } else {
- /* printf("[%d] receiving...\n",rank); */
- for (i=0; i<cnt; i++) cols[i] = -1;
- /* ierr = */ MPI_Recv(cols,cnt,MPI_LONG_LONG_INT,0,0,MPI_COMM_WORLD,&status);
- /* ierr = MPI_Get_count(&status,MPI_LONG_LONG_INT,&cnt);
- Get_count still fails because status.count is not 64 bit */
- for (i=0; i<cnt; i++) {
- if (cols[i] != i) {
- /*printf("Rank %d, cols[i]=%lld, should be %d\n", rank, cols[i], i);*/
+ if (rank == 0) {
+ for (i = 0; i < cnt; i++)
+ cols[i] = i;
+ /* printf("[%d] sending...\n",rank); */
+ ierr = MPI_Send(cols, cnt, MPI_LONG_LONG_INT, 1, 0, MPI_COMM_WORLD);
+ ierr = MPI_Send(cols, cnt, MPI_LONG_LONG_INT, 2, 0, MPI_COMM_WORLD);
+ }
+ else {
+ /* printf("[%d] receiving...\n",rank); */
+ for (i = 0; i < cnt; i++)
+ cols[i] = -1;
+ ierr = MPI_Recv(cols, cnt, MPI_LONG_LONG_INT, 0, 0, MPI_COMM_WORLD, &status);
+ ierr = MPI_Get_count(&status,MPI_LONG_LONG_INT,&stat_cnt);
+ if (cnt != stat_cnt) {
+ fprintf(stderr, "Output of MPI_Get_count (%d) does not match expected count (%d).\n", stat_cnt, cnt);
errs++;
}
+ for (i = 0; i < cnt; i++) {
+ if (cols[i] != i) {
+ /*printf("Rank %d, cols[i]=%lld, should be %d\n", rank, cols[i], i); */
+ errs++;
+ }
+ }
}
- }
- MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2015 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mpi.h>
+
+#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;
+}
--- /dev/null
+/*
+ * (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 <stdio.h>
+#include <stdlib.h>
+#include <memory.h>
+#include <mpi.h>
+
+#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;
+}
#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 { \
} \
} 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);
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 */
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;
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);
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);
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
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) {
return 0;
}
-
#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<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 );
- }
- }
+ /* To shorten test time, only run the default version of datatype tests
+ * for comm world and run the minimum version for other communicators. */
+ if (comm != MPI_COMM_WORLD) {
+ MTestInitMinDatatypes();
+ }
- 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 );
+ while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
+ int nbytes;
+ MPI_Type_size(sendtype.datatype, &nbytes);
+
+ /* 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);
+
+ 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;
}
#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
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;
}
#include "mpi.h"
#include "mpitest.h"
-/*
+/*
* This program checks that MPI_Iprobe and MPI_Probe correctly handle
* a source of MPI_PROC_NULL
*/
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;
}
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;
}
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;
}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ * (C) 2016 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <mpi.h>
+
+#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;
+}
#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;
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();
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;
}
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;
}
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;
}
--- /dev/null
+/* -*- 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 <stdio.h>
+#include <stdlib.h>
+#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;
+}
#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).
*/
#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;
}
/*
* 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.
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<argc; i++) {
- if (strcmp(argv[i],"-v") == 0 ||
- strcmp(argv[i],"--verbose") == 0) verbose = 1;
- else if (strcmp(argv[i],"-p") == 0 ||
- strcmp(argv[i],"--progress") == 0) loopProgress = 1;
- else {
- if (rank == 0) {
- fprintf( stderr, "%s: [ -v | --verbose ] [ -p | --progress ]\n",
- argv[0] );
- fflush(stderr);
- }
- }
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0)
+ verbose = 1;
+ else if (strcmp(argv[i], "-p") == 0 || strcmp(argv[i], "--progress") == 0)
+ loopProgress = 1;
+ else {
+ if (rank == 0) {
+ fprintf(stderr, "%s: [ -v | --verbose ] [ -p | --progress ]\n", argv[0]);
+ fflush(stderr);
+ }
+ }
}
if (verbose) {
- char buf[ 128 ] ;
- sprintf( buf, "fast_mpi_%d.dmp", rank ) ;
- pf = fopen( buf, "w" ) ;
+ char buf[128];
+ sprintf(buf, "fast_mpi_%d.dmp", rank);
+ pf = fopen(buf, "w");
}
else if (loopProgress) {
- pf = stdout;
+ pf = stdout;
}
- if( !rank ) {
- int **psend ;
- int **precv ;
- psend = (int**)calloc( nProc, sizeof( int *) ) ;
- precv = (int**)calloc( nProc, sizeof( int *) ) ;
- for( i = 0 ; i < nProc ; i++ ) {
- psend[ i ] = (int*)calloc( DATA_SIZE, sizeof( int ) ) ;
- precv[ i ] = (int*)calloc( DATA_SIZE, sizeof( int ) ) ;
- }
- for( i = 0 ; i < LOOP_COUNT ; i++ ) {
- if (verbose) {
- fprintf( pf, "Master : loop %d\n", i ) ;
- fflush( pf ) ;
- }
- else if (loopProgress && (i & PROGRESS_COUNT) == 0) {
- fprintf( pf, "Master: loop %d\n", i ); fflush( pf );
- }
- for( j = 1 ; j < nProc ; j++ ) {
- if (verbose) {
- fprintf( pf, " read from child %d\n", j ) ;
- fflush( pf ) ;
- }
- status = MPI_Recv( precv[ j ], DATA_SIZE, MPI_INT, j, MP_TAG,
- MPI_COMM_WORLD, MPI_STATUS_IGNORE ) ;
- if (verbose) {
- fprintf( pf, " read from child %d done, status = %d\n", j,
- status ) ;
- fflush( pf ) ;
- }
- }
- for( j = 1 ; j < nProc ; j++ ) {
- if (verbose) {
- fprintf( pf, " send to child %d\n", j ) ;
- fflush( pf ) ;
- }
- status = MPI_Send( psend[ j ], DATA_SIZE - 1, MPI_INT, j,
- MP_TAG, MPI_COMM_WORLD ) ;
- if (verbose) {
- fprintf( pf, " send to child %d done, status = %d\n", j,
- status ) ;
- fflush( pf ) ;
- }
- }
- }
- for( i = 0 ; i < nProc ; i++ ) {
- free( psend[ i ] );
- free( precv[ i ] );
- }
- free( psend );
- free( precv );
- } else {
- int *psend ;
- int *precv ;
- psend = (int*)calloc( DATA_SIZE, sizeof( int ) ) ;
- precv = (int*)calloc( DATA_SIZE, sizeof( int ) ) ;
- for( i = 0 ; i < LOOP_COUNT ; i++ ) {
- if (verbose) {
- fprintf( pf, " send to master\n" ) ;
- fflush( pf ) ;
- }
- /*
- else if (loopProgress && (i & PROGRESS_COUNT) == 0) {
- fprintf( pf, "Slave: loop %d\n", i ); fflush( pf );
- }
- */
- status = MPI_Send( psend, DATA_SIZE - 1, MPI_INT, 0, MP_TAG,
- MPI_COMM_WORLD ) ;
- if (verbose) {
- fprintf( pf, " send to master done, status = %d\n", status ) ;
- fflush( pf ) ;
- fprintf( pf, " read from master\n" ) ;
- fflush( pf ) ;
- }
- status = MPI_Recv( precv, DATA_SIZE, MPI_INT, 0, MP_TAG,
- MPI_COMM_WORLD, MPI_STATUS_IGNORE ) ;
- if (verbose) {
- fprintf( pf, " read from master done, status = %d\n", status ) ;
- fflush( pf ) ;
- }
- }
- free( psend );
- free( precv );
+ if (!rank) {
+ int **psend;
+ int **precv;
+ psend = (int **) calloc(nProc, sizeof(int *));
+ precv = (int **) calloc(nProc, sizeof(int *));
+ for (i = 0; i < nProc; i++) {
+ psend[i] = (int *) calloc(DATA_SIZE, sizeof(int));
+ precv[i] = (int *) calloc(DATA_SIZE, sizeof(int));
+ }
+ for (i = 0; i < LOOP_COUNT; i++) {
+ if (verbose) {
+ fprintf(pf, "Master : loop %d\n", i);
+ fflush(pf);
+ }
+ else if (loopProgress && (i & PROGRESS_COUNT) == 0) {
+ fprintf(pf, "Master: loop %d\n", i);
+ fflush(pf);
+ }
+ for (j = 1; j < nProc; j++) {
+ if (verbose) {
+ fprintf(pf, " read from child %d\n", j);
+ fflush(pf);
+ }
+ status = MPI_Recv(precv[j], DATA_SIZE, MPI_INT, j, MP_TAG,
+ MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ if (verbose) {
+ fprintf(pf, " read from child %d done, status = %d\n", j, status);
+ fflush(pf);
+ }
+ }
+ for (j = 1; j < nProc; j++) {
+ if (verbose) {
+ fprintf(pf, " send to child %d\n", j);
+ fflush(pf);
+ }
+ status = MPI_Send(psend[j], DATA_SIZE - 1, MPI_INT, j, MP_TAG, MPI_COMM_WORLD);
+ if (verbose) {
+ fprintf(pf, " send to child %d done, status = %d\n", j, status);
+ fflush(pf);
+ }
+ }
+ }
+ for (i = 0; i < nProc; i++) {
+ free(psend[i]);
+ free(precv[i]);
+ }
+ free(psend);
+ free(precv);
+ }
+ else {
+ int *psend;
+ int *precv;
+ psend = (int *) calloc(DATA_SIZE, sizeof(int));
+ precv = (int *) calloc(DATA_SIZE, sizeof(int));
+ for (i = 0; i < LOOP_COUNT; i++) {
+ if (verbose) {
+ fprintf(pf, " send to master\n");
+ fflush(pf);
+ }
+ /*
+ * else if (loopProgress && (i & PROGRESS_COUNT) == 0) {
+ * fprintf(pf, "Slave: loop %d\n", i); fflush(pf);
+ * }
+ */
+ status = MPI_Send(psend, DATA_SIZE - 1, MPI_INT, 0, MP_TAG, MPI_COMM_WORLD);
+ if (verbose) {
+ fprintf(pf, " send to master done, status = %d\n", status);
+ fflush(pf);
+ fprintf(pf, " read from master\n");
+ fflush(pf);
+ }
+ status = MPI_Recv(precv, DATA_SIZE, MPI_INT, 0, MP_TAG,
+ MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ if (verbose) {
+ fprintf(pf, " read from master done, status = %d\n", status);
+ fflush(pf);
+ }
+ }
+ free(psend);
+ free(precv);
}
if (verbose) {
- fclose( pf ) ;
+ fclose(pf);
}
- MPI_Finalize() ;
+ MPI_Finalize();
/* This test fails if it hangs */
if (rank == 0) {
- printf( " No Errors\n" );
+ printf(" No Errors\n");
}
return 0;
}
-
static char MTEST_Descrip[] = "Send-Recv";
*/
-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;
- MPI_Comm comm;
+ int minsize = 2, count;
+ 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;
+ /* 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;
+ /* 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 );
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
- for (count = 1; count < 65000; count = count * 2) {
- while (MTestGetDatatypes( &sendtype, &recvtype, count )) {
- /* Make sure that everyone has a recv buffer */
- recvtype.InitBuf( &recvtype );
+ MTEST_DATATYPE_FOR_EACH_COUNT(count) {
+ while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
+ /* Make sure that everyone has a recv buffer */
+ recvtype.InitBuf(&recvtype);
- if (rank == source) {
- sendtype.InitBuf( &sendtype );
-
- err = MPI_Send( sendtype.buf, sendtype.count,
- sendtype.datatype, dest, 0, comm);
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
- }
- else if (rank == dest) {
- err = MPI_Recv( recvtype.buf, recvtype.count,
- recvtype.datatype, source, 0, comm, MPI_STATUS_IGNORE);
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
+ if (rank == source) {
+ sendtype.InitBuf(&sendtype);
- 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\n",
- MTestGetDatatypeName( &recvtype ),
- MTestGetDatatypeName( &sendtype ),
- count );
- recvtype.printErrors = 1;
- (void)MTestCheckRecv( 0, &recvtype );
- }
- errs += err;
- }
- }
- MTestFreeDatatype( &sendtype );
- MTestFreeDatatype( &recvtype );
- }
- }
- MTestFreeComm( &comm );
+ err = MPI_Send(sendtype.buf, sendtype.count, sendtype.datatype, dest, 0, comm);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+ }
+ else if (rank == dest) {
+ 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\n",
+ MTestGetDatatypeName(&recvtype), MTestGetDatatypeName(&sendtype),
+ count);
+ recvtype.printErrors = 1;
+ (void) MTestCheckRecv(0, &recvtype);
+ }
+ errs += err;
+ }
+ }
+ MTestFreeDatatype(&sendtype);
+ MTestFreeDatatype(&recvtype);
+ }
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
static int parse_args(int argc, char **argv);
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int i, j, errs = 0;
int rank, size;
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size < 2) {
- if (verbose) fprintf(stderr, "comm size must be > 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;
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;
}
*/
#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<nmsg; i++) {
- buf[i] = (int *)malloc( msgSize * sizeof(int) );
- if (!buf[i]) {
- fprintf( stderr, "Unable to allocate %d bytes\n",
- msgSize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- exit(1);
- }
- }
- partner = (rank + 1) % size;
+ for (i = 0; i < nmsg; i++) {
+ buf[i] = (int *) malloc(msgSize * sizeof(int));
+ if (!buf[i]) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", msgSize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MTEST_VG_MEM_INIT(buf[i], msgSize * sizeof(int));
+ }
+ partner = (rank + 1) % size;
- MPI_Sendrecv( MPI_BOTTOM, 0, MPI_INT, partner, 10,
- MPI_BOTTOM, 0, MPI_INT, partner, 10, comm,
- MPI_STATUS_IGNORE );
- /* Try to fill up the outgoing message buffers */
- for (i=0; i<nmsg; i++) {
- MPI_Isend( buf[i], msgSize, MPI_INT, partner, testnum, comm,
- &r[i] );
- }
- for (i=0; i<nmsg; i++) {
- MPI_Recv( buf[i], msgSize, MPI_INT, partner, testnum, comm,
- MPI_STATUS_IGNORE );
- }
- MPI_Waitall( nmsg, r, MPI_STATUSES_IGNORE );
+ MPI_Sendrecv(MPI_BOTTOM, 0, MPI_INT, partner, 10,
+ MPI_BOTTOM, 0, MPI_INT, partner, 10, comm, MPI_STATUS_IGNORE);
+ /* Try to fill up the outgoing message buffers */
+ for (i = 0; i < nmsg; i++) {
+ MPI_Isend(buf[i], msgSize, MPI_INT, partner, testnum, comm, &r[i]);
+ }
+ for (i = 0; i < nmsg; i++) {
+ MPI_Recv(buf[i], msgSize, MPI_INT, partner, testnum, comm, MPI_STATUS_IGNORE);
+ }
+ MPI_Waitall(nmsg, r, MPI_STATUSES_IGNORE);
- /* Repeat the test, but make one of the processes sleep */
- MPI_Sendrecv( MPI_BOTTOM, 0, MPI_INT, partner, 10,
- MPI_BOTTOM, 0, MPI_INT, partner, 10, comm,
- MPI_STATUS_IGNORE );
- if (rank == dest) MTestSleep( 1 );
- /* Try to fill up the outgoing message buffers */
- tsend = MPI_Wtime();
- for (i=0; i<nmsg; i++) {
- MPI_Isend( buf[i], msgSize, MPI_INT, partner, testnum, comm,
- &r[i] );
- }
- tsend = MPI_Wtime() - tsend;
- for (i=0; i<nmsg; i++) {
- MPI_Recv( buf[i], msgSize, MPI_INT, partner, testnum, comm,
- MPI_STATUS_IGNORE );
- }
- MPI_Waitall( nmsg, r, MPI_STATUSES_IGNORE );
+ /* Repeat the test, but make one of the processes sleep */
+ MPI_Sendrecv(MPI_BOTTOM, 0, MPI_INT, partner, 10,
+ MPI_BOTTOM, 0, MPI_INT, partner, 10, comm, MPI_STATUS_IGNORE);
+ if (rank == dest)
+ MTestSleep(1);
+ /* Try to fill up the outgoing message buffers */
+ tsend = MPI_Wtime();
+ for (i = 0; i < nmsg; i++) {
+ MPI_Isend(buf[i], msgSize, MPI_INT, partner, testnum, comm, &r[i]);
+ }
+ tsend = MPI_Wtime() - tsend;
+ for (i = 0; i < nmsg; i++) {
+ MPI_Recv(buf[i], msgSize, MPI_INT, partner, testnum, comm, MPI_STATUS_IGNORE);
+ }
+ MPI_Waitall(nmsg, r, MPI_STATUSES_IGNORE);
- 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 );
+ 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<nmsg; i++) {
- free( buf[i] );
- }
- }
+ for (i = 0; i < nmsg; i++) {
+ free(buf[i]);
+ }
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
static char MTEST_Descrip[] = "Test of sending to self (with a preposted receive)";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size;
int count;
- MPI_Comm comm;
- MPI_Request req;
+ MPI_Comm comm;
+ MPI_Request req;
MTestDatatype sendtype, recvtype;
- 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);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
-
- for (count = 1; count < 65000; count = count * 2) {
- while (MTestGetDatatypes( &sendtype, &recvtype, count )) {
-
- sendtype.InitBuf( &sendtype );
- recvtype.InitBuf( &recvtype );
-
- err = MPI_Irecv( recvtype.buf, recvtype.count,
- recvtype.datatype, rank, 0, comm, &req );
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
-
- err = MPI_Send( sendtype.buf, sendtype.count,
- sendtype.datatype, rank, 0, comm);
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
- err = MPI_Wait( &req, MPI_STATUS_IGNORE );
- 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\n",
- MTestGetDatatypeName( &recvtype ),
- MTestGetDatatypeName( &sendtype ),
- count );
- recvtype.printErrors = 1;
- (void)MTestCheckRecv( 0, &recvtype );
- }
- errs += err;
- }
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
- err = MPI_Irecv( recvtype.buf, recvtype.count,
- recvtype.datatype, rank, 0, comm, &req );
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
-
- err = MPI_Ssend( sendtype.buf, sendtype.count,
- sendtype.datatype, rank, 0, comm);
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
- err = MPI_Wait( &req, MPI_STATUS_IGNORE );
- 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\n",
- MTestGetDatatypeName( &recvtype ),
- MTestGetDatatypeName( &sendtype ),
- count );
- recvtype.printErrors = 1;
- (void)MTestCheckRecv( 0, &recvtype );
- }
- errs += err;
- }
+ MTEST_DATATYPE_FOR_EACH_COUNT(count) {
+ while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
- err = MPI_Irecv( recvtype.buf, recvtype.count,
- recvtype.datatype, rank, 0, comm, &req );
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
-
- err = MPI_Rsend( sendtype.buf, sendtype.count,
- sendtype.datatype, rank, 0, comm);
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
- err = MPI_Wait( &req, MPI_STATUS_IGNORE );
- 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\n",
- MTestGetDatatypeName( &recvtype ),
- MTestGetDatatypeName( &sendtype ),
- count );
- recvtype.printErrors = 1;
- (void)MTestCheckRecv( 0, &recvtype );
- }
- errs += err;
- }
+ sendtype.InitBuf(&sendtype);
+ recvtype.InitBuf(&recvtype);
- MTestFreeDatatype( &sendtype );
- MTestFreeDatatype( &recvtype );
- }
+ err = MPI_Irecv(recvtype.buf, recvtype.count, recvtype.datatype, rank, 0, comm, &req);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+
+ err = MPI_Send(sendtype.buf, sendtype.count, sendtype.datatype, rank, 0, comm);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+ err = MPI_Wait(&req, MPI_STATUS_IGNORE);
+ 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\n",
+ MTestGetDatatypeName(&recvtype), MTestGetDatatypeName(&sendtype), count);
+ recvtype.printErrors = 1;
+ (void) MTestCheckRecv(0, &recvtype);
+ }
+ errs += err;
+ }
+
+ err = MPI_Irecv(recvtype.buf, recvtype.count, recvtype.datatype, rank, 0, comm, &req);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+
+ err = MPI_Ssend(sendtype.buf, sendtype.count, sendtype.datatype, rank, 0, comm);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+ err = MPI_Wait(&req, MPI_STATUS_IGNORE);
+ 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\n",
+ MTestGetDatatypeName(&recvtype), MTestGetDatatypeName(&sendtype), count);
+ recvtype.printErrors = 1;
+ (void) MTestCheckRecv(0, &recvtype);
+ }
+ errs += err;
+ }
+
+ err = MPI_Irecv(recvtype.buf, recvtype.count, recvtype.datatype, rank, 0, comm, &req);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+
+ err = MPI_Rsend(sendtype.buf, sendtype.count, sendtype.datatype, rank, 0, comm);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+ err = MPI_Wait(&req, MPI_STATUS_IGNORE);
+ 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\n",
+ MTestGetDatatypeName(&recvtype), MTestGetDatatypeName(&sendtype), count);
+ recvtype.printErrors = 1;
+ (void) MTestCheckRecv(0, &recvtype);
+ }
+ errs += err;
+ }
+
+ MTestFreeDatatype(&sendtype);
+ MTestFreeDatatype(&recvtype);
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
#bsendpending 2
isendself 1
#issendselfcancel 1
+isendirecv 10
#needs MPI_Buffer_attach, MPI_Bsend, MPI_Buffer_detach
#bsendfrag 2
#needs MPI_Intercomm_create
static int verbose = 0;
+int main(int argc, char *argv[]);
int parse_args(int argc, char **argv);
int main(int argc, char *argv[])
{
int i, err, errs = 0, rank, toterrs;
- int index;
+ int index;
MPI_Request requests[10];
- MPI_Status statuses[10];
+ MPI_Status statuses[10];
MPI_Init(&argc, &argv);
parse_args(argc, argv);
- for (i=0; i < 10; i++) {
- requests[i] = MPI_REQUEST_NULL;
+ for (i = 0; i < 10; i++) {
+ requests[i] = MPI_REQUEST_NULL;
}
/* begin testing */
/* 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 );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
err = MPI_Waitany(10, requests, &index, statuses);
if (err != MPI_SUCCESS) {
- errs++;
- fprintf(stderr, "MPI_Waitany did not return MPI_SUCCESS\n");
+ errs++;
+ fprintf(stderr, "MPI_Waitany did not return MPI_SUCCESS\n");
}
if (index != MPI_UNDEFINED) {
- errs++;
- fprintf(stderr, "MPI_Waitany did not set index to MPI_UNDEFINED\n");
+ errs++;
+ fprintf(stderr, "MPI_Waitany did not set index to MPI_UNDEFINED\n");
}
/* end testing */
-
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL );
- MPI_Comm_rank( MPI_COMM_WORLD, & rank );
- MPI_Allreduce( &errs, &toterrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
+
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Allreduce(&errs, &toterrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
if (rank == 0) {
- if (toterrs) {
- fprintf(stderr, " Found %d errors\n", toterrs);
- }
- else {
- printf(" No Errors\n");
- }
+ if (toterrs) {
+ fprintf(stderr, " Found %d errors\n", toterrs);
+ }
+ else {
+ printf(" No Errors\n");
+ }
}
MPI_Finalize();
return 0;
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;
}
#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.
*/
{
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;
}