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", i, (long) extent);
52 MPI_Abort(MPI_COMM_WORLD, 1);
54 MTEST_VG_MEM_INIT(bufs[i], extent);
56 buf = (int *) malloc(10 * 30 * sizeof(int));
58 MPI_Barrier(MPI_COMM_WORLD);
61 for (i = 0; i < MAX_MSGS; i++) {
62 MPI_Recv(buf, 10 * 30, MPI_INT, source, i, comm, MPI_STATUS_IGNORE);
65 else if (rank == source) {
66 for (i = 0; i < MAX_MSGS; i++) {
67 MPI_Isend(bufs[i], 1, dtype, dest, i, comm, &req[i]);
69 MPI_Waitall(MAX_MSGS, req, MPI_STATUSES_IGNORE);
72 MPI_Type_free(&dtype);
73 for (i = 0; i < MAX_MSGS; i++) {