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 / env / aborttest.c
1 #include "mpi.h"
2 /* This  simple test checks that MPI_Abort kills all processes 
3  * There are two interesting cases:
4  * masternode == 0
5  * masternode != 0
6  */
7 int main( int argc, char **argv )
8 {
9   int node, size, i;
10   int masternode = 0;
11
12   MPI_Init(&argc, &argv);
13
14   MPI_Comm_rank(MPI_COMM_WORLD, &node);
15   MPI_Comm_size(MPI_COMM_WORLD, &size);
16
17   /* Check for -altmaster */
18   for (i=1; i<argc; i++) {
19       if (argv[i] && strcmp( "-altmaster", argv[i] ) == 0) {
20           masternode = size-1;
21       }
22   }
23
24   if(node == masternode) {
25     MPI_Abort(MPI_COMM_WORLD, 99);
26   }
27   else {
28     /* barrier will hang since masternode never calls */
29     MPI_Barrier(MPI_COMM_WORLD);
30   }
31
32   MPI_Finalize();
33   return 0;
34 }