2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) Thu Nov 30 2000 */
3 /* persistent3.c -- do some MPI persistent calls */
4 /* including freeing an active request - the effect of which */
5 /* is implementation dependent - usually a detected error */
6 /* in this test, the error is made in only task rank 1... */
14 main (int argc, char **argv)
18 char processor_name[128];
22 MPI_Request aReq[2], free_req;
23 MPI_Status aStatus[2];
28 MPI_Init (&argc, &argv);
29 MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
30 MPI_Comm_rank (MPI_COMM_WORLD, &rank);
31 MPI_Get_processor_name (processor_name, &namelen);
32 printf ("(%d) is alive on %s\n", rank, processor_name);
35 MPI_Barrier (MPI_COMM_WORLD);
38 /* use at least 3 tasks so there is one non-mgr without error... */
39 printf ("not enough tasks\n");
43 memset (buf0, 0, buf_size);
45 MPI_Send_init (buf0, buf_size, MPI_INT, 1, 0, MPI_COMM_WORLD, &aReq[0]);
46 MPI_Recv_init (buf1, buf_size, MPI_INT, 1, 0, MPI_COMM_WORLD, &aReq[1]);
51 MPI_Waitall (2, aReq, aStatus);
53 memset (buf0, 1, buf_size);
55 MPI_Startall (2, aReq);
57 MPI_Waitall (2, aReq, aStatus);
60 memset (buf1, 1, buf_size);
62 MPI_Recv_init (buf0, buf_size, MPI_INT, 0, 0, MPI_COMM_WORLD, &aReq[0]);
63 MPI_Send_init (buf1, buf_size, MPI_INT, 0, 0, MPI_COMM_WORLD, &aReq[1]);
68 MPI_Waitall (2, aReq, aStatus);
70 memset (buf1, 0, buf_size);
72 MPI_Startall (2, aReq);
74 /* free an active request... */
76 MPI_Request_free (&free_req);
78 MPI_Waitall (2, aReq, aStatus);
82 MPI_Barrier (MPI_COMM_WORLD);
84 MPI_Request_free (&aReq[0]);
87 printf ("(%d) Finished normally\n", rank);