Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into CRTP
[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)
31             continue;
32         /* Determine the sender and receiver */
33         MPI_Comm_rank(comm, &rank);
34         MPI_Comm_size(comm, &size);
35         MPI_Comm_group(comm, &group);
36         MPI_Group_rank(group, &grank);
37         MPI_Group_size(group, &gsize);
38         if (rank != grank) {
39             errs++;
40             fprintf(stderr, "Ranks of groups do not match %d != %d\n", rank, grank);
41         }
42         if (size != gsize) {
43             errs++;
44             fprintf(stderr, "Sizes of groups do not match %d != %d\n", size, gsize);
45         }
46         MPI_Group_free(&group);
47         MTestFreeComm(&comm);
48     }
49
50     MTest_Finalize(errs);
51     MPI_Finalize();
52     return 0;
53 }