Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
2318a9547725a3fa85e24b770c4f7b71031a6370
[simgrid.git] / teshsuite / smpi / isp / umpire / no-error-wait2.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) Fri Mar  17 2000 */
3 /* no-error-wait2.c -- do some MPI calls without any errors */
4 /*    use assignment of handles to confuse address checking */
5
6 #include <stdio.h>
7 #include "mpi.h"
8
9 #define buf_size 128
10
11 int
12 main (int argc, char **argv)
13 {
14   int nprocs = -1;
15   int rank = -1;
16   char processor_name[128];
17   int namelen = 128;
18   int buf0[buf_size];
19   int buf1[buf_size];
20   MPI_Status status;
21   MPI_Request req, req2;
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, 1, 0, MPI_COMM_WORLD, &req);
42
43       req2 = req;
44
45       MPI_Send (buf0, buf_size, MPI_INT, 1, 0, MPI_COMM_WORLD);
46
47       MPI_Wait (&req2, &status, i);
48     }
49   else if (rank == 1)
50     {
51       memset (buf1, 1, buf_size);
52
53       MPI_Irecv (buf0, buf_size, MPI_INT, 0, 0, MPI_COMM_WORLD, &req);
54
55       req2 = req;
56
57       MPI_Wait (&req2, &status, i);
58
59       MPI_Send (buf1, buf_size, MPI_INT, 0, 0, MPI_COMM_WORLD);
60     }
61
62   MPI_Barrier (MPI_COMM_WORLD);
63
64   MPI_Finalize ();
65   printf ("(%d) Finished normally\n", rank);
66 }
67
68 /* EOF */