Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ignore generated tesh files
[simgrid.git] / teshsuite / smpi / isp / umpire / group-no-error3.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) */
3
4 /* group-no-error3.c -- "correctly" construct many groups and free them */
5
6 #ifndef lint
7 static char *rcsid =
8   "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/group-no-error3.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               100
18
19
20 #include <stdio.h>
21 #include <string.h>
22 #include "mpi.h"
23
24 #define buf_size 128
25
26 int
27 main (int argc, char **argv)
28 {
29   int nprocs = -1;
30   int rank = -1;
31   int i;
32   char processor_name[128];
33   int namelen = 128;
34   MPI_Group worldgroup, newgroup[ITERATIONS];
35
36   /* init */
37   MPI_Init (&argc, &argv);
38   MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
39   MPI_Comm_rank (MPI_COMM_WORLD, &rank);
40   MPI_Get_processor_name (processor_name, &namelen);
41   printf ("(%d) is alive on %s\n", rank, processor_name);
42   fflush (stdout);
43
44   MPI_Comm_group (MPI_COMM_WORLD, &worldgroup);
45
46   MPI_Barrier (MPI_COMM_WORLD);
47
48   for (i = 0; i < ITERATIONS; i++) {
49     /* create groups that don't include the local rank... */
50     MPI_Group_excl (worldgroup, 1, &rank, &newgroup[i]);
51   }
52
53   for (i = 0; i < ITERATIONS; i++) {
54     MPI_Group_free (&newgroup[i]);
55   }
56
57   MPI_Group_free (&worldgroup);
58   MPI_Barrier (MPI_COMM_WORLD);
59   printf ("(%d) Finished normally\n", rank);
60   MPI_Finalize ();
61 }
62
63 /* EOF */