BELFEM 0.9.3
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
commtools.hpp File Reference
#include <limits>
#include <type_traits>
#include <string>
#include "typedefs.hpp"
#include "assert.hpp"
#include "cl_Vector.hpp"
#include "cl_Matrix.hpp"
#include "cl_Communicator.hpp"
#include "commtypes.hpp"
Include dependency graph for commtools.hpp:

Go to the source code of this file.

Classes

struct  belfem::is_scalar< T >
struct  belfem::is_scalar< Vector< T > >
struct  belfem::is_scalar< Matrix< T > >

Namespaces

namespace  belfem
 USER GUIDES:

Functions

proc_t belfem::comm_size ()
proc_t belfem::comm_rank ()
void belfem::comm_check (const int aErrorCode)
 Any code other than MPI_SUCCESS aborts through BELFEM_ERROR ( release too ), which ends the whole run with MPI_Abort on the world communicator.
void belfem::comm_barrier ()
 Collective: every rank must reach it before any rank passes it.
void belfem::comm_drain_check (const char *aLabel)
 Debug-build tripwire for the two-tags-per-pair ordering contract of the point-to-point fabric ( see comm_tag() in commtools.cpp ).
int belfem::comm_tag (const proc_t aSource, const proc_t aTarget)
 The base tag of an unordered rank pair.
Cell< int > belfem::comm_split (const index_t aLength)
 Local, it does not communicate: splits aLength into chunks of at most gMaxCommChunkLength.
index_t belfem::comm_splitcount (const Vector< index_t > &aLengths, const proc_t aRoot)
 Local, it does not communicate despite aRoot: the number of chunk messages comm_split() would produce for every rank but aRoot.
index_t belfem::comm_splitcount (index_t aLength)
template<typename T>
void belfem::broadcast (T &aMessage, const proc_t aRoot=0, typename std::enable_if< is_scalar< T >::value >::type *=nullptr)
 Collective: every rank calls it, and aRoot's data lands on all ranks.
template<typename T>
void belfem::broadcast (T *aMessage, const proc_t aRoot, const proc_t aLength)
 Collective: every rank calls it, and aRoot's data lands on all ranks.
template<typename T>
void belfem::allreduce (const T *aSend, T *aRecv, const int aCount)
 Collective MAX-reduction visible on every rank.
template<typename T>
void belfem::allreduce_min (const T *aSend, T *aRecv, const int aCount)
 Collective MIN-reduction visible on every rank.
template<typename T>
void belfem::send (const T aData, const proc_t aTarget=0, typename std::enable_if< is_scalar< T >::value >::type *=nullptr)
 Point-to-point, not collective: one send() is matched by exactly one receive() on aTarget, in the same order for the same rank pair.
template<typename T>
void belfem::receive (T &aData, const proc_t aSource=0, typename std::enable_if< is_scalar< T >::value >::type *=nullptr)
 The receiving half of send(): point-to-point, not collective, blocks until the message has arrived.
template<typename T>
void belfem::send (T *aData, const index_t aLength, const proc_t aTarget)
 Same contract as send( T ).
template<typename T>
void belfem::receive (T *aData, index_t &aLength, const proc_t aSource)
 Same contract as receive( T& ), except that aData must be preallocated.
template<typename T>
void belfem::send (Cell< T > &aData, const proc_t aTarget=0)
 Same contract as send( T ).
template<typename T>
void belfem::receive (Cell< T > &aData, const proc_t aSource=0)
 Same contract as receive( T& ); aData is resized to the sender's size and filled with 0 before the payload lands.
template<typename T>
void belfem::broadcast (Cell< T > &aData, const proc_t aRoot=0)
 Collective: every rank calls it, and aRoot's data lands on all ranks.
template<typename T>
void belfem::distribute (Cell< T > &aData)
 Sends only, not collective: aData has one entry per rank ( asserted ) and entry p goes to rank p; its own slot is skipped.
template<typename T>
void belfem::collect (Cell< T > &aData, const T aMyValue=0)
 Receives only, one slot per rank.
template<typename T>
void belfem::send (Vector< T > &aData, const proc_t aTarget=0)
 Same contract as send( T ).
template<typename T>
void belfem::receive (Vector< T > &aData, const proc_t aSource=0)
 Same contract as receive( T& ); aData is resized to the sender's size and filled with 0 before the payload lands.
template<typename T>
void belfem::broadcast (Vector< T > &aData, const proc_t aRoot=0)
 Collective: every rank calls it, and aRoot's data lands on all ranks.
template<typename T>
void belfem::distribute (Vector< T > &aData)
 Same contract as distribute( Cell< T >& ).
template<typename T>
void belfem::collect (Vector< T > &aData, const T aMyValue=0)
 Receives only, one slot per rank.
template<typename T>
void belfem::distribute (Cell< Vector< T > > &aData)
 Same contract as distribute( Cell< T >& ).
template<typename T>
void belfem::distribute (Cell< Cell< T > > &aData)
 Same contract as distribute( Cell< T >& ).
template<typename T, typename U>
void belfem::distribute (const T *aData, const Vector< U > &aOffsets)
 Same contract as distribute( Cell< T >& ), on a contiguous caller-owned buffer.
template<typename T, typename U>
void belfem::collect (T *aData, const Vector< U > &aOffsets)
 Rank 0 only, receives only: rank p's block lands at aOffsets( p ) and every other rank must send it, through distribute() or send().
template<typename T>
void belfem::collect (Cell< Vector< T > > &aData, Vector< T > aMyData={})
 Receives only, one slot per rank.
template<typename T>
void belfem::share (Vector< T > &aData)
 Sends only; it is not collective.
template<typename T>
void belfem::share (Cell< T > &aData)
 Same contract as share( Vector< T >& ).
template<typename T>
void belfem::broadcast (Matrix< T > &aData, const proc_t aRoot=0)
 Collective: every rank calls it, and aRoot's data lands on all ranks.
template<typename T>
void belfem::send (Matrix< T > &aData, const proc_t aTarget=0)
 Same contract as send( T ).
template<typename T>
void belfem::receive (Matrix< T > &aData, const proc_t aSource=0)
 Same contract as receive( T& ); aData is resized to the sender's shape.
template<typename T>
void belfem::distribute (Cell< Matrix< T > > &aData)
 Same contract as distribute( Cell< T >& ).
template<typename T>
void belfem::collect (Cell< Matrix< T > > &aData)
 Receives only, one slot per rank.
void belfem::broadcast (Cell< string > &aData, const proc_t aRoot=0)
 Collective: every rank calls it, and aRoot's data lands on all ranks.
void belfem::send (const string &aMessage, const proc_t aTarget=0)
 Same contract as send( T ).
void belfem::receive (string &aMessage, const proc_t aSource=0)
 Same contract as receive( T& ).

Variables

belfem::Communicator gComm
constexpr int belfem::gMaxCommChunkLength = 64 * 1024

Variable Documentation

◆ gComm

belfem::Communicator gComm
extern