2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) Fri Mar 17 2000 */
3 /* no-error.c -- do some MPI calls without any errors */
11 main (int argc, char **argv)
15 char processor_name[128];
19 MPI_Status statuses[2];
23 MPI_Init (&argc, &argv);
24 MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
25 MPI_Comm_rank (MPI_COMM_WORLD, &rank);
26 MPI_Get_processor_name (processor_name, &namelen);
27 printf ("(%d) is alive on %s\n", rank, processor_name);
30 MPI_Barrier (MPI_COMM_WORLD);
32 /* this code is very similar to no-error-waitall-any_src.c */
33 /* but deadlocks since task 2's send and recv are inverted... */
36 printf ("not enough tasks\n");
40 MPI_Irecv (buf0, buf_size, MPI_INT,
41 MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &reqs[0]);
43 MPI_Irecv (buf1, buf_size, MPI_INT,
44 MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &reqs[1]);
46 MPI_Waitall (2, reqs, statuses);
48 MPI_Send (buf1, buf_size, MPI_INT, 1, 1, MPI_COMM_WORLD);
52 memset (buf0, 0, buf_size*sizeof(int));
54 MPI_Isend (buf0, buf_size, MPI_INT, 0, 0, MPI_COMM_WORLD, &reqs[0]);
56 MPI_Isend (buf0, buf_size, MPI_INT, 2, 1, MPI_COMM_WORLD, &reqs[1]);
58 MPI_Wait (reqs, statuses);
60 MPI_Send (buf0, buf_size, MPI_INT, 0, 0, MPI_COMM_WORLD);
62 MPI_Recv (buf1, buf_size, MPI_INT, 0, 1, MPI_COMM_WORLD, statuses);
64 MPI_Wait (&reqs[1], statuses);
70 MPI_Recv (buf1, buf_size, MPI_INT, 1, 1, MPI_COMM_WORLD, statuses);
73 MPI_Barrier (MPI_COMM_WORLD);
76 printf ("(%d) Finished normally\n", rank);