29 comm_world = comm_world_in;
30 comm_group_leaders = comm_group_leaders_in;
31 comm_worker_groups = comm_worker_groups_in;
34 ierr = MPI_Comm_size(comm_world, &N_procs_world);
35 if (ierr != 0)
throw std::runtime_error(
"Error with the supplied mpi_comm_world in mango::MPI_Partition::set_custom.");
36 ierr = MPI_Comm_rank(comm_world, &rank_world);
37 proc0_world = (rank_world == 0);
40 MPI_Comm_rank(comm_worker_groups, &rank_worker_groups);
41 if (ierr != 0)
throw std::runtime_error(
"Error with the supplied mpi_comm_worker_groups in mango::MPI_Partition::set_custom.");
42 MPI_Comm_size(comm_worker_groups, &N_procs_worker_groups);
43 proc0_worker_groups = (rank_worker_groups == 0);
46 if (proc0_worker_groups) {
47 MPI_Comm_rank(comm_group_leaders, &rank_group_leaders);
48 if (ierr != 0)
throw std::runtime_error(
"Error with the supplied mpi_comm_group_leaders in mango::MPI_Partition::set_custom.");
49 MPI_Comm_size(comm_group_leaders, &N_procs_group_leaders);
52 rank_group_leaders = -1;
53 N_procs_group_leaders = -1;
57 N_worker_groups = (proc0_worker_groups ? 1 : 0);
58 MPI_Allreduce(MPI_IN_PLACE, &N_worker_groups, 1, MPI_INT, MPI_SUM, comm_world);
61 worker_group = rank_group_leaders;
62 MPI_Bcast(&worker_group, 1, MPI_INT, 0, comm_worker_groups);