9 This program is from mpich/tsuite/pt2pt and should be changed there only.
10 It needs gcomm and dtype from mpich/tsuite, and can be run with
11 any number of processes > 1.
13 int main( int argc, char **argv)
16 void **inbufs, **outbufs;
18 int *counts, *bytesize, ntype;
20 int ncomm = 20, rank, np, partner, tag, count;
21 int i, j, k, err, toterr, world_rank, errloc;
25 MPI_Init( &argc, &argv );
28 * Check for -basiconly to select only the simple datatypes
30 for (i=1; i<argc; i++) {
32 if (strcmp( argv[i], "-basiconly" ) == 0) {
35 else if (strcmp( argv[i], "-verbose" ) == 0) {
40 AllocateForData( &types, &inbufs, &outbufs, &counts, &bytesize,
42 GenerateData( types, inbufs, outbufs, counts, bytesize, names, &ntype );
44 MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
45 MakeComms( comms, 20, &ncomm, 0 );
47 /* Test over a wide range of datatypes and communicators */
49 for (i=0; i<ncomm; i++) {
50 if (comms[i] == MPI_COMM_NULL) continue;
51 MPI_Comm_rank( comms[i], &rank );
52 MPI_Comm_size( comms[i], &np );
54 if (world_rank == 0 && verbose)
55 fprintf( stdout, "Testing communicator number %d\n", i );
58 for (j=0; j<ntype; j++) {
59 if (world_rank == 0 && verbose)
60 fprintf( stdout, "Testing type %s\n", names[j] );
64 MPIR_PrintDatatypePack( stdout, counts[j], types[j], 0, 0 );
66 MPI_Send( inbufs[j], counts[j], types[j], partner, tag, comms[i] );
68 else if (rank == np-1) {
71 for (k=0; k<bytesize[j]; k++)
73 MPI_Recv( outbufs[j], counts[j], types[j], partner, tag,
76 MPI_Get_count( &status, types[j], &count );
77 if (count != counts[j]) {
79 "Error in counts (got %d expected %d) with type %s\n",
80 count, counts[j], names[j] );
83 if (status.MPI_SOURCE != partner) {
85 "Error in source (got %d expected %d) with type %s\n",
86 status.MPI_SOURCE, partner, names[j] );
89 if ((errloc = CheckData( inbufs[j], outbufs[j], bytesize[j] ))) {
92 "Error in data with type %s (type %d on %d) at byte %d\n",
93 names[j], j, world_rank, errloc - 1 );
94 p1 = (char *)inbufs[j];
95 p2 = (char *)outbufs[j];
97 "Got %x expected %x\n", p1[errloc-1], p2[errloc-1] );
100 MPIR_PrintDatatypeUnpack( stderr, counts[j], types[j],
108 fprintf( stderr, "%d errors on %d\n", err, rank );
110 MPI_Allreduce( &err, &toterr, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
111 if (world_rank == 0) {
113 printf( " No Errors\n" );
116 printf (" Found %d errors\n", toterr );
119 FreeDatatypes( types, inbufs, outbufs, counts, bytesize, names, ntype );
120 FreeComms( comms, ncomm );