Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ignore generated tesh files
[simgrid.git] / teshsuite / smpi / isp / umpire / any_src-wait-deadlock2.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   int i;
20   MPI_Status status;
21   MPI_Request req;
22
23   /* init */
24   MPI_Init (&argc, &argv);
25   MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
26   MPI_Comm_rank (MPI_COMM_WORLD, &rank);
27   MPI_Get_processor_name (processor_name, &namelen);
28   printf ("(%d) is alive on %s\n", rank, processor_name);
29   fflush (stdout);
30
31   MPI_Barrier (MPI_COMM_WORLD);
32
33   if (nprocs < 2)
34     {
35       printf ("not enough tasks\n");
36     }
37   else if (rank == 0)
38     {
39       memset (buf0, 0, buf_size);
40
41       MPI_Irecv (buf1, buf_size, MPI_INT, 
42                  MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &req);
43       printf("Proc 0:  Request number - %d\n",req);
44       
45       MPI_Send (buf0, buf_size, MPI_INT, 1, 0, MPI_COMM_WORLD);
46         
47       MPI_Recv (buf0, buf_size, MPI_INT, 1, 0, MPI_COMM_WORLD, &status);
48
49       MPI_Send (buf0, buf_size, MPI_INT, 1, 0, MPI_COMM_WORLD);
50
51       MPI_Wait (&req, &status);
52       printf("Proc 0:  Request number after wait test- %d\n",req);
53     }
54   else if (rank == 1)
55     {
56       memset (buf1, 1, buf_size);
57
58       MPI_Irecv (buf1, buf_size, MPI_INT, 
59                  MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &req);
60       printf("Proc 1:  Request number - %d\n",req);
61
62       MPI_Send (buf1, buf_size, MPI_INT, 0, 0, MPI_COMM_WORLD);
63
64       MPI_Recv (buf0, buf_size, MPI_INT, 0, 0, MPI_COMM_WORLD, &status);
65
66       MPI_Send (buf1, buf_size, MPI_INT, 0, 0, MPI_COMM_WORLD);
67
68       MPI_Wait (&req, &status);
69       printf("Proc 1:  Request number after wait test- %d\n",req);
70     }
71
72   MPI_Barrier (MPI_COMM_WORLD);
73
74   MPI_Finalize ();
75   printf ("(%d) Finished normally\n", rank);
76 }
77
78 /* EOF */