Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into fix/execute_benched
[simgrid.git] / teshsuite / smpi / isp / umpire / change-send-buffer.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Jeffrey Vetter (j-vetter@llnl.gov) Mon Nov  1 1999 */
3 /* lost-request.c -- overwrite a request and essentially lose a synch point */
4
5 #ifndef lint
6 static char *rcsid =
7   "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/change-send-buffer.c,v 1.3 2002/07/30 21:34:42 bronis Exp $";
8 #endif
9
10 #include <stdio.h>
11 #include <string.h>
12 #include "mpi.h"
13
14 int
15 main (int argc, char **argv)
16 {
17   int nprocs = -1;
18   int rank = -1;
19   int tag1 = 0;
20   int tag2 = 0;
21   MPI_Comm comm = MPI_COMM_WORLD;
22   char processor_name[128];
23   int namelen = 128;
24   int buf0[128];
25   int buf1[128];
26   int i;
27   MPI_Request aReq[2];
28   MPI_Status aStatus[2];
29
30   /* init */
31   MPI_Init (&argc, &argv);
32   MPI_Comm_size (comm, &nprocs);
33   MPI_Comm_rank (comm, &rank);
34   MPI_Get_processor_name (processor_name, &namelen);
35   printf ("(%d) is alive on %s\n", rank, processor_name);
36   fflush (stdout);
37   for (i = 0; i < 128; i++)
38     {
39       buf0[i] = i;
40       buf1[i] = 127 - i;
41     }
42
43   MPI_Barrier(MPI_COMM_WORLD);
44
45   switch (rank)
46     {
47     case 0:
48        MPI_Isend (buf0, 128, MPI_INT, 1, tag1, comm, &aReq[0]);
49       MPI_Isend (buf1, 128, MPI_INT, 1, tag2, comm, &aReq[1]);
50       /* do some work here */
51
52       buf0[64] = 1000000;
53
54       MPI_Wait (&aReq[0], &aStatus[0]);
55       MPI_Wait (&aReq[1], &aStatus[1]);
56
57       break;
58
59     case 1:
60       MPI_Irecv (buf0, 128, MPI_INT, 0, tag1, comm, &aReq[0]);
61       MPI_Irecv (buf1, 128, MPI_INT, 0, tag2, comm, &aReq[1]);
62       /* do some work here ... */
63       MPI_Wait (&aReq[0], &aStatus[0]);
64       MPI_Wait (&aReq[1], &aStatus[1]);
65       break;
66
67     default:
68       /* do nothing */
69       break;
70     }
71
72
73   MPI_Barrier(MPI_COMM_WORLD);
74
75   for (i = 0; i < 128; i++)
76     {
77       buf0[i] = i;
78       buf1[i] = 127 - i;
79     }
80   switch (rank)
81     {
82     case 0:
83       MPI_Isend (buf0, 128, MPI_INT, 1, tag1, comm, &aReq[0]);
84       MPI_Isend (buf1, 128, MPI_INT, 1, tag2, comm, &aReq[1]);
85       /* do some work here */
86
87       buf0[64] = 1000000;
88
89       MPI_Waitall (2, aReq, aStatus);
90
91       break;
92
93     case 1:
94       MPI_Irecv (buf0, 128, MPI_INT, 0, tag1, comm, &aReq[0]);
95       MPI_Irecv (buf1, 128, MPI_INT, 0, tag2, comm, &aReq[1]);
96       /* do some work here ... */
97       MPI_Waitall (2, aReq, aStatus);
98       break;
99
100     default:
101       /* do nothing */
102       break;
103     }
104
105   MPI_Finalize ();
106   printf ("(%d) Finished normally\n", rank);
107 }
108
109 /* EOF */