Doxygen
1.9.1
|
Functions | |
template<bool binary = TasGrid::mode_binary> | |
int | TasGrid::MPIGridSend (TasmanianSparseGrid const &grid, int destination, int tag, MPI_Comm comm) |
Send a grid to another process in the MPI comm. More... | |
template<bool binary = TasGrid::mode_binary> | |
int | TasGrid::MPIGridRecv (TasmanianSparseGrid &grid, int source, int tag, MPI_Comm comm, MPI_Status *status=MPI_STATUS_IGNORE) |
Receive a grid from another process in the MPI comm. More... | |
template<bool binary = TasGrid::mode_binary> | |
int | TasGrid::MPIGridBcast (TasmanianSparseGrid &grid, int root, MPI_Comm comm) |
Broadcast a grid to all processes in an MPI comm. More... | |
template<bool binary = TasGrid::mode_binary> | |
int | TasGrid::MPIGridScatterOutputs (TasmanianSparseGrid const &source, TasmanianSparseGrid &destination, int root, int tag, MPI_Comm comm) |
Split the grid across the comm where each rank receives an equal portion of the total outputs. More... | |
Methods to send/receive TasGrid::TasmanianSparseGrid objects. The syntax mimics the raw MPI_Send and MPI_Recv calls, and the templates require Tasmanian_ENABLE_MPI=ON.
int TasGrid::MPIGridSend | ( | TasmanianSparseGrid const & | grid, |
int | destination, | ||
int | tag, | ||
MPI_Comm | comm | ||
) |
Send a grid to another process in the MPI comm.
Send the grid to the destination rank across an MPI comm. The grid is frist writtein to a stream in either binary or ASCII format and then send with a single MPI_Send() call. Binary results in smaller messages and less computational overhead; thus, ASCII is provided mostly for debugging purposes.
binary | defines whether to use binary (true) or ASCII (false) mode. Recommended use with constexpr constant TasGrid::mode_binary and TasGrid::mode_ascii. |
grid | is the grid to send. |
destination | is the rank of the recipient MPI process. |
tag | is the tag to use for the MPI message. |
comm | is the MPI comm where the source and destination reside. |
Note: this call must be mirrored by TasGrid::MPIGridRecv() on the destination process.
Example usage, process 0 creates a grid and sends it to process 1:
int TasGrid::MPIGridRecv | ( | TasmanianSparseGrid & | grid, |
int | source, | ||
int | tag, | ||
MPI_Comm | comm, | ||
MPI_Status * | status = MPI_STATUS_IGNORE |
||
) |
Receive a grid from another process in the MPI comm.
Receive a grid that has been send with TasGrid::MPIGridSend(). This call intercepts both messages and compiles them into a sparse grid object.
binary | defines whether to use binary (true) or ASCII (false) mode. Recommended use with constexpr constant TasGrid::mode_binary and TasGrid::mode_ascii. |
grid | is the output grid, it will be overwritten with grid send by the source rank similar to TasGrid::TasmanianSparseGrid::read(). |
source | is the rank of the process in the MPI comm that issued the send command. |
tag | is the tag used in the MPI send command. |
comm | is the MPI comm where the source and destination reside. |
status | is the status of the MPI_Recv() command. |
int TasGrid::MPIGridBcast | ( | TasmanianSparseGrid & | grid, |
int | root, | ||
MPI_Comm | comm | ||
) |
Broadcast a grid to all processes in an MPI comm.
Make all grid variables for all process in the comm match the grid on the root process. This call uses two MPI_Bcast() calls, the grid size (in memory units) and the actual grid data. The transfer can be done in either binary or ASCII format, but binary results in smaller messages and less computational overhead; thus, ASCII is provided mostly for debugging purposes.
binary | defines whether to use binary (true) or ASCII (false) mode. Recommended use with constexpr constant TasGrid::mode_binary and TasGrid::mode_ascii. |
grid | is the grid to broadcast across the MPI comm, the grid on the root process will not be modified (i.e., treat as const), in all other cases, the grid will be overwritten similar to the TasGrid::TasmanianSparseGrid::read(). |
root | is the process that holds the data that needs to be send across. |
comm | is the MPI comm of all process that need to share the grid. |
Example usage, process 0 reads a grid from a file and sends it to all processes:
int TasGrid::MPIGridScatterOutputs | ( | TasmanianSparseGrid const & | source, |
TasmanianSparseGrid & | destination, | ||
int | root, | ||
int | tag, | ||
MPI_Comm | comm | ||
) |
Split the grid across the comm where each rank receives an equal portion of the total outputs.
Split the grid across the ranks in the comm so that each rank receives a grid with the same type, rule, points, etc., but with a subset of the total outputs. The distribution is as close to even as possible, if there are less outputs than ranks, some ranks will receive an empty grid.
Note: this does not use MPI_Scatter(), instead it makes multiple calls to MPIGridSend() and MPIGridRecv().
binary | defines whether to use binary (true) or ASCII (false) mode, see TasGrid::MPIGridSend(). |
source | grid located on the root rank is the grid to be distributed across, for all other ranks the source will not be referenced. |
destination | is the grid where the local portion of the scatter will be stored, the existing grid will be overwritten. If the source outputs are less than the number of comm ranks, then some of the destination grids will be empty. |
root | is the rank that will hold the source sparse grid. |
tag | same as in TasGrid::MPIGridSend(). |
comm | is the MPI comm of all process that need to share a portion of the grid. |
Example usage, rank 0 creates a large grid and scatters is across comm: