7 #if defined(NEEDS_STDLIB_PROTOTYPES)
12 /* Nonblocking ready persistent sends
14 This is similar to a test in allpair.f, but with an expanded range of
15 datatypes and communicators.
17 This is like irsend.c, but with multiple starts of the same persistent
21 int main( int argc, char **argv )
24 void **inbufs, **outbufs;
26 int *counts, *bytesize, ntype;
28 int ncomm = 20, rank, np, partner, tag;
29 int i, j, k, err, toterr, world_rank, errloc;
33 MPI_Request requests[2];
37 MPI_Init( &argc, &argv );
39 AllocateForData( &types, &inbufs, &outbufs, &counts, &bytesize,
41 GenerateData( types, inbufs, outbufs, counts, bytesize, names, &ntype );
43 MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
44 MakeComms( comms, 20, &ncomm, 0 );
46 /* Test over a wide range of datatypes and communicators */
48 for (i=0; i<ncomm; i++) {
49 MPI_Comm_rank( comms[i], &rank );
50 MPI_Comm_size( comms[i], &np );
53 for (j=0; j<ntype; j++) {
54 if (world_rank == 0 && verbose)
55 fprintf( stdout, "Testing type %s\n", names[j] );
56 /* This test does an irsend between both partners, with
57 a sendrecv after the irecv used to guarentee that the
58 irsend has a matching receive
63 MPIR_PrintDatatypePack( stdout, counts[j], types[j], 0, 0 );
66 for (k=0; k<bytesize[j]; k++)
69 MPI_Recv_init(outbufs[j], counts[j], types[j], partner, tag,
70 comms[i], &requests[0] );
71 MPI_Rsend_init( inbufs[j], counts[j], types[j], partner, tag,
72 comms[i], &requests[1] );
74 for (mcnt=0; mcnt<10; mcnt++) {
75 MPI_Start( &requests[0] );
76 MPI_Sendrecv( MPI_BOTTOM, 0, MPI_INT, partner, ncomm+i,
77 MPI_BOTTOM, 0, MPI_INT, partner, ncomm+i,
79 MPI_Start( &requests[1] );
81 MPI_Waitany( 2, requests, &index, &status );
84 if ((errloc = CheckData( inbufs[j], outbufs[j],
88 "Error in data with type %s (type %d on %d) at byte %d in %dth test\n",
89 names[j], j, world_rank, errloc - 1, mcnt );
90 p1 = (char *)inbufs[j];
91 p2 = (char *)outbufs[j];
93 "Got %x expected %x\n", p1[errloc-1], p2[errloc-1] );
96 MPIR_PrintDatatypeUnpack( stderr, counts[j], types[j],
100 MPI_Waitall(1, &requests[1], &status );
102 MPI_Request_free( &requests[0] );
103 MPI_Request_free( &requests[1] );
105 else if (rank == np - 1) {
108 for (k=0; k<bytesize[j]; k++)
111 MPI_Recv_init(outbufs[j], counts[j], types[j], partner, tag,
112 comms[i], &requests[0] );
113 MPI_Rsend_init( inbufs[j], counts[j], types[j], partner, tag,
114 comms[i], &requests[1] );
115 for (mcnt=0; mcnt<10; mcnt++) {
116 MPI_Start( &requests[0] );
117 MPI_Sendrecv( MPI_BOTTOM, 0, MPI_INT, partner, ncomm+i,
118 MPI_BOTTOM, 0, MPI_INT, partner, ncomm+i,
120 MPI_Start( &requests[1] );
121 /* Wait for irecv to complete */
123 MPI_Test( &requests[0], &flag, &status );
125 if ((errloc = CheckData( inbufs[j], outbufs[j],
129 "Error in data with type %s (type %d on %d) at byte %d\n",
130 names[j], j, world_rank, errloc - 1 );
131 p1 = (char *)inbufs[j];
132 p2 = (char *)outbufs[j];
134 "Got %x expected %x\n", p1[errloc-1], p2[errloc-1] );
137 MPIR_PrintDatatypeUnpack( stderr, counts[j], types[j],
142 MPI_Waitall(1, &requests[1], &status );
144 MPI_Request_free( &requests[0] );
145 MPI_Request_free( &requests[1] );
151 fprintf( stderr, "%d errors on %d\n", err, rank );
153 MPI_Allreduce( &err, &toterr, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
154 if (world_rank == 0) {
156 printf( " No Errors\n" );
159 printf (" Found %d errors\n", toterr );
162 FreeDatatypes( types, inbufs, outbufs, counts, bytesize, names, ntype );
163 FreeComms( comms, ncomm );