Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add mpich3 test suite, to replace older one.
[simgrid.git] / teshsuite / smpi / mpich3-test / comm / comm_group_half.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *  (C) 2003 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6
7 #include <stdio.h>
8 #include <mpi.h>
9 /* USE_STRICT_MPI may be defined in mpitestconf.h */
10 #include "mpitestconf.h"
11
12 int main(int argc, char **argv)
13 {
14     int rank, size;
15     MPI_Group full_group, half_group;
16     int range[1][3];
17     MPI_Comm __attribute__((unused)) comm;
18
19     MPI_Init(NULL, NULL);
20     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
21     MPI_Comm_size(MPI_COMM_WORLD, &size);
22
23     MPI_Comm_group(MPI_COMM_WORLD, &full_group);
24     range[0][0] = 0;
25     range[0][1] = size / 2;
26     range[0][2] = 1;
27     MPI_Group_range_incl(full_group, 1, range, &half_group);
28
29 #if !defined(USE_STRICT_MPI) && defined(MPICH)
30     if (rank <= size / 2) {
31         MPI_Comm_create_group(MPI_COMM_WORLD, half_group, 0, &comm);
32         MPI_Barrier(comm);
33         MPI_Comm_free(&comm);
34     }
35 #endif /* USE_STRICT_MPI */
36
37     MPI_Group_free(&half_group);
38     MPI_Group_free(&full_group);
39
40     if (rank == 0)
41         printf(" No Errors\n");
42
43     MPI_Finalize();
44
45     return 0;
46 }