walberla::blockforest::communication::UniformBufferedScheme< Stencil_T > Class Template Reference

Detailed Description

template<typename Stencil_T>
class walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >

Communication scheme for buffered communication in uniform block grids.

Most common use case: Synchronize a set of GhostLayerFields with the neighboring processes

  • when multiple fields have been changed they can be synchronized at once, using one MPI message per communication partner
    UniformBufferedScheme<stencil::D3Q19> scheme; // the stencil defines the communication neighbors
    scheme.addPackInfo( make_shared<field::PackInfo<FieldType> >( idOfFirstField ) );
    scheme.addPackInfo( make_shared<field::PackInfo<FieldType> >( idOfSecondField ) );
    // either synchronous communication...
    scheme();
    // .. or asynchronous:
    scheme.startCommunication();
    functionWhichDoesNotNeedCommunicatedValues();
    scheme.wait();

This scheme sends one message per communication step and neighbor process. Therefore all contents that have to be sent, are packed into a buffer before. Multiple PackInfos can be registered to send their contents in a single step. Another option is to omit the buffering step and send multiple messages. This strategy is implemented in blockforest::communication::UniformDirectScheme

When running multiple Schemes concurrently different MPI tags have to be used for the schemes: the tag can be passed in the constructor.

#include <UniformBufferedScheme.h>

Public Types

typedef Stencil_T Stencil
 
typedef mpi::SendBuffer SendBuffer
 
typedef mpi::RecvBuffer RecvBuffer
 
typedef shared_ptr< walberla::communication::UniformPackInfoPackInfo
 
typedef std::function< void()> VoidFunction
 
typedef std::function< void(SendBuffer &buffer)> SendBufferFunction
 
typedef walberla::communication::UniformPackInfo CommunicationItemInfo
 

Public Member Functions

LocalCommunicationMode localMode () const
 
void setLocalMode (const LocalCommunicationMode &mode)
 
Construction & Destruction
 UniformBufferedScheme (weak_ptr_wrapper< StructuredBlockForest > bf, const int tag=778)
 
 UniformBufferedScheme (weak_ptr_wrapper< StructuredBlockForest > bf, const Set< SUID > &requiredBlockSelectors, const Set< SUID > &incompatibleBlockSelectors, const int tag=778)
 
 ~UniformBufferedScheme ()
 
Pack Info Registration
void addPackInfo (const PackInfo &packInfo)
 
void addDataToCommunicate (const PackInfo &packInfo)
 
Synchronous Communication
void operator() ()
 
void communicate ()
 
Asynchronous Communication
void startCommunication ()
 
void wait ()
 
std::function< void()> getStartCommunicateFunctor ()
 
std::function< void()> getWaitFunctor ()
 

Protected Member Functions

void receive (RecvBuffer &buffer)
 
void localBufferPacking (const uint_t index, const PackInfo &packInfo, const Block *sender, const stencil::Direction &dir)
 
void localBufferUnpacking (const uint_t index, const PackInfo &packInfo, Block *receiver, const stencil::Direction &dir)
 

Static Protected Member Functions

static void writeHeader (SendBuffer &buffer, const BlockID &id, const stencil::Direction &dir)
 
static void readHeader (RecvBuffer &buffer, BlockID &id, stencil::Direction &dir)
 
static void send (SendBuffer &buffer, std::vector< SendBufferFunction > &functions)
 

Protected Attributes

weak_ptr_wrapper< StructuredBlockForestblockForest_
 
uint_t forestModificationStamp_
 
std::vector< PackInfopackInfos_
 
LocalCommunicationMode localMode_
 
mpi::OpenMPBufferSystem bufferSystem_
 
std::vector< VoidFunctionlocalCommunication_
 
std::vector< VoidFunctionthreadsafeLocalCommunication_
 
std::vector< VoidFunctionlocalCommunicationUnpack_
 
std::vector< VoidFunctionthreadsafeLocalCommunicationUnpack_
 
std::vector< SendBufferlocalBuffers_
 
bool setupBeforeNextCommunication_
 
bool communicationInProgress_
 
Set< SUID > requiredBlockSelectors_
 
Set< SUID > incompatibleBlockSelectors_
 

Member Typedef Documentation

template<typename Stencil_T>
typedef std::function<void ( SendBuffer & buffer )> walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::SendBufferFunction
template<typename Stencil_T>
typedef std::function<void ()> walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::VoidFunction

Constructor & Destructor Documentation

template<typename Stencil_T>
walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::UniformBufferedScheme ( weak_ptr_wrapper< StructuredBlockForest bf,
const int  tag = 778 
)
inlineexplicit
template<typename Stencil_T>
walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::UniformBufferedScheme ( weak_ptr_wrapper< StructuredBlockForest bf,
const Set< SUID > &  requiredBlockSelectors,
const Set< SUID > &  incompatibleBlockSelectors,
const int  tag = 778 
)
inline

Member Function Documentation

template<typename Stencil_T>
void walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::addDataToCommunicate ( const PackInfo packInfo)
inline
template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::addPackInfo ( const PackInfo packInfo)
inline
template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::communicate ( )
inline
template<typename Stencil >
std::function< void()> walberla::blockforest::communication::UniformBufferedScheme< Stencil >::getStartCommunicateFunctor ( )
template<typename Stencil >
std::function< void()> walberla::blockforest::communication::UniformBufferedScheme< Stencil >::getWaitFunctor ( )
template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::localBufferPacking ( const uint_t  index,
const PackInfo packInfo,
const Block sender,
const stencil::Direction dir 
)
protected
template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::localBufferUnpacking ( const uint_t  index,
const PackInfo packInfo,
Block receiver,
const stencil::Direction dir 
)
protected
template<typename Stencil_T>
LocalCommunicationMode walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::localMode ( ) const
inline
template<typename Stencil_T>
void walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::operator() ( )
inline
template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::readHeader ( RecvBuffer buffer,
BlockID id,
stencil::Direction dir 
)
staticprotected
template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::receive ( RecvBuffer buffer)
protected
template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::send ( SendBuffer buffer,
std::vector< SendBufferFunction > &  functions 
)
staticprotected
template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::setLocalMode ( const LocalCommunicationMode mode)
inline
template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::startCommunication ( )
template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::wait ( )
template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::writeHeader ( SendBuffer buffer,
const BlockID id,
const stencil::Direction dir 
)
staticprotected

Member Data Documentation

template<typename Stencil_T>
mpi::OpenMPBufferSystem walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::bufferSystem_
protected
template<typename Stencil_T>
bool walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::communicationInProgress_
protected
template<typename Stencil_T>
uint_t walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::forestModificationStamp_
protected
template<typename Stencil_T>
Set<SUID> walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::incompatibleBlockSelectors_
protected
template<typename Stencil_T>
std::vector< SendBuffer > walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::localBuffers_
protected
template<typename Stencil_T>
std::vector< VoidFunction > walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::localCommunication_
protected
template<typename Stencil_T>
std::vector< VoidFunction > walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::localCommunicationUnpack_
protected
template<typename Stencil_T>
std::vector< PackInfo > walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::packInfos_
protected
template<typename Stencil_T>
Set<SUID> walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::requiredBlockSelectors_
protected
template<typename Stencil_T>
bool walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::setupBeforeNextCommunication_
protected
template<typename Stencil_T>
std::vector< VoidFunction > walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::threadsafeLocalCommunication_
protected
template<typename Stencil_T>
std::vector< VoidFunction > walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::threadsafeLocalCommunicationUnpack_
protected

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