1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2014 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
13 This program is derived from one in the MPICH-1 test suite. It
14 tests a wide variety of basic and derived datatypes.
16 int main( int argc, char **argv)
19 void **inbufs, **outbufs;
20 int *counts, *bytesize, ntype;
22 int rank, np, partner, tag, count;
23 int i, j, k, err, world_rank, errloc;
26 char myname[MPI_MAX_OBJECT_NAME];
29 MTest_Init( &argc, &argv );
32 * Check for -basiconly to select only the simple datatypes
34 for (i=1; i<argc; i++) {
36 if (strcmp( argv[i], "-basiconly" ) == 0) {
37 MTestDatatype2BasicOnly();
41 MTestDatatype2Allocate( &types, &inbufs, &outbufs, &counts, &bytesize,
43 MTestDatatype2Generate( types, inbufs, outbufs, counts, bytesize, &ntype );
45 MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
47 /* Test over a wide range of datatypes and communicators */
50 while (MTestGetIntracomm( &comm, 2 )) {
51 if (comm == MPI_COMM_NULL) continue;
52 MPI_Comm_rank( comm, &rank );
53 MPI_Comm_size( comm, &np );
56 MTestPrintfMsg( 10, "Testing communicator number %s\n",
57 MTestGetIntracommName() );
60 for (j=0; j<ntype; j++) {
61 MPI_Type_get_name( types[j], myname, &mynamelen );
63 MTestPrintfMsg( 10, "Testing type %s\n", myname );
66 MPI_Send( inbufs[j], counts[j], types[j], partner, tag, comm );
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], myname );
83 if (status.MPI_SOURCE != partner) {
85 "Error in source (got %d expected %d) with type %s\n",
86 status.MPI_SOURCE, partner, myname );
89 if ((errloc = MTestDatatype2Check( inbufs[j], outbufs[j],
93 "Error in data with type %s (type %d on %d) at byte %d\n",
94 myname, j, world_rank, errloc - 1 );
95 p1 = (char *)inbufs[j];
96 p2 = (char *)outbufs[j];
98 "Got %x expected %x\n", p1[errloc-1], p2[errloc-1] );
103 MTestFreeComm( &comm );
106 MTestDatatype2Free( types, inbufs, outbufs, counts, bytesize, ntype );
107 MTest_Finalize( err );
109 return MTestReturnValue( err );