Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use the right name of an option in the doc
[simgrid.git] / teshsuite / smpi / isp / umpire / comm-deadlock.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-deadlock.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 nc1;
24   int dat = 1234;
25
26   /* init */
27   MPI_Init (&argc, &argv);
28   MPI_Comm_size (comm, &nprocs);
29   MPI_Comm_rank (comm, &rank);
30   MPI_Get_processor_name (processor_name, &namelen);
31   printf ("(%d) is alive on %s\n", rank, processor_name);
32   fflush (stdout);
33
34   MPI_Barrier (comm);
35
36   if (rank == 0)
37     {
38       printf ("Creating first new comm\n");
39     }
40   {
41     int color = rank % 2;
42     int key = 1;
43     int nrank;
44     int nsize;
45     MPI_Comm_split (comm, color, key, &nc1);
46     MPI_Comm_size (nc1, &nsize);
47     MPI_Comm_rank (nc1, &nrank);
48     printf ("world task %d/%d/%d maps to new comm task %d/%d/%d\n",
49             comm, nprocs, rank, nc1, nsize, nrank);
50   }
51
52   MPI_Barrier (comm);
53
54   printf ("Entering deadlock state.....\n");
55
56   if (rank == 1)
57     {
58       MPI_Bcast (&dat, 1, MPI_INT, 0, nc1);
59     }
60   else
61     {
62       MPI_Bcast (&dat, 1, MPI_INT, 0, comm);
63     }
64
65   MPI_Barrier (comm);
66
67   printf ("(%d) Finished normally\n", rank);
68   MPI_Finalize ();
69 }
70
71 /* EOF */