Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'actor-yield' of github.com:Takishipp/simgrid into actor-yield
[simgrid.git] / teshsuite / smpi / isp / umpire / wait-deadlock.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) Fri Mar  17 2000 */
3 /* no-error.c -- do some MPI calls without any errors */
4
5 #include <stdio.h>
6 #include "mpi.h"
7
8 #define buf_size 128
9
10 int
11 main (int argc, char **argv)
12 {
13   int nprocs = -1;
14   int rank = -1;
15   char processor_name[128];
16   int namelen = 128;
17   int buf0[buf_size];
18   int buf1[buf_size];
19   MPI_Status status;
20   MPI_Request req;
21
22   /* init */
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);
28   fflush (stdout);
29   MPI_Barrier (MPI_COMM_WORLD);
30
31   if (nprocs < 2)
32     {
33       printf ("not enough tasks\n");
34     }
35   else if (rank == 0)
36     {
37       memset (buf0, 0, buf_size);
38
39       MPI_Irecv (buf1, buf_size, MPI_INT, 1, 0, MPI_COMM_WORLD, &req);
40
41       MPI_Wait (&req, &status);
42
43       MPI_Send (buf0, buf_size, MPI_INT, 1, 0, MPI_COMM_WORLD);
44     }
45   else if (rank == 1)
46     {
47       memset (buf1, 1, buf_size);
48
49       MPI_Irecv (buf0, buf_size, MPI_INT, 0, 0, MPI_COMM_WORLD, &req);
50
51       MPI_Wait (&req, &status);
52
53       MPI_Send (buf1, buf_size, MPI_INT, 0, 0, MPI_COMM_WORLD);
54     }
55
56   MPI_Barrier (MPI_COMM_WORLD);
57
58   MPI_Finalize ();
59   printf ("(%d) Finished normally\n", rank);
60 }
61
62 /* EOF */