Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] ISP tests integration
[simgrid.git] / teshsuite / smpi / isp / umpire / collective-misorder.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Jeffrey Vetter (j-vetter@llnl.gov) Mon Nov  1 1999 */
3 /* collective-misorder.c -- do some collective operations (w/ one of them out of order) */
4
5 #ifndef lint
6 static char *rcsid =
7   "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/collective-misorder.c,v 1.2 2000/12/04 19:09:45 bronis Exp $";
8 #endif
9
10 #include <stdio.h>
11 #include <string.h>
12 #include "mpi.h"
13
14 #define buf_size 128
15
16 int
17 main (int argc, char **argv)
18 {
19   int nprocs = -1;
20   int rank = -1;
21   int comm = MPI_COMM_WORLD;
22   char processor_name[128];
23   int namelen = 128;
24   int buf0[buf_size];
25   int buf1[buf_size];
26
27   /* init */
28   MPI_Init (&argc, &argv);
29   MPI_Comm_size (comm, &nprocs);
30   MPI_Comm_rank (comm, &rank);
31   MPI_Get_processor_name (processor_name, &namelen);
32   printf ("(%d) is alive on %s\n", rank, processor_name);
33   fflush (stdout);
34
35   memset (buf0, 0, buf_size);
36   memset (buf1, 1, buf_size);
37
38   MPI_Barrier (comm);
39   MPI_Barrier (comm);
40
41   switch (rank)
42     {
43     case 0:
44       MPI_Bcast (buf0, buf_size, MPI_INT, 1, comm);     /* note that I didn't use root == 0 */
45       MPI_Barrier (comm);
46       break;
47
48     default:
49       MPI_Barrier (comm);
50       MPI_Bcast (buf0, buf_size, MPI_INT, 1, comm);
51       break;
52     }
53   MPI_Finalize ();
54   printf ("(%d) Finished normally\n", rank);
55 }
56
57 /* EOF */