2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) Thu Nov 30 2000 */
3 /* persistent.c -- do some MPI persistent calls */
4 /* including freeing an active request - the effect of which */
5 /* is implementation dependent - usually a detected error */
13 main (int argc, char **argv)
17 char processor_name[128];
21 MPI_Request aReq[2], free_req;
22 MPI_Status aStatus[2];
27 MPI_Init (&argc, &argv);
28 MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
29 MPI_Comm_rank (MPI_COMM_WORLD, &rank);
30 MPI_Get_processor_name (processor_name, &namelen);
31 printf ("(%d) is alive on %s\n", rank, processor_name);
34 MPI_Barrier (MPI_COMM_WORLD);
37 printf ("not enough tasks\n");
41 memset (buf0, 0, buf_size);
43 MPI_Send_init (buf0, buf_size, MPI_INT, 1, 0, MPI_COMM_WORLD, &aReq[0]);
44 MPI_Recv_init (buf1, buf_size, MPI_INT, 1, 0, MPI_COMM_WORLD, &aReq[1]);
49 MPI_Waitall (2, aReq, aStatus);
51 memset (buf0, 1, buf_size);
53 MPI_Startall (2, aReq);
55 /* free an active request... */
57 MPI_Request_free (&free_req);
59 MPI_Waitall (2, aReq, aStatus);
62 memset (buf1, 1, buf_size);
64 MPI_Recv_init (buf0, buf_size, MPI_INT, 0, 0, MPI_COMM_WORLD, &aReq[0]);
65 MPI_Send_init (buf1, buf_size, MPI_INT, 0, 0, MPI_COMM_WORLD, &aReq[1]);
70 MPI_Waitall (2, aReq, aStatus);
72 memset (buf1, 0, buf_size);
74 MPI_Startall (2, aReq);
76 /* free an active request... */
78 MPI_Request_free (&free_req);
80 MPI_Waitall (2, aReq, aStatus);
84 MPI_Barrier (MPI_COMM_WORLD);
86 MPI_Request_free (&aReq[0]);
89 printf ("(%d) Finished normally\n", rank);