2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) Wed Jan 22, 2003 */
3 /* partial-recv-persistent.c -- do persistent ops w/oversized recv bufs */
7 "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/partial-recv-persistent.c,v 1.1 2003/05/17 11:05:31 bronis Exp $";
20 main (int argc, char **argv)
24 int comm = MPI_COMM_WORLD;
25 char processor_name[128];
27 int buf[BUF_SIZE * 2 + SLOP];
30 MPI_Status aStatus[2];
33 MPI_Init (&argc, &argv);
34 MPI_Comm_size (comm, &nprocs);
35 MPI_Comm_rank (comm, &rank);
36 MPI_Get_processor_name (processor_name, &namelen);
37 printf ("(%d) is alive on %s\n", rank, processor_name);
41 /* set up persistent sends... */
42 MPI_Send_init (buf, BUF_SIZE, MPI_INT, 1, 0, comm, &aReq[0]);
43 MPI_Send_init (&buf[BUF_SIZE], BUF_SIZE, MPI_INT, 1, 1, comm, &aReq[1]);
45 /* initialize the send buffers */
46 for (k = 0; k < BUF_SIZE; k++) {
48 buf[BUF_SIZE + k] = BUF_SIZE - 1 - k;
52 /* set up the persistent receives... */
53 MPI_Recv_init (buf, BUF_SIZE, MPI_INT, 0, 0, comm, &aReq[0]);
54 MPI_Recv_init (&buf[BUF_SIZE],BUF_SIZE+SLOP,MPI_INT,0,1,comm,&aReq[1]);
57 for (k = 0; k < 4; k++) {
59 /* zero out all of the receive buffers */
60 bzero (buf, sizeof(int) * BUF_SIZE * 2 + SLOP);
63 /* start the persistent requests... */
66 MPI_Startall (2, aReq);
73 MPI_Barrier(MPI_COMM_WORLD);
75 /* complete the requests */
78 MPI_Waitall (2, aReq, aStatus);
84 MPI_Testall (2, aReq, &flag, aStatus);
89 /* Barrier to ensure receives are posted for rsends... */
90 MPI_Barrier(MPI_COMM_WORLD);
94 MPI_Barrier(MPI_COMM_WORLD);
97 /* free the persistent requests */
98 MPI_Request_free (&aReq[0]);
99 MPI_Request_free (&aReq[1]);
103 printf ("(%d) Finished normally\n", rank);