ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
Utils::Mpi Namespace Reference

Classes

struct  CartInfo
 Information about a cartesian communicator. More...
 

Functions

template<typename T >
bool all_compare (boost::mpi::communicator const &comm, T const &value)
 Compare values on all nodes.
 
template<std::size_t dim>
Vector< int, dim > dims_create (int nodes)
 Wrapper around MPI_Dims_create.
 
template<std::size_t dim>
boost::mpi::communicator cart_create (boost::mpi::communicator const &comm, Vector< int, dim > const &dims, bool reorder=true, Vector< int, dim > const &periodicity=Vector< int, dim >::broadcast(1))
 Wrapper around MPI_Cart_create.
 
template<std::size_t dims>
Vector3i cart_coords (boost::mpi::communicator const &comm, int rank)
 Wrapper around MPI_Cart_coords.
 
template<std::size_t dims>
int cart_rank (boost::mpi::communicator const &comm, const Vector< int, dims > &pos)
 Wrapper around MPI_Cart_rank.
 
std::pair< int, int > cart_shift (boost::mpi::communicator const &comm, int direction, int displacement)
 Wrapper around MPI_Cart_shift.
 
template<std::size_t dim>
Utils::Vector< int, 2 *dim > cart_neighbors (const boost::mpi::communicator &comm)
 Calculates the numbers of the nearest neighbors for a node.
 
template<std::size_t dim>
CartInfo< dim > cart_get (const boost::mpi::communicator &comm)
 Wrapper around MPI_Cart_get.
 
template<typename T , class Allocator >
void gather_buffer (std::vector< T, Allocator > &buffer, boost::mpi::communicator const &comm, int root=0)
 Gather buffer with different size on each node.
 
template<typename T >
void gatherv (const boost::mpi::communicator &comm, const T *in_values, int in_size, T *out_values, const int *sizes, const int *displs, int root)
 
template<typename T >
void gatherv (const boost::mpi::communicator &comm, const T *in_values, int in_size, T *out_values, const int *sizes, int root)
 
template<typename T >
void gatherv (const boost::mpi::communicator &comm, const T *in_values, int in_size, int root)
 
template<typename T >
auto iall_gatherv (boost::mpi::communicator const &comm, T const *in_values, int in_size, T *out_values, int const *sizes)
 
template<typename T >
reduce_optional (boost::mpi::communicator const &comm, std::optional< T > const &result)
 Reduce an optional on the head node.
 
template<typename T >
void scatter_buffer (T *buffer, int n_elem, boost::mpi::communicator comm, int root=0)
 Scatter buffer with different size on each node.
 
template<typename T >
mpi::status sendrecv (mpi::communicator const &comm, int dest, int stag, const T &sval, int src, int rtag, T &rval)
 
template<typename T >
std::array< mpi::request, 2 > isendrecv (mpi::communicator const &comm, int dest, int stag, const T &sval, int src, int rtag, T &rval)
 

Function Documentation

◆ all_compare()

template<typename T >
bool Utils::Mpi::all_compare ( boost::mpi::communicator const &  comm,
T const &  value 
)

Compare values on all nodes.

Parameters
commThe communicator to operate on.
valuethe value to compare.
Template Parameters
Tthe type of value.

Returns true iff all ranks in comm called the function with the same value. T has to be serializeable.

Definition at line 42 of file all_compare.hpp.

Referenced by CollisionDetection::BindAtPointOfCollision::handle_collisions(), CollisionDetection::GlueToSurface::handle_collisions(), and System::System::on_integration_start().

◆ cart_coords()

template<std::size_t dims>
Vector3i Utils::Mpi::cart_coords ( boost::mpi::communicator const &  comm,
int  rank 
)

Wrapper around MPI_Cart_coords.

Template Parameters
dimsNumber of dimensions

Definition at line 72 of file cart_comm.hpp.

References Utils::Array< T, N >::data().

◆ cart_create()

template<std::size_t dim>
boost::mpi::communicator Utils::Mpi::cart_create ( boost::mpi::communicator const &  comm,
Vector< int, dim > const &  dims,
bool  reorder = true,
Vector< int, dim > const &  periodicity = Vector<int, dim>::broadcast(1) 
)

Wrapper around MPI_Cart_create.

Template Parameters
dimNumber of dimensions

Definition at line 54 of file cart_comm.hpp.

References Utils::Array< T, N >::data().

Referenced by Communicator::init_comm_cart().

◆ cart_get()

template<std::size_t dim>
CartInfo< dim > Utils::Mpi::cart_get ( const boost::mpi::communicator &  comm)

Wrapper around MPI_Cart_get.

Template Parameters
dimNumber of dimensions.
Parameters
commCommunicator with cartesian topology.
Returns
Struct with information about the communicator.

Definition at line 150 of file cart_comm.hpp.

◆ cart_neighbors()

template<std::size_t dim>
Utils::Vector< int, 2 *dim > Utils::Mpi::cart_neighbors ( const boost::mpi::communicator &  comm)

Calculates the numbers of the nearest neighbors for a node.

Template Parameters
dimDimension of the communicator
Parameters
commCartesian communicator
Returns
Ranks of 2*dim neighbors

Definition at line 115 of file cart_comm.hpp.

References cart_shift().

◆ cart_rank()

template<std::size_t dims>
int Utils::Mpi::cart_rank ( boost::mpi::communicator const &  comm,
const Vector< int, dims > &  pos 
)

Wrapper around MPI_Cart_rank.

Template Parameters
dimsNumber of dimensions

Definition at line 84 of file cart_comm.hpp.

References Utils::Array< T, N >::data().

◆ cart_shift()

std::pair< int, int > Utils::Mpi::cart_shift ( boost::mpi::communicator const &  comm,
int  direction,
int  displacement 
)
inline

Wrapper around MPI_Cart_shift.

Returns
pair of source and destination rank.

Definition at line 96 of file cart_comm.hpp.

Referenced by cart_neighbors().

◆ dims_create()

template<std::size_t dim>
Vector< int, dim > Utils::Mpi::dims_create ( int  nodes)

Wrapper around MPI_Dims_create.

Template Parameters
dimNumber of dimensions

Definition at line 40 of file cart_comm.hpp.

◆ gather_buffer()

template<typename T , class Allocator >
void Utils::Mpi::gather_buffer ( std::vector< T, Allocator > &  buffer,
boost::mpi::communicator const &  comm,
int  root = 0 
)

Gather buffer with different size on each node.

Gathers buffers with different lengths from all nodes to root. The buffer is resized to the total size. On the root node, the first n_elem elements of buffer are moved, if need be. On the other nodes, buffer is not touched.

This encapsulates a common combination of MPI_Gather() and MPI_{Send,Recv}().

Parameters
bufferOn the head node: the target buffer that has the local part in the beginning. On worker nodes: the local buffer.
commThe MPI communicator.
rootThe rank where the data should be gathered.

Definition at line 54 of file gather_buffer.hpp.

References gatherv().

Referenced by ScriptInterface::Particles::auto_exclusions(), ScriptInterface::Analysis::Analysis::do_call_method(), ScriptInterface::CellSystem::CellSystem::do_call_method(), ErrorHandling::RuntimeErrorCollector::gather(), CollisionDetection::gather_collision_queue(), BondBreakage::gather_global_queue(), ErrorHandling::RuntimeErrorCollector::gather_local(), gather_traits_for_types(), GatherParticleTraits< T >::join(), mindist(), nbhood(), and propagate_vel_pos_sd().

◆ gatherv() [1/3]

template<typename T >
void Utils::Mpi::gatherv ( const boost::mpi::communicator &  comm,
const T *  in_values,
int  in_size,
int  root 
)

Definition at line 116 of file gatherv.hpp.

References gatherv().

◆ gatherv() [2/3]

template<typename T >
void Utils::Mpi::gatherv ( const boost::mpi::communicator &  comm,
const T *  in_values,
int  in_size,
T *  out_values,
const int *  sizes,
const int *  displs,
int  root 
)

Definition at line 87 of file gatherv.hpp.

Referenced by gather_buffer(), gatherv(), mpi_get_particles(), and mpi_get_particles_local().

◆ gatherv() [3/3]

template<typename T >
void Utils::Mpi::gatherv ( const boost::mpi::communicator &  comm,
const T *  in_values,
int  in_size,
T *  out_values,
const int *  sizes,
int  root 
)

Definition at line 95 of file gatherv.hpp.

◆ iall_gatherv()

template<typename T >
auto Utils::Mpi::iall_gatherv ( boost::mpi::communicator const &  comm,
T const *  in_values,
int  in_size,
T *  out_values,
int const *  sizes 
)

Definition at line 73 of file iall_gatherv.hpp.

Referenced by gather_particle_data().

◆ isendrecv()

template<typename T >
std::array< mpi::request, 2 > Utils::Mpi::isendrecv ( mpi::communicator const &  comm,
int  dest,
int  stag,
const T &  sval,
int  src,
int  rtag,
T &  rval 
)

Definition at line 73 of file sendrecv.hpp.

◆ reduce_optional()

template<typename T >
T Utils::Mpi::reduce_optional ( boost::mpi::communicator const &  comm,
std::optional< T > const &  result 
)

Reduce an optional on the head node.

Worker nodes get a default-constructed object.

Definition at line 36 of file reduce_optional.hpp.

Referenced by ScriptInterface::walberla::EKIndexedReaction::do_call_method(), ScriptInterface::walberla::EKSpeciesNode::do_call_method(), and ScriptInterface::walberla::LBFluidNode::do_call_method().

◆ scatter_buffer()

template<typename T >
void Utils::Mpi::scatter_buffer ( T *  buffer,
int  n_elem,
boost::mpi::communicator  comm,
int  root = 0 
)

Scatter buffer with different size on each node.

Scatter a buffer to the nodes, where every node gets a different chunk of the buffer, controlled by the worker node.

This is a collective call.

Definition at line 44 of file scatter_buffer.hpp.

Referenced by propagate_vel_pos_sd().

◆ sendrecv()

template<typename T >
mpi::status Utils::Mpi::sendrecv ( mpi::communicator const &  comm,
int  dest,
int  stag,
const T &  sval,
int  src,
int  rtag,
T &  rval 
)

Definition at line 66 of file sendrecv.hpp.