7 #if defined(NEEDS_STDLIB_PROTOTYPES)
15 This is similar to a test in allpair.f, but with an expanded range of
16 datatypes and communicators.
19 int main( int argc, char **argv )
22 void **inbufs, **outbufs;
24 int *counts, *bytesize, ntype;
26 int ncomm = 20, rank, np, partner, tag;
27 int i, j, k, err, toterr, world_rank;
28 MPI_Status status, statuses[2];
29 int flag, index, outcount, indices[2];
31 MPI_Request requests[2];
34 MPI_Init( &argc, &argv );
36 AllocateForData( &types, &inbufs, &outbufs, &counts, &bytesize,
38 GenerateData( types, inbufs, outbufs, counts, bytesize, names, &ntype );
40 MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
41 MakeComms( comms, 20, &ncomm, 0 );
43 /* Test over a wide range of datatypes and communicators */
45 for (i=0; i<ncomm; i++) {
46 MPI_Comm_rank( comms[i], &rank );
47 MPI_Comm_size( comms[i], &np );
59 testsome (both may) waitsome (both may)
60 waitall waitsome (must get other, if any)
61 waitsome (outcount = undefined)
62 This test DEPENDS on the handling of null requests, since the several
63 waits/tests may complete everything "early".
65 for (j=0; j<ntype; j++) {
66 if (world_rank == 0 && verbose)
67 fprintf( stdout, "Testing type %s\n", names[j] );
68 /* This test does an irsend between both partners, with
69 a sendrecv after the irecv used to guarentee that the
70 irsend has a matching receive
76 MPIR_PrintDatatypePack( stdout, counts[j], types[j], 0, 0 );
79 for (k=0; k<bytesize[j]; k++)
82 MPI_Irecv(outbufs[j], counts[j], types[j], partner, tag,
83 comms[i], &requests[0] );
85 MPI_Isend( inbufs[j], counts[j], types[j], partner, tag,
86 comms[i], &requests[1] );
88 /* Note that the send may have completed */
89 MPI_Testsome( 1, &requests[0], &outcount, indices, statuses );
91 fprintf( stderr, "MPI_Testsome returned outcount = %d\n",
95 MPI_Testany( 1, &requests[0], &index, &flag, &status );
97 fprintf( stderr, "MPI_Testany returned flag = true\n" );
100 MPI_Sendrecv( MPI_BOTTOM, 0, MPI_INT, partner, ncomm+i,
101 MPI_BOTTOM, 0, MPI_INT, partner, ncomm+i,
103 MPI_Sendrecv( MPI_BOTTOM, 0, MPI_INT, partner, ncomm+i,
104 MPI_BOTTOM, 0, MPI_INT, partner, ncomm+i,
106 /* We EXPECT both to succeed, but they may not */
107 MPI_Testsome( 2, requests, &outcount, indices, statuses );
108 MPI_Waitall( 2, requests, statuses );
110 /* Check the received data */
111 if (CheckDataAndPrint( inbufs[j], outbufs[j], bytesize[j],
116 else if (rank == np - 1) {
120 for (k=0; k<bytesize[j]; k++)
123 MPI_Irecv(outbufs[j], counts[j], types[j], partner, tag,
124 comms[i], &requests[0] );
126 MPI_Sendrecv( MPI_BOTTOM, 0, MPI_INT, partner, ncomm+i,
127 MPI_BOTTOM, 0, MPI_INT, partner, ncomm+i,
130 MPI_Isend( inbufs[j], counts[j], types[j], partner, tag,
131 comms[i], &requests[1] );
133 MPI_Sendrecv( MPI_BOTTOM, 0, MPI_INT, partner, ncomm+i,
134 MPI_BOTTOM, 0, MPI_INT, partner, ncomm+i,
137 MPI_Waitsome( 2, requests, &outcount, indices, statuses );
138 MPI_Waitsome( 2, requests, &outcount, indices, statuses );
139 MPI_Waitsome( 2, requests, &outcount, indices, statuses );
140 if (outcount != MPI_UNDEFINED) {
143 "MPI_Waitsome did not return outcount = MPI_UNDEFINED\n" );
146 if (CheckDataAndPrint( inbufs[j], outbufs[j], bytesize[j],
151 MPI_Waitall(1, &requests[1], &status );
157 fprintf( stderr, "%d errors on %d\n", err, rank );
159 MPI_Allreduce( &err, &toterr, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
160 if (world_rank == 0) {
162 printf( " No Errors\n" );
165 printf (" Found %d errors\n", toterr );
168 FreeDatatypes( types, inbufs, outbufs, counts, bytesize, names, ntype );
169 FreeComms( comms, ncomm );