TRIQS/mpi 1.3.0
C++ interface to MPI
Loading...
Searching...
No Matches
Utilities

Detailed Description

Some other utilities used in the mpi library.

Concepts

concept  mpi::contiguous_sized_range
 A concept that checks if a range type is contiguous and sized.
 

Typedefs

template<typename T >
using mpi::regular_t = typename detail::_regular<std::decay_t<T>>::type
 Type trait to get the regular type of a type.
 

Functions

void mpi::check_mpi_call (int errcode, const std::string &mpi_routine)
 Check the success of an MPI call.
 
template<typename R >
auto mpi::chunk (R &&rg, communicator c={})
 Divide a given range as evenly as possible across the MPI processes in a communicator and get the subrange assigned to the calling process.
 
long mpi::chunk_length (long end, int nranges, int i, long min_size=1)
 Get the length of the ith subrange after splitting the integer range [0, end) as evenly as possible across n subranges.
 

Typedef Documentation

◆ regular_t

template<typename T >
using mpi::regular_t = typename detail::_regular<std::decay_t<T>>::type

#include <mpi/utils.hpp>

Type trait to get the regular type of a type.

Template Parameters
TType to check.

Definition at line 55 of file utils.hpp.

Function Documentation

◆ check_mpi_call()

void mpi::check_mpi_call ( int errcode,
const std::string & mpi_routine )
inline

#include <mpi/utils.hpp>

Check the success of an MPI call.

It checks if the given error code returned by an MPI routine is equal to MPI_SUCCESS. If it isn't, it throws an exception.

It is intended to simply wrap any calls to the MPI C library:

int value = 5;
int result = 0;
check_mpi_call(MPI_Allreduce(&value, &result, 1, mpi::mpi_type<int>::get(), MPI_MAX, comm.get()), "MPI_Allreduce");
void check_mpi_call(int errcode, const std::string &mpi_routine)
Check the success of an MPI call.
Definition utils.hpp:72
Map C++ datatypes to the corresponding MPI datatypes.
Definition datatypes.hpp:57
Parameters
errcodeError code returned by an MPI routine.
mpi_routineName of the MPI routine used in the error message.

Definition at line 72 of file utils.hpp.

◆ chunk()

template<typename R >
auto mpi::chunk ( R && rg,
communicator c = {} )
nodiscard

#include <mpi/chunk.hpp>

Divide a given range as evenly as possible across the MPI processes in a communicator and get the subrange assigned to the calling process.

Template Parameters
RRange type.
Parameters
rgRange to divide.
cmpi::communicator.
Returns
An itertools::sliced range assigned to the calling process.

Definition at line 66 of file chunk.hpp.

◆ chunk_length()

long mpi::chunk_length ( long end,
int nranges,
int i,
long min_size = 1 )
inlinenodiscard

#include <mpi/chunk.hpp>

Get the length of the ith subrange after splitting the integer range [0, end) as evenly as possible across n subranges.

The optional parameter min_size can be used to first divide the range into equal parts of size min_size before distributing them as evenly as possible across the number of specified subranges.

It throws an exception if min_size < 1 or if it is not a divisor of end.

Parameters
endEnd of the integer range [0, end).
nrangesNumber of subranges.
iIndex of the subrange of interest.
min_sizeMinimum size of the subranges.
Returns
Length of the ith subrange.

Definition at line 50 of file chunk.hpp.