Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
reduce some tests duration as comm_create takes longer now (comms)
[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 #include "mpitestconf.h"
10
11 int main(int argc, char **argv)
12 {
13     int rank, size;
14     MPI_Group full_group, half_group;
15     int range[1][3];
16     MPI_Comm comm;
17
18     MPI_Init(NULL, NULL);
19     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
20     MPI_Comm_size(MPI_COMM_WORLD, &size);
21
22     MPI_Comm_group(MPI_COMM_WORLD, &full_group);
23     range[0][0] = 0;
24     range[0][1] = size / 2;
25     range[0][2] = 1;
26     MPI_Group_range_incl(full_group, 1, range, &half_group);
27
28     if (rank <= size / 2) {
29         MPI_Comm_create_group(MPI_COMM_WORLD, half_group, 0, &comm);
30         MPI_Barrier(comm);
31         MPI_Comm_free(&comm);
32     }
33
34     MPI_Group_free(&half_group);
35     MPI_Group_free(&full_group);
36
37     if (rank == 0)
38         printf(" No Errors\n");
39
40     MPI_Finalize();
41
42     return 0;
43 }