Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Ignore stdout/stderr of the umpire tests
[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   int 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 int j, k;
38   for (i = 0; i < 128; i++)
39     {
40       buf0[i] = i;
41       buf1[i] = 127 - i;
42     }
43
44   MPI_Barrier(MPI_COMM_WORLD);
45
46   switch (rank)
47     {
48     case 0:
49        MPI_Isend (buf0, 128, MPI_INT, 1, tag1, comm, &aReq[0]);
50       MPI_Isend (buf1, 128, MPI_INT, 1, tag2, comm, &aReq[1]);
51       /* do some work here */
52
53       buf0[64] = 1000000;
54
55       MPI_Wait (&aReq[0], &aStatus[0]);
56       MPI_Wait (&aReq[1], &aStatus[1]);
57
58       break;
59
60     case 1:
61       MPI_Irecv (buf0, 128, MPI_INT, 0, tag1, comm, &aReq[0]);
62       MPI_Irecv (buf1, 128, MPI_INT, 0, tag2, comm, &aReq[1]);
63       /* do some work here ... */
64       MPI_Wait (&aReq[0], &aStatus[0]);
65       MPI_Wait (&aReq[1], &aStatus[1]);
66       break;
67
68     default:
69       /* do nothing */
70       break;
71     }
72
73
74   MPI_Barrier(MPI_COMM_WORLD);
75
76   for (i = 0; i < 128; i++)
77     {
78       buf0[i] = i;
79       buf1[i] = 127 - i;
80     }
81   switch (rank)
82     {
83     case 0:
84       MPI_Isend (buf0, 128, MPI_INT, 1, tag1, comm, &aReq[0]);
85       MPI_Isend (buf1, 128, MPI_INT, 1, tag2, comm, &aReq[1]);
86       /* do some work here */
87
88       buf0[64] = 1000000;
89
90       MPI_Waitall (2, aReq, aStatus);
91
92       break;
93
94     case 1:
95       MPI_Irecv (buf0, 128, MPI_INT, 0, tag1, comm, &aReq[0]);
96       MPI_Irecv (buf1, 128, MPI_INT, 0, tag2, comm, &aReq[1]);
97       /* do some work here ... */
98       MPI_Waitall (2, aReq, aStatus);
99       break;
100
101     default:
102       /* do nothing */
103       break;
104     }
105
106   MPI_Finalize ();
107   printf ("(%d) Finished normally\n", rank);
108 }
109
110 /* EOF */