Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add mpich3 topo tests
[simgrid.git] / teshsuite / smpi / mpich3-test / comm / icgroup.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 "mpitest.h"
10
11 /*
12 static char MTEST_Descrip[] = "Get the group of an intercommunicator";
13 */
14
15 int main( int argc, char *argv[] )
16 {
17     int errs = 0;
18     int rank, size, grank, gsize;
19     int minsize = 2, isleft; 
20     MPI_Comm      comm;
21     MPI_Group     group;
22
23     MTest_Init( &argc, &argv );
24
25     /* The following illustrates the use of the routines to 
26        run through a selection of communicators and datatypes.
27        Use subsets of these for tests that do not involve combinations 
28        of communicators, datatypes, and counts of datatypes */
29     while (MTestGetIntercomm( &comm, &isleft, minsize )) {
30         if (comm == MPI_COMM_NULL) continue;
31         /* Determine the sender and receiver */
32         MPI_Comm_rank( comm, &rank );
33         MPI_Comm_size( comm, &size );
34         MPI_Comm_group( comm, &group );
35         MPI_Group_rank( group, &grank );
36         MPI_Group_size( group, &gsize );
37         if (rank != grank) {
38             errs++;
39             fprintf( stderr, "Ranks of groups do not match %d != %d\n",
40                      rank, grank );
41         }
42         if (size != gsize) {
43             errs++;
44             fprintf( stderr, "Sizes of groups do not match %d != %d\n",
45                      size, gsize );
46         }
47         MPI_Group_free( &group );
48         MTestFreeComm( &comm );
49     }
50
51     MTest_Finalize( errs );
52     MPI_Finalize();
53     return 0;
54 }