MADNESS 0.10.1
SafeMPI::ByteCount Class Reference

The (count, datatype) pair that describes a buffer of bytes to MPI. More...

#include <safempi.h>

Public Member Functions

 ByteCount (const ByteCount &)=delete
 ByteCount (std::size_t nbyte, std::size_t chunk=ByteCount::max_plain_count())
 ~ByteCount ()
int count () const
MPI_Datatype datatype () const
bool derived () const
ByteCount & operator= (const ByteCount &)=delete

Static Public Member Functions

static constexpr bool have_large_count ()
static std::size_t max_plain_count ()
static void set_max_plain_count (std::size_t n)
 Sets max_plain_count().
static void set_use_large_count (bool flag)
 Sets use_large_count().
static bool use_large_count ()

Static Private Member Functions

static std::atomic< std::size_t > & max_plain_count_accessor ()
static std::atomic< bool > & use_large_count_accessor ()

Private Attributes

int count_
MPI_Datatype datatype_
bool derived_

Detailed Description

The (count, datatype) pair that describes a buffer of bytes to MPI.

This is how a buffer of more than INT_MAX bytes is sent and received where MPI has no large-count functions (before MPI 4), see Intracomm::Isend_bytes() . MPI counts are int , so a buffer of more than INT_MAX bytes cannot be described as a count of MPI_BYTE . Such a buffer is described here as one element of a derived datatype: whole chunks of bytes, then the bytes left over. The type signature is that of the same number of MPI_BYTE , so the two ends of a message need not agree on how they describe it. A derived datatype is freed by the destructor; MPI lets a datatype be freed while a nonblocking operation that uses it is pending, so the object need not outlive the request.

Constructor & Destructor Documentation

◆ ByteCount() [1/2]

SafeMPI::ByteCount::ByteCount ( std::size_t nbyte,
std::size_t chunk = ByteCount::max_plain_count() )
inlineexplicit
Parameters
nbytethe size of the buffer
chunka buffer of up to this many bytes is described as a count of MPI_BYTE , and a larger one as chunks of this many bytes plus the rest (default: max_plain_count() ; 0, or a value above INT_MAX , means INT_MAX )

References count_, datatype_, derived_, MADNESS_MPI_TEST, max_plain_count(), MPI_BYTE, MPI_ERR_COUNT, MPI_SUCCESS, MPI_Type_commit(), MPI_Type_contiguous(), MPI_Type_create_struct(), MPI_Type_free(), SAFE_MPI_GLOBAL_MUTEX, and status.

Referenced by ByteCount(), and operator=().

◆ ByteCount() [2/2]

SafeMPI::ByteCount::ByteCount ( const ByteCount & )
delete

References ByteCount().

◆ ~ByteCount()

SafeMPI::ByteCount::~ByteCount ( )
inline

Member Function Documentation

◆ count()

int SafeMPI::ByteCount::count ( ) const
inline
Returns
the count to give MPI together with datatype()

References count_.

Referenced by SafeMPI::Intracomm::Irecv_bytes(), and SafeMPI::Intracomm::Isend_bytes().

◆ datatype()

MPI_Datatype SafeMPI::ByteCount::datatype ( ) const
inline

◆ derived()

bool SafeMPI::ByteCount::derived ( ) const
inline
Returns
whether the buffer was too large for a count of MPI_BYTE

References derived_.

◆ have_large_count()

constexpr bool SafeMPI::ByteCount::have_large_count ( )
inlinestaticconstexpr
Returns
whether this MPI has the large-count functions of MPI 4 ( MPI_Isend_c and the like), which take a count of type MPI_Count

Referenced by main(), and use_large_count().

◆ max_plain_count()

std::size_t SafeMPI::ByteCount::max_plain_count ( )
inlinestatic
Returns
the largest buffer that is described as a count of MPI_BYTE

References max_plain_count_accessor().

Referenced by ByteCount(), SafeMPI::Intracomm::Irecv_bytes(), and SafeMPI::Intracomm::Isend_bytes().

◆ max_plain_count_accessor()

std::atomic< std::size_t > & SafeMPI::ByteCount::max_plain_count_accessor ( )
inlinestaticprivate

◆ operator=()

ByteCount & SafeMPI::ByteCount::operator= ( const ByteCount & )
delete

References ByteCount().

◆ set_max_plain_count()

void SafeMPI::ByteCount::set_max_plain_count ( std::size_t n)
inlinestatic

Sets max_plain_count().

This exists for tests, which lower it to take the derived-datatype path with small buffers; nothing else has a reason to call it. The two ends of a message may use different values, and a change while messages are in flight is safe: each ByteCount reads the value once.

Parameters
nthe new value; 0, or a value above INT_MAX , restores the default

References max_plain_count_accessor().

Referenced by main().

◆ set_use_large_count()

void SafeMPI::ByteCount::set_use_large_count ( bool flag)
inlinestatic

Sets use_large_count().

Like set_max_plain_count() this exists for tests, which turn it off to take the derived-datatype path with an MPI that has large counts. The two ends of a message need not agree.

References use_large_count_accessor().

Referenced by main().

◆ use_large_count()

bool SafeMPI::ByteCount::use_large_count ( )
inlinestatic
Returns
whether buffers above max_plain_count() are given to the large-count functions of MPI rather than described by a derived datatype; true by default if have_large_count() , and always false otherwise

References have_large_count(), and use_large_count_accessor().

Referenced by SafeMPI::Intracomm::Irecv_bytes(), SafeMPI::Intracomm::Isend_bytes(), and main().

◆ use_large_count_accessor()

std::atomic< bool > & SafeMPI::ByteCount::use_large_count_accessor ( )
inlinestaticprivate

Member Data Documentation

◆ count_

int SafeMPI::ByteCount::count_
private

Referenced by ByteCount(), and count().

◆ datatype_

MPI_Datatype SafeMPI::ByteCount::datatype_
private

Referenced by ByteCount(), ~ByteCount(), and datatype().

◆ derived_

bool SafeMPI::ByteCount::derived_
private

Referenced by ByteCount(), ~ByteCount(), and derived().


The documentation for this class was generated from the following file: