Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MC: complete workaround in the error msg seen on modern systems
[simgrid.git] / teshsuite / smpi / isp / umpire / comm-dup-no-free2.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) Fri Dec 20 2002 */
3
4 /* comm-dup-no-free2.c - leak many communicators created with comm dup */
5
6 #ifndef lint
7 static char *rcsid =
8   "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/comm-dup-no-free2.c,v 1.1 2003/01/13 18:31:47 bronis Exp $";
9 #endif
10
11 /* NOTE: Some value of ITERATIONS will imply resource exhaustion */
12 /*       either in Umpire or MPI no matter how things are implemented */
13 /*       the best we can hope for is to fail gracefully... */
14 /* Approximately 4100 gets "ERROR: 0032-160 Too many communicators" */
15 /* with IBM's MPI (AIX 5.1.0, PSSP 3.4) as of 1/13/03... */
16 /* Umpire failure is graceful - comm creates are identified... */
17 /* UNKNOWN N breaks umpire due to running out of memory as of 1/13/03... */
18 /* UMPIRE FAILURE IS NOT GRACEFUL AS OF THIS TIME IN THIS CASE... */
19 #define ITERATIONS               10
20 #define COMMS_PER_ITERATION          3
21 #define COMMS_LOST_PER_ITERATION     1
22
23
24 #include <stdio.h>
25 #include <string.h>
26 #include "mpi.h"
27
28 #define buf_size 128
29
30 int
31 main (int argc, char **argv)
32 {
33   int nprocs = -1;
34   int rank = -1;
35   int i, j;
36   char processor_name[128];
37   int namelen = 128;
38   MPI_Comm newcomm[COMMS_PER_ITERATION];
39
40   /* init */
41   MPI_Init (&argc, &argv);
42   MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
43   MPI_Comm_rank (MPI_COMM_WORLD, &rank);
44   MPI_Get_processor_name (processor_name, &namelen);
45   printf ("(%d) is alive on %s\n", rank, processor_name);
46   fflush (stdout);
47
48   MPI_Barrier (MPI_COMM_WORLD);
49
50   for (i = 0; i < ITERATIONS; i++) {
51     for (j = 0; j < COMMS_PER_ITERATION; j++) {
52       MPI_Comm_dup (MPI_COMM_WORLD, &newcomm[j]);
53
54       MPI_Barrier (newcomm[j]);
55
56       if (j < COMMS_PER_ITERATION - COMMS_LOST_PER_ITERATION) {
57         MPI_Comm_free (&newcomm[j]);
58       }
59     }
60   }
61
62   MPI_Barrier (MPI_COMM_WORLD);
63
64   printf ("(%d) Finished normally\n", rank);
65   MPI_Finalize ();
66 }
67
68 /* EOF */