Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ignore generated tesh files
[simgrid.git] / teshsuite / smpi / isp / umpire / dropped-req.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) Wed Nov 29 2000 */
3 /* dropped-req.c -- create a request that's never matched */
4 /* NOTE: THIS TEST ASSUMES THAT MPI LIBRARY USES EAGER SENDS IF */
5 /* BUFFER IS ZERO BYTES; WILL DEADLOCK IN WHILE LOOP IF FALSE */
6
7
8 /* NOTE: Some value of ITERATIONS will imply resource exhaustion */
9 /*       either in Umpire or MPI no matter how things are implemented */
10 /*       the best we can hope for is to fail gracefully... */
11 /* 10000 breaks umpire due to running out of memory as of 12/20/02... */
12 /* FAILURE IS NOT GRACEFUL AS OF THIS TIME... */
13 #define ITERATIONS                10
14
15
16 #include <stdio.h>
17 #include <string.h>
18 #include <unistd.h>
19 #include "mpi.h"
20
21 int
22 main (int argc, char **argv)
23 {
24   int nprocs = -1;
25   int rank = -1;
26   int tag = 31;
27   int i;
28   MPI_Comm comm = MPI_COMM_WORLD;
29   char processor_name[128];
30   int namelen = 128;
31   MPI_Request req;
32   MPI_Status status;
33
34   /* init */
35   MPI_Init (&argc, &argv);
36   MPI_Comm_size (comm, &nprocs);
37   MPI_Comm_rank (comm, &rank);
38   MPI_Get_processor_name (processor_name, &namelen);
39   printf ("(%d) is alive on %s\n", rank, processor_name);
40   fflush (stdout);
41
42   MPI_Barrier(comm);
43
44   /* 0 sends task nprocs-1 a message that is never received */
45   if (rank == 0) {
46     for (i = 0; i < ITERATIONS; i++) {
47       int flag = 0;
48       MPI_Isend (&tag, 0, MPI_BYTE, nprocs - 1, tag, comm, &req);
49
50       while (!flag)
51         MPI_Test (&req, &flag, &status);
52     }
53   }
54
55  MPI_Finalize ();
56   printf ("(%d) Finished normally\n", rank);
57 }
58
59 /* EOF */