7 #if defined(NEEDS_STDLIB_PROTOTYPES)
12 /* Nonblocking ready sends
14 This is similar to a test in allpair.f, but with an expanded range of
15 datatypes and communicators.
18 int main( int argc, char **argv )
21 void **inbufs, **outbufs;
23 int *counts, *bytesize, ntype;
25 int ncomm = 20, rank, np, partner, tag;
26 int i, j, k, err, toterr, world_rank, errloc;
27 MPI_Status status, statuses[2];
30 MPI_Request requests[2];
33 MPI_Init( &argc, &argv );
35 AllocateForData( &types, &inbufs, &outbufs, &counts, &bytesize,
37 GenerateData( types, inbufs, outbufs, counts, bytesize, names, &ntype );
39 MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
40 MakeComms( comms, 20, &ncomm, 0 );
42 /* Test over a wide range of datatypes and communicators */
44 for (i=0; i<ncomm; i++) {
45 MPI_Comm_rank( comms[i], &rank );
46 MPI_Comm_size( comms[i], &np );
49 for (j=0; j<ntype; j++) {
50 if (world_rank == 0 && verbose)
51 fprintf( stdout, "Testing type %s\n", names[j] );
52 /* This test does an irsend between both partners, with
53 a sendrecv after the irecv used to guarentee that the
54 irsend has a matching receive
59 MPIR_PrintDatatypePack( stdout, counts[j], types[j], 0, 0 );
62 for (k=0; k<bytesize[j]; k++)
65 MPI_Irecv(outbufs[j], counts[j], types[j], partner, tag,
66 comms[i], &requests[0] );
68 MPI_Sendrecv( MPI_BOTTOM, 0, MPI_INT, partner, ncomm+i,
69 MPI_BOTTOM, 0, MPI_INT, partner, ncomm+i,
72 MPI_Irsend( inbufs[j], counts[j], types[j], partner, tag,
73 comms[i], &requests[1] );
76 MPI_Waitany( 2, requests, &index, &status );
79 /* Always the possiblity that the Irsend is still waiting */
80 MPI_Waitall( 2, requests, statuses );
81 if ((errloc = CheckData( inbufs[j], outbufs[j], bytesize[j] ))) {
84 "Error in data with type %s (type %d on %d) at byte %d\n",
85 names[j], j, world_rank, errloc - 1 );
86 p1 = (char *)inbufs[j];
87 p2 = (char *)outbufs[j];
89 "Got %x expected %x\n", p1[errloc-1], p2[errloc-1] );
92 MPIR_PrintDatatypeUnpack( stderr, counts[j], types[j],
97 else if (rank == np - 1) {
100 for (k=0; k<bytesize[j]; k++)
103 MPI_Irecv(outbufs[j], counts[j], types[j], partner, tag,
104 comms[i], &requests[0] );
106 MPI_Sendrecv( MPI_BOTTOM, 0, MPI_INT, partner, ncomm+i,
107 MPI_BOTTOM, 0, MPI_INT, partner, ncomm+i,
110 /* Wait for irecv to complete */
112 MPI_Test( &requests[0], &flag, &status );
114 if ((errloc = CheckData( inbufs[j], outbufs[j], bytesize[j] ))) {
117 "Error in data with type %s (type %d on %d) at byte %d\n",
118 names[j], j, world_rank, errloc - 1 );
119 p1 = (char *)inbufs[j];
120 p2 = (char *)outbufs[j];
122 "Got %x expected %x\n", p1[errloc-1], p2[errloc-1] );
125 MPIR_PrintDatatypeUnpack( stderr, counts[j], types[j],
130 MPI_Irsend( inbufs[j], counts[j], types[j], partner, tag,
131 comms[i], &requests[1] );
133 MPI_Waitall(1, &requests[1], &status );
139 fprintf( stderr, "%d errors on %d\n", err, rank );
141 MPI_Allreduce( &err, &toterr, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
142 if (world_rank == 0) {
144 printf( " No Errors\n" );
147 printf (" Found %d errors\n", toterr );
150 FreeDatatypes( types, inbufs, outbufs, counts, bytesize, names, ntype );
151 FreeComms( comms, ncomm );