Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Ignore stdout/stderr of the umpire tests
[simgrid.git] / teshsuite / smpi / isp / umpire / group-no-free3.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) */
3
4 /* group-no-free3.c -- construct many groups without freeing some */
5
6 #ifndef lint
7 static char *rcsid =
8   "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/group-no-free3.c,v 1.1 2003/01/13 18:31:48 bronis Exp $";
9 #endif
10
11
12 /* NOTE: Some value of ITERATIONS will imply resource exhaustion */
13 /*       either in Umpire or MPI no matter how things are implemented */
14 /*       the best we can hope for is to fail gracefully... */
15 /* UNKNOWN N breaks umpire due to running out of memory as of 12/20/02... */
16 /* FAILURE IS NOT GRACEFUL AS OF THIS TIME... */
17 #define ITERATIONS                   10
18 #define GROUPS_PER_ITERATION          3
19 #define GROUPS_LOST_PER_ITERATION     1
20
21
22 #include <stdio.h>
23 #include <string.h>
24 #include "mpi.h"
25
26 #define buf_size 128
27
28 int
29 main (int argc, char **argv)
30 {
31   int nprocs = -1;
32   int rank = -1;
33   int i, j;
34   char processor_name[128];
35   int namelen = 128;
36   MPI_Group worldgroup, newgroup[GROUPS_PER_ITERATION];
37
38   /* init */
39   MPI_Init (&argc, &argv);
40   MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
41   MPI_Comm_rank (MPI_COMM_WORLD, &rank);
42   MPI_Get_processor_name (processor_name, &namelen);
43   printf ("(%d) is alive on %s\n", rank, processor_name);
44   fflush (stdout);
45
46   MPI_Comm_group (MPI_COMM_WORLD, &worldgroup);
47
48   MPI_Barrier (MPI_COMM_WORLD);
49
50   for (i = 0; i < ITERATIONS; i++) {
51     for (j = 0; j < GROUPS_PER_ITERATION; j++) {
52       /* create groups that don't include the local rank... */
53       MPI_Group_excl (worldgroup, 1, &rank, &newgroup[j]);
54
55       if (j < GROUPS_PER_ITERATION - GROUPS_LOST_PER_ITERATION) {
56         MPI_Group_free (&newgroup[j]);
57       }
58     }
59   }
60
61   MPI_Group_free (&worldgroup);
62   MPI_Barrier (MPI_COMM_WORLD);
63   printf ("(%d) Finished normally\n", rank);
64   MPI_Finalize ();
65 }
66
67 /* EOF */