Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / teshsuite / smpi / isp / umpire / deadlock-config_blocking.c
1 /* $Header: /usr/gapps/asde/cvs-vault/umpire/tests/deadlock-config.c,v 1.2 2001/09/20 22:27:28 bronis Exp $ */
2
3 #include <stdio.h>
4 #include "mpi.h"
5
6 #define buf_size 32000
7
8 main (int argc, char **argv)
9 {
10   int nprocs = -1;
11   int rank = -1;
12   float data[buf_size];
13   int tag = 30;
14   char processor_name[128];
15   int namelen = buf_size;
16
17   /* init */
18   MPI_Init (&argc, &argv);
19   MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
20   MPI_Comm_rank (MPI_COMM_WORLD, &rank);
21   if (rank == 0)
22     {
23       printf ("WARNING: This test depends on the MPI's eager limit. "
24               "Set it appropriately.\n");
25     }
26   printf ("Initializing (%d of %d)\n", rank, nprocs);
27   MPI_Get_processor_name (processor_name, &namelen);
28   printf ("(%d) is alive on %s\n", rank, processor_name);
29   fflush (stdout);
30   {
31     int dest = (rank == nprocs - 1) ? (0) : (rank + 1);
32     data[0] = rank;
33     MPI_Send (data, buf_size, MPI_FLOAT, dest, tag, MPI_COMM_WORLD);
34     printf ("(%d) sent data %f\n", rank, data[0]);
35     fflush (stdout);
36   }
37   {
38     int src = (rank == 0) ? (nprocs - 1) : (rank - 1);
39     MPI_Status status;
40     MPI_Recv (data, buf_size, MPI_FLOAT, src, tag, MPI_COMM_WORLD, &status);
41     printf ("(%d) got data %f\n", rank, data[0]);
42     fflush (stdout);
43   }
44   MPI_Finalize ();
45   printf ("(%d) Finished normally\n", rank);
46 }
47
48                                  /* EOF */