A class for dividing the set of MPI processes into worker groups. More...
#include <mango.hpp>
Public Member Functions | |
MPI_Partition () | |
Constructor. More... | |
~MPI_Partition () | |
Destructor. More... | |
void | init (MPI_Comm comm_world) |
Divide up a given "world" communicator into worker groups. More... | |
void | set_custom (MPI_Comm comm_world, MPI_Comm comm_group_leaders, MPI_Comm comm_worker_groups) |
Use a user-supplied partitioning of the MPI processes into worker groups. More... | |
MPI_Comm | get_comm_world () |
Get the MPI communicator for MANGO's world communicator. More... | |
MPI_Comm | get_comm_worker_groups () |
Get the MPI communicator for MANGO's "worker groups" communicator. More... | |
MPI_Comm | get_comm_group_leaders () |
Get the MPI communicator for MANGO's "group leaders" communicator. More... | |
bool | get_proc0_world () |
Determine whether this MPI processor has rank 0 in MANGO's world communicator. More... | |
bool | get_proc0_worker_groups () |
Determine whether this MPI processor has rank 0 in MANGO's "worker groups" communicator. More... | |
int | get_rank_world () |
Get the MPI rank of this processor in MANGO's world communicator. More... | |
int | get_rank_worker_groups () |
Get the MPI rank of this processor in MANGO's "worker groups" communicator. More... | |
int | get_rank_group_leaders () |
Get the MPI rank of this processor in MANGO's "group leaders" communicator. More... | |
int | get_N_procs_world () |
Get the number of processors in MANGO's world communicator. More... | |
int | get_N_procs_worker_groups () |
Get the number of processors in MANGO's "worker groups" communicator. More... | |
int | get_N_procs_group_leaders () |
Get the number of processors in MANGO's "group leaders" communicator. More... | |
int | get_worker_group () |
Returns an integer indicating the worker group to which this MPI process belongs. More... | |
int | get_N_worker_groups () |
Returns the number of worker groups. More... | |
void | set_N_worker_groups (int N_worker_groups) |
Set the number of worker groups to the given integer. More... | |
void | write (std::string filename) |
Write a file with the given filename, showing the worker group assignments and rank of each process in each communicator. More... | |
void | stop_workers () |
Tell the worker MPI processes (i.e. those that are not group leaders) that the optimization problem is complete. More... | |
void | mobilize_workers () |
Tell the worker MPI processes (i.e. those that are not group leaders) to begin an evaluation of the objective function. More... | |
bool | continue_worker_loop () |
For an MPI worker, determine whether to carry out another evaluation of the objective function or exit. More... | |
Public Attributes | |
int | verbose |
If true, information is printed to stdout that may be useful for debugging. More... | |
A class for dividing the set of MPI processes into worker groups.
Each group works together on evaluations of the objective function. For more information, see Core Concepts.
mango::MPI_Partition::MPI_Partition | ( | ) |
Constructor.
Definition at line 25 of file mpi_partition.cpp.
mango::MPI_Partition::~MPI_Partition | ( | ) |
Destructor.
Definition at line 32 of file mpi_partition.cpp.
bool mango::MPI_Partition::continue_worker_loop | ( | ) |
For an MPI worker, determine whether to carry out another evaluation of the objective function or exit.
This subroutine should only be called on MPI processors that are not group leaders. You can see typical usage of this subroutine in the examples. However you are also free to use your own approach to controlling the worker processes instead of this subroutine.
Definition at line 125 of file mpi_partition.cpp.
MPI_Comm mango::MPI_Partition::get_comm_group_leaders | ( | ) |
Get the MPI communicator for MANGO's "group leaders" communicator.
For more information about MPI communicators, see Core Concepts. This function can only be called after calling mango::Problem::mpi_init(), mango::MPI_Partition::init(), or mango::MPI_Partition::set_custom(). Otherwise a C++ exception will be thrown.
Definition at line 51 of file mpi_partition.cpp.
MPI_Comm mango::MPI_Partition::get_comm_worker_groups | ( | ) |
Get the MPI communicator for MANGO's "worker groups" communicator.
For more information about MPI communicators, see Core Concepts. This function can only be called after calling mango::Problem::mpi_init(), mango::MPI_Partition::init(), or mango::MPI_Partition::set_custom(). Otherwise a C++ exception will be thrown.
Definition at line 46 of file mpi_partition.cpp.
MPI_Comm mango::MPI_Partition::get_comm_world | ( | ) |
Get the MPI communicator for MANGO's world communicator.
For more information about MPI communicators, see Core Concepts. This function can only be called after calling mango::Problem::mpi_init(), mango::MPI_Partition::init(), or mango::MPI_Partition::set_custom(). Otherwise a C++ exception will be thrown.
Definition at line 41 of file mpi_partition.cpp.
int mango::MPI_Partition::get_N_procs_group_leaders | ( | ) |
Get the number of processors in MANGO's "group leaders" communicator.
For more information about MPI communicators, see Core Concepts. This function can only be called after calling mango::Problem::mpi_init(), mango::MPI_Partition::init(), or mango::MPI_Partition::set_custom(). Otherwise a C++ exception will be thrown.
Definition at line 91 of file mpi_partition.cpp.
int mango::MPI_Partition::get_N_procs_worker_groups | ( | ) |
Get the number of processors in MANGO's "worker groups" communicator.
For more information about MPI communicators, see Core Concepts. This function can only be called after calling mango::Problem::mpi_init(), mango::MPI_Partition::init(), or mango::MPI_Partition::set_custom(). Otherwise a C++ exception will be thrown.
Definition at line 86 of file mpi_partition.cpp.
int mango::MPI_Partition::get_N_procs_world | ( | ) |
Get the number of processors in MANGO's world communicator.
For more information about MPI communicators, see Core Concepts. This function can only be called after calling mango::Problem::mpi_init(), mango::MPI_Partition::init(), or mango::MPI_Partition::set_custom(). Otherwise a C++ exception will be thrown.
Definition at line 81 of file mpi_partition.cpp.
int mango::MPI_Partition::get_N_worker_groups | ( | ) |
Returns the number of worker groups.
Definition at line 101 of file mpi_partition.cpp.
bool mango::MPI_Partition::get_proc0_worker_groups | ( | ) |
Determine whether this MPI processor has rank 0 in MANGO's "worker groups" communicator.
Equivalently, this function determines whether this MPI processor is a group leader.
This function can only be called after calling mango::Problem::mpi_init(), mango::MPI_Partition::init(), or mango::MPI_Partition::set_custom(). Otherwise a C++ exception will be thrown.
Definition at line 61 of file mpi_partition.cpp.
bool mango::MPI_Partition::get_proc0_world | ( | ) |
Determine whether this MPI processor has rank 0 in MANGO's world communicator.
This function can only be called after calling mango::Problem::mpi_init(), mango::MPI_Partition::init(), or mango::MPI_Partition::set_custom(). Otherwise a C++ exception will be thrown.
Definition at line 56 of file mpi_partition.cpp.
int mango::MPI_Partition::get_rank_group_leaders | ( | ) |
Get the MPI rank of this processor in MANGO's "group leaders" communicator.
For more information about MPI communicators, see Core Concepts. This function can only be called after calling mango::Problem::mpi_init(), mango::MPI_Partition::init(), or mango::MPI_Partition::set_custom(). Otherwise a C++ exception will be thrown.
Definition at line 76 of file mpi_partition.cpp.
int mango::MPI_Partition::get_rank_worker_groups | ( | ) |
Get the MPI rank of this processor in MANGO's "worker groups" communicator.
For more information about MPI communicators, see Core Concepts. This function can only be called after calling mango::Problem::mpi_init(), mango::MPI_Partition::init(), or mango::MPI_Partition::set_custom(). Otherwise a C++ exception will be thrown.
Definition at line 71 of file mpi_partition.cpp.
int mango::MPI_Partition::get_rank_world | ( | ) |
Get the MPI rank of this processor in MANGO's world communicator.
For more information about MPI communicators, see Core Concepts. This function can only be called after calling mango::Problem::mpi_init(), mango::MPI_Partition::init(), or mango::MPI_Partition::set_custom(). Otherwise a C++ exception will be thrown.
Definition at line 66 of file mpi_partition.cpp.
int mango::MPI_Partition::get_worker_group | ( | ) |
Returns an integer indicating the worker group to which this MPI process belongs.
This function can only be called after calling mango::Problem::mpi_init(), mango::MPI_Partition::init(), or mango::MPI_Partition::set_custom(). Otherwise a C++ exception will be thrown.
Definition at line 96 of file mpi_partition.cpp.
void mango::MPI_Partition::init | ( | MPI_Comm | comm_world | ) |
Divide up a given "world" communicator into worker groups.
Normally this function is not called directly. Instead it is preferable to call mango::Problem::mpi_init(), since it sets the number of worker groups to 1 for optimization algorithms that do not support multiple worker groups.
This subroutine creates the "worker groups" and "group leaders" communicators.
[in] | comm_world | An MPI communicator consisting of all the processors that will be divided up into worker groups. |
Definition at line 24 of file mpi_partition_init.cpp.
void mango::MPI_Partition::mobilize_workers | ( | ) |
Tell the worker MPI processes (i.e. those that are not group leaders) to begin an evaluation of the objective function.
This subroutine should only be called by group leaders. This subroutine is typically called at the beginning of the user-supplied subroutine for the objective function. You can see typical usage of this subroutine in the examples. However you are also free to use your own approach to controlling the worker processes instead of this subroutine.
Definition at line 118 of file mpi_partition.cpp.
void mango::MPI_Partition::set_custom | ( | MPI_Comm | comm_world, |
MPI_Comm | comm_group_leaders, | ||
MPI_Comm | comm_worker_groups | ||
) |
Use a user-supplied partitioning of the MPI processes into worker groups.
Use either this subroutine or mango::MPI_Partition::init(), not both.
[in] | comm_world | An MPI communicator consisting of all the processors that will be divided up into worker groups. |
[in] | comm_group_leaders | An MPI communicator consisting only of the group leaders. |
[in] | comm_worker_groups | An MPI communicator containing all the processors of comm_world, but with a separate "color" for each worker group. The processes with rank 0 in this communicator must be the same as the processes in comm_group_leaders. |
Definition at line 24 of file mpi_partition_set_custom.cpp.
void mango::MPI_Partition::set_N_worker_groups | ( | int | N_worker_groups | ) |
Set the number of worker groups to the given integer.
Except when using a custom partition, this method must be called before any of the 'get' methods or before using the MPI_Partition for an optimization. This method does not need to be called when using a custom partition.
[in] | N_worker_groups | The desired number of worker groups |
Definition at line 106 of file mpi_partition.cpp.
void mango::MPI_Partition::stop_workers | ( | ) |
Tell the worker MPI processes (i.e. those that are not group leaders) that the optimization problem is complete.
This subroutine should only be called by group leaders. This subroutine is typically called immediately after mango::Problem::optimize(). You can see typical usage of this subroutine in the examples. However you are also free to use your own approach to stopping the worker processes instead of this subroutine.
Definition at line 111 of file mpi_partition.cpp.
void mango::MPI_Partition::write | ( | std::string | filename | ) |
Write a file with the given filename, showing the worker group assignments and rank of each process in each communicator.
[in] | filename | The name of the file in which to write the MPI data. If the file already exists, it will be over-written. |
Definition at line 51 of file mpi_partition_print.cpp.
int mango::MPI_Partition::verbose |