Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Ignore stdout/stderr of the umpire tests
[simgrid.git] / teshsuite / smpi / isp / umpire / comm-simple.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Jeffrey Vetter (vetter3@llnl.gov) Thu Feb 24 2000 */
3
4 #ifndef lint
5 static char *rcsid =
6   "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/comm-simple.c,v 1.2 2000/12/04 19:09:45 bronis Exp $";
7 #endif
8
9 #include <stdio.h>
10 #include <string.h>
11 #include "mpi.h"
12
13 #define buf_size 128
14
15 int
16 main (int argc, char **argv)
17 {
18   int nprocs = -1;
19   int rank = -1;
20   int comm = MPI_COMM_WORLD;
21   char processor_name[128];
22   int namelen = 128;
23   MPI_Comm newcomm;
24
25   /* init */
26   MPI_Init (&argc, &argv);
27   MPI_Comm_size (comm, &nprocs);
28   MPI_Comm_rank (comm, &rank);
29   MPI_Get_processor_name (processor_name, &namelen);
30   printf ("(%d) is alive on %s\n", rank, processor_name);
31   fflush (stdout);
32
33   printf ("WARNING: doesn't really deadlock yet! work-in-progress.\n");
34
35   MPI_Barrier (comm);
36
37   {
38     int color = rank % 2;
39     int key = 1;
40     int nrank;
41     int nsize;
42     int dat = 0;
43
44     MPI_Comm_split (comm, color, key, &newcomm);
45
46     MPI_Comm_size (newcomm, &nsize);
47     MPI_Comm_rank (newcomm, &nrank);
48     printf ("world task %d/%d/%d maps to new comm task %d/%d/%d\n",
49             comm, nprocs, rank, newcomm, nsize, nrank);
50
51     if (nrank == 0)
52       {
53         dat = 1000 + color;
54       }
55
56     MPI_Bcast (&dat, 1, MPI_INT, 0, newcomm);
57
58     printf ("world task %d/%d/%d maps to new comm task %d/%d/%d --> %d\n",
59             comm, nprocs, rank, newcomm, nsize, nrank, dat);
60   }
61
62   MPI_Barrier (comm);
63
64   printf ("(%d) Finished normally\n", rank);
65   MPI_Finalize ();
66 }
67
68 /* EOF */