Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
working on mpi_comm_split.
[simgrid.git] / src / smpi / sample / split.c
1 #include <stdio.h>
2 #include <mpi.h>
3
4 int main(int argc, char *argv[]) {
5         int worldrank, localrank;
6         MPI_Comm localcomm;
7         MPI_Init(&argc, &argv);
8         MPI_Comm_rank(MPI_COMM_WORLD, &worldrank);
9         MPI_Comm_split(MPI_COMM_WORLD, worldrank % 2, worldrank, &localcomm);
10         MPI_Comm_rank(localcomm, &localrank);
11         printf("node with world rank %d has local rank %d\n", worldrank, localrank);
12         MPI_Finalize();
13         return 0;
14 }