1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2006 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
12 static char MTEST_Descrip[] = "Test of a large number of derived-datatype messages eagerly, with no preposted receive so that an MPI implementation may have to queue up messages on the sending side";
17 int main( int argc, char *argv[] )
20 int rank, size, dest, source;
23 int *buf, *bufs[MAX_MSGS];
26 MPI_Request req[MAX_MSGS];
28 MTest_Init( &argc, &argv );
30 comm = MPI_COMM_WORLD;
31 MPI_Comm_rank( comm, &rank );
32 MPI_Comm_size( comm, &size );
36 /* Setup by creating a blocked datatype that is likely to be processed
37 in a piecemeal fashion */
38 for (i=0; i<30; i++) {
42 /* 30 blocks of size 10 */
43 MPI_Type_create_indexed_block( 30, 10, indices, MPI_INT, &dtype );
44 MPI_Type_commit( &dtype );
46 /* Create the corresponding message buffers */
47 MPI_Type_extent( dtype, &extent );
48 for (i=0; i<MAX_MSGS; i++) {
49 bufs[i] = (int *)malloc( extent );
51 fprintf( stderr, "Unable to allocate buffer %d of size %ld\n",
53 MPI_Abort( MPI_COMM_WORLD, 1 );
57 buf = (int *)malloc( 10 * 30 * sizeof(int) );
59 MPI_Barrier( MPI_COMM_WORLD );
62 for (i=0; i<MAX_MSGS; i++) {
63 MPI_Recv( buf, 10*30, MPI_INT, source, i, comm,
67 else if (rank == source ) {
68 for (i=0; i<MAX_MSGS; i++) {
69 MPI_Isend( bufs[i], 1, dtype, dest, i, comm, &req[i] );
71 MPI_Waitall( MAX_MSGS, req, MPI_STATUSES_IGNORE );
74 MPI_Type_free( &dtype );
75 MTest_Finalize( errs );