Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
first commit to add the mpich-test suite to smpi tesh suite. Obviously all tests...
[simgrid.git] / teshsuite / smpi / mpich-test / pt2pt / exittest.c
1
2 /*
3   A report was made that this program hung on a 2 processor LINUX cluster.
4   We haven't seen that problem, but since this does test whether process 0
5   waits for the other processes to complete before exiting, it is a good
6   test to have.
7  */
8 #include <stdio.h>
9 #include "mpi.h"
10 #define MAX_NUM_PROCS 10
11
12 int main( int argc, char *argv[])
13 {
14   int idx;
15   int num_procs,my_id;
16   int s;
17   int r;
18   MPI_Status status;
19
20   MPI_Init(&argc,&argv);
21   MPI_Comm_size(MPI_COMM_WORLD,&num_procs);
22   MPI_Comm_rank(MPI_COMM_WORLD,&my_id);
23   
24   if (num_procs < 3)
25     {
26     fprintf(stderr, "Need at least 3 processes for this bug\n");
27     MPI_Finalize();
28     return 0;
29     }
30
31 #ifdef DEBUG  
32   fprintf(stderr, "%d Starting ....\n", my_id);
33   fflush(stderr);
34 #endif
35   
36   if (my_id == 1)
37     {
38     idx = 2;
39     s = 333;
40 #ifdef DEBUG
41     fprintf(stdout, "%d start send (%d) to %d\n", my_id, s, idx);
42     fflush(stdout);
43 #endif
44     MPI_Send(&s, 1, MPI_INT, idx, 0, MPI_COMM_WORLD);
45 #ifdef DEBUG
46     fprintf(stdout, "%d finished send to %d\n", my_id, idx);
47     fflush(stdout);
48 #endif
49     }
50   
51   if (my_id == 2)
52     {
53     idx = 1;
54 #ifdef DEBUG
55     fprintf(stdout, "%d start recv from %d\n", my_id, idx);
56     fflush(stdout);
57 #endif
58     MPI_Recv (&r, 1, MPI_INT, idx, 0, MPI_COMM_WORLD, &status );
59 #ifdef DEBUG
60     fprintf(stdout, "%d finished recv (%d) from %d\n", my_id, r, idx);
61     fflush(stdout);
62 #endif
63     }
64
65 #ifdef DBUG  
66   fprintf(stdout, "%d Done ....\n",my_id);
67   fflush(stdout);
68 #endif  
69   MPI_Barrier( MPI_COMM_WORLD );
70   if (my_id == 0) {
71       /* If we reach here, we're done */
72       printf( " No Errors\n" );
73   }
74
75   MPI_Finalize();
76   return 0;
77 }
78