2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) Fri Mar 17 2000 */
3 /* no-error.c -- do some MPI calls without any errors */
12 main (int argc, char **argv)
17 char processor_name[128];
25 MPI_Init (&argc, &argv);
26 MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
27 MPI_Comm_rank (MPI_COMM_WORLD, &rank);
28 MPI_Get_processor_name (processor_name, &namelen);
29 printf ("(%d) is alive on %s\n", rank, processor_name);
32 MPI_Barrier (MPI_COMM_WORLD);
34 /* this code is very similar to any_src-waitall-deadlock.c */
35 /* but eliminates the deadlock by using MPI_Waitany... */
36 /* also very similar to no-error-waitall-any_src.c but */
37 /* this code is deterministic; buf0 holds result of */
38 /* memset to 0 and buf1 holds the result of memset to */
39 /* in all three tasks since must match the first Irecv first... */
42 printf ("not enough tasks\n");
46 MPI_Irecv (buf0, buf_size, MPI_INT,
47 MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &reqs[0]);
49 MPI_Irecv (buf1, buf_size, MPI_INT,
50 MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &reqs[1]);
52 MPI_Waitany (2, reqs, &done, &status);
56 MPI_Send (buf1, buf_size, MPI_INT, 1, 1, MPI_COMM_WORLD);
58 MPI_Send (buf0, buf_size, MPI_INT, 2, 2, MPI_COMM_WORLD);
60 MPI_Wait (&reqs[1], &status);
64 memset (buf0, 0, buf_size);
66 MPI_Send (buf0, buf_size, MPI_INT, 0, 0, MPI_COMM_WORLD);
68 MPI_Recv (buf1, buf_size, MPI_INT, 0, 1, MPI_COMM_WORLD, &status);
72 MPI_Recv (buf0, buf_size, MPI_INT, 0, 2, MPI_COMM_WORLD, &status);
74 memset (buf1, 1, buf_size);
76 MPI_Send (buf1, buf_size, MPI_INT, 0, 0, MPI_COMM_WORLD);
79 MPI_Barrier (MPI_COMM_WORLD);
82 printf ("(%d) Finished normally\n", rank);