27 ierr = MPI_Comm_dup(mpi_comm_world_in, &comm_world);
28 if (ierr != 0)
throw std::runtime_error(
"Error 1 in mango::MPI_Partition::init.");
30 ierr = MPI_Comm_size(comm_world, &N_procs_world);
31 ierr = MPI_Comm_rank(comm_world, &rank_world);
32 proc0_world = (rank_world == 0);
37 MPI_Bcast(&N_worker_groups, 1, MPI_INT, 0, comm_world);
40 if (N_worker_groups > N_procs_world) N_worker_groups = N_procs_world;
42 if (N_worker_groups < 1) N_worker_groups = N_procs_world;
46 worker_group = (rank_world * N_worker_groups) / N_procs_world;
50 ierr = MPI_Comm_split(comm_world, worker_group, rank_world, &comm_worker_groups);
51 if (ierr != 0)
throw std::runtime_error(
"Error 2 in mango::MPI_Partition::init.");
52 MPI_Comm_rank(comm_worker_groups, &rank_worker_groups);
53 MPI_Comm_size(comm_worker_groups, &N_procs_worker_groups);
54 proc0_worker_groups = (rank_worker_groups == 0);
58 if (proc0_worker_groups) {
61 color = MPI_UNDEFINED;
63 ierr = MPI_Comm_split(comm_world, color, rank_world, &comm_group_leaders);
64 if (ierr != 0)
throw std::runtime_error(
"Error 3 in mango::MPI_Partition::init.");
66 if (proc0_worker_groups) {
67 MPI_Comm_rank(comm_group_leaders, &rank_group_leaders);
68 MPI_Comm_size(comm_group_leaders, &N_procs_group_leaders);
71 rank_group_leaders = -1;
72 N_procs_group_leaders = -1;