- 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);