TRIQS/nda 1.3.0
Multi-dimensional array library for C++
|
MPI support for nda::basic_array and nda::basic_array_view objects.
nda uses the TRIQS/mpi library to provide functions to broadcast, gather, reduce and scatter arrays and views over MPI processes.
The following example demonstrates some of these features:
Running with 4 cores outputs:
Classes | |
struct | mpi::lazy< mpi::tag::gather, A > |
Specialization of the mpi::lazy class for nda::Array types and the mpi::tag::gather tag. More... | |
struct | mpi::lazy< mpi::tag::reduce, A > |
Specialization of the mpi::lazy class for nda::Array types and the mpi::tag::reduce tag. More... | |
struct | mpi::lazy< mpi::tag::scatter, A > |
Specialization of the mpi::lazy class for nda::Array types and the mpi::tag::scatter tag. More... | |
Functions | |
template<typename A > requires (is_regular_or_view_v<A>) | |
void | nda::mpi_broadcast (A &a, mpi::communicator comm={}, int root=0) |
Implementation of an MPI broadcast for nda::basic_array or nda::basic_array_view types. | |
template<typename A > requires (is_regular_or_view_v<A>) | |
ArrayInitializer< std::remove_reference_t< A > > auto | nda::mpi_gather (A &&a, mpi::communicator comm={}, int root=0, bool all=false) |
Implementation of an MPI gather for nda::basic_array or nda::basic_array_view types. | |
template<typename A > requires (is_regular_or_view_v<A>) | |
ArrayInitializer< std::remove_reference_t< A > > auto | nda::mpi_reduce (A &&a, mpi::communicator comm={}, int root=0, bool all=false, MPI_Op op=MPI_SUM) |
Implementation of an MPI reduce for nda::basic_array or nda::basic_array_view types. | |
template<typename A > requires (is_regular_or_view_v<A>) | |
ArrayInitializer< std::remove_reference_t< A > > auto | nda::mpi_scatter (A &&a, mpi::communicator comm={}, int root=0, bool all=false) |
Implementation of an MPI scatter for nda::basic_array or nda::basic_array_view types. | |
void nda::mpi_broadcast | ( | A & | a, |
mpi::communicator | comm = {}, | ||
int | root = 0 ) |
#include <nda/mpi/broadcast.hpp>
Implementation of an MPI broadcast for nda::basic_array or nda::basic_array_view types.
For the root process, the array/view is broadcasted to all other processes. For non-root processes, the array/view is resized/checked to match the broadcasted dimensions and the data is written into the given array/view.
Throws an exception, if a given view does not have the correct shape.
A | nda::basic_array or nda::basic_array_view type. |
a | Array or view to be broadcasted from/into. |
comm | mpi::communicator object. |
root | Rank of the root process. |
Definition at line 61 of file broadcast.hpp.
ArrayInitializer< std::remove_reference_t< A > > auto nda::mpi_gather | ( | A && | a, |
mpi::communicator | comm = {}, | ||
int | root = 0, | ||
bool | all = false ) |
#include <nda/mpi/gather.hpp>
Implementation of an MPI gather for nda::basic_array or nda::basic_array_view types.
Since the returned mpi::lazy
object models an nda::ArrayInitializer, it can be used to initialize/assign to nda::basic_array and nda::basic_array_view objects:
Here, the array res
will have a shape of (3 * comm.size(), 4)
.
A | nda::basic_array or nda::basic_array_view type. |
a | Array or view to be gathered. |
comm | mpi::communicator object. |
root | Rank of the root process. |
all | Should all processes receive the result of the gather. |
mpi::lazy
object modelling an nda::ArrayInitializer. Definition at line 166 of file gather.hpp.
ArrayInitializer< std::remove_reference_t< A > > auto nda::mpi_reduce | ( | A && | a, |
mpi::communicator | comm = {}, | ||
int | root = 0, | ||
bool | all = false, | ||
MPI_Op | op = MPI_SUM ) |
#include <nda/mpi/reduce.hpp>
Implementation of an MPI reduce for nda::basic_array or nda::basic_array_view types.
Since the returned mpi::lazy
object models an nda::ArrayInitializer, it can be used to initialize/assign to nda::basic_array and nda::basic_array_view objects:
A | nda::basic_array or nda::basic_array_view type. |
a | Array or view to be gathered. |
comm | mpi::communicator object. |
root | Rank of the root process. |
all | Should all processes receive the result of the gather. |
op | MPI reduction operation. |
mpi::lazy
object modelling an nda::ArrayInitializer. Definition at line 165 of file reduce.hpp.
ArrayInitializer< std::remove_reference_t< A > > auto nda::mpi_scatter | ( | A && | a, |
mpi::communicator | comm = {}, | ||
int | root = 0, | ||
bool | all = false ) |
#include <nda/mpi/scatter.hpp>
Implementation of an MPI scatter for nda::basic_array or nda::basic_array_view types.
Since the returned mpi::lazy
object models an nda::ArrayInitializer, it can be used to initialize/assign to nda::basic_array and nda::basic_array_view objects:
Here, the array res
will have a shape of (10 / comm.size(), 4)
.
A | nda::basic_array or nda::basic_array_view type. |
a | Array or view to be scattered. |
comm | mpi::communicator object. |
root | Rank of the root process. |
all | Should all processes receive the result of the scatter (not used). |
mpi::lazy
object modelling an nda::ArrayInitializer. Definition at line 156 of file scatter.hpp.