Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reactivate an umpire test, once disabled in 56fefe1bf81ca.
[simgrid.git] / teshsuite / smpi / isp / umpire / no-error-vector-isend.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov)  */
3 /* no-error-vector-isend.c - use isend with vector type; touch holes */
4
5 #ifndef lint
6 static char *rcsid =
7   "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/no-error-vector-isend.c,v 1.1 2002/06/07 20:41:22 bronis Exp $";
8 #endif
9
10 #include <stdio.h>
11 #include <string.h>
12 #include <assert.h>
13 #include "mpi.h"
14
15 #define buf_size 128
16
17 int
18 main (int argc, char **argv)
19 {
20   int nprocs = -1;
21   int rank = -1;
22   MPI_Comm comm = MPI_COMM_WORLD;
23   char processor_name[128];
24   int namelen = 128;
25   int buf[buf_size];
26   int i;
27   MPI_Request req;
28   MPI_Status status;
29   MPI_Datatype strided_type;
30
31   /* init */
32   MPI_Init (&argc, &argv);
33   MPI_Comm_size (comm, &nprocs);
34   MPI_Comm_rank (comm, &rank);
35   MPI_Get_processor_name (processor_name, &namelen);
36   printf ("(%d) is alive on %s\n", rank, processor_name);
37   fflush (stdout);
38
39   MPI_Type_vector (buf_size/2, 1, 2, MPI_INT, &strided_type);
40   MPI_Type_commit (&strided_type);
41
42   MPI_Barrier(MPI_COMM_WORLD);
43
44   if (rank == 0) {
45     for (i = 0; i < buf_size; i = i + 2)
46       buf[i] = i;
47
48     MPI_Isend (&buf[rank], 1, strided_type, (rank + 1) % 2, 0, comm, &req);
49
50     for (i = 1; i < buf_size; i = i + 2)
51       buf[i] = i;
52
53     MPI_Wait (&req, &status);
54
55     for (i = 0; i < buf_size; i++)
56       assert (buf[i] == i);
57   }
58   else if (rank == 1) {
59     for (i = 1; i < buf_size; i = i + 2)
60       buf[i] = i;
61
62     MPI_Recv (&buf[(rank + 1) % 2], 1,
63               strided_type, (rank + 1) % 2, 0, comm, &status);
64
65     for (i = 0; i < buf_size; i++)
66       assert (buf[i] == i);
67   }
68
69   MPI_Barrier(MPI_COMM_WORLD);
70
71   MPI_Type_free (&strided_type);
72
73   MPI_Finalize ();
74   printf ("(%d) Finished normally\n", rank);
75 }
76
77 /* EOF */