Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix [#17799] : have mpi_group_range_incl and mpi_group_range_excl better test some...
[simgrid.git] / teshsuite / smpi / mpich3-test / comm / cmsplit.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2003 by Argonne National Laboratory.
5  *      See COPYRIGHT in top-level directory.
6  */
7 #include "mpi.h"
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include "mpitest.h"
11
12 /*
13 static char MTEST_Descrip[] = "Test comm split";
14 */
15
16 int main( int argc, char *argv[] )
17 {
18     int errs = 0;
19     int rank, size, color, srank;
20     MPI_Comm      comm, scomm;
21
22     MTest_Init( &argc, &argv );
23
24     MPI_Comm_dup( MPI_COMM_WORLD, &comm );
25
26     MPI_Comm_rank( comm, &rank );
27     MPI_Comm_size( comm, &size );
28
29     if (size < 4) {
30         fprintf( stderr, "This test requires at least four processes." );
31         MPI_Abort( MPI_COMM_WORLD, 1 );
32         exit(1);
33     }
34
35     color = MPI_UNDEFINED;
36     if (rank < 2) color = 1;
37     MPI_Comm_split( comm, color, size - rank, &scomm );
38     
39     if (rank < 2) {
40         /* Check that the ranks are ordered correctly */
41         MPI_Comm_rank( scomm, &srank );
42         if (srank != 1 - rank) {
43             errs++;
44         }
45         MPI_Comm_free( &scomm );
46     }
47     else {
48         if (scomm != MPI_COMM_NULL) {
49             errs++;
50         }
51     }
52     MPI_Comm_free( &comm );
53     MTest_Finalize( errs );
54     MPI_Finalize();
55     return 0;
56 }