Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] ISP tests integration
[simgrid.git] / teshsuite / smpi / isp / umpire / type-no-free2.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) Tue Dec 10 2002 */
3
4 /* type-no-free2.c -- create many types, failing to free some */
5
6 #ifndef lint
7 static char *rcsid =
8   "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/type-no-free2.c,v 1.2 2003/01/13 18:31:48 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 /* 10000 breaks umpire due to running out of memory as of 12/12/02... */
15 /* FAILURE IS NOT GRACEFUL AS OF THIS TIME... */
16 #define ITERATIONS                  10
17 #define TYPES_PER_ITERATION          3
18 #define TYPES_LOST_PER_ITERATION     1
19 #define TYPES_TO_COMMIT              1
20
21
22 #include <stdio.h>
23 #include <string.h>
24 #include "mpi.h"
25
26
27 #define buf_size 128
28
29 int
30 main (int argc, char **argv)
31 {
32   int nprocs = -1;
33   int rank = -1;
34   int i, j;
35   char processor_name[128];
36   int namelen = 128;
37   MPI_Datatype newtype[TYPES_PER_ITERATION];
38
39   /* init */
40   MPI_Init (&argc, &argv);
41   MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
42   MPI_Comm_rank (MPI_COMM_WORLD, &rank);
43   MPI_Get_processor_name (processor_name, &namelen);
44   printf ("(%d) is alive on %s\n", rank, processor_name);
45   fflush (stdout);
46
47   MPI_Barrier (MPI_COMM_WORLD);
48
49   for (i = 0; i < ITERATIONS; i++) {
50     for (j = 0; j < TYPES_PER_ITERATION; j++) {
51       MPI_Type_contiguous (128, MPI_INT, &newtype[j]);
52
53       if (j >= TYPES_PER_ITERATION - TYPES_TO_COMMIT) {
54         MPI_Type_commit (&newtype[j]);
55       }
56
57       if (j < TYPES_PER_ITERATION - TYPES_LOST_PER_ITERATION) {
58         MPI_Type_free (&newtype[j]);
59       }
60     }
61
62     if (((i % (ITERATIONS/10)) == 0) && (rank == 0))
63       printf ("iteration %d completed\n", i);
64   }
65
66   MPI_Barrier (MPI_COMM_WORLD);
67
68   printf ("(%d) Finished normally\n", rank);
69   MPI_Finalize ();
70 }
71
72 /* EOF */