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>

+ Inheritance diagram for walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >:

Public Types

using Stencil = Stencil_T
 
using SendBuffer = mpi::SendBuffer
 
using RecvBuffer = mpi::RecvBuffer
 
using PackInfo = shared_ptr< walberla::communication::UniformPackInfo >
 
using VoidFunction = std::function< void()>
 
using SendBufferFunction = std::function< void(SendBuffer &)>
 
using CommunicationItemInfo = walberla::communication::UniformPackInfo
 

Public Member Functions

Construction & Destruction
 UniformBufferedScheme (weak_ptr< StructuredBlockForest > bf, const int tag=778)
 
 UniformBufferedScheme (weak_ptr< 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 ()
 
LocalCommunicationMode localMode () const
 
void setLocalMode (const LocalCommunicationMode &mode)
 

Asynchronous Communication

weak_ptr< 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_
 
void startCommunication ()
 
void wait ()
 
std::function< void()> getStartCommunicateFunctor ()
 
std::function< void()> getWaitFunctor ()
 
std::function< void()> getCommunicateFunctor ()
 
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)
 
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)
 

Member Typedef Documentation

◆ CommunicationItemInfo

◆ PackInfo

◆ RecvBuffer

◆ SendBuffer

◆ SendBufferFunction

template<typename Stencil_T >
using walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::SendBufferFunction = std::function<void (SendBuffer &)>

◆ Stencil

◆ VoidFunction

template<typename Stencil_T >
using walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::VoidFunction = std::function<void ()>

Constructor & Destructor Documentation

◆ UniformBufferedScheme() [1/2]

template<typename Stencil_T >
walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::UniformBufferedScheme ( weak_ptr< StructuredBlockForest bf,
const int  tag = 778 
)
inlineexplicit

◆ UniformBufferedScheme() [2/2]

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

◆ ~UniformBufferedScheme()

Member Function Documentation

◆ addDataToCommunicate()

template<typename Stencil_T >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::addDataToCommunicate ( const PackInfo packInfo)
inline

◆ addPackInfo()

template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::addPackInfo ( const PackInfo packInfo)
inline

◆ communicate()

template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::communicate
inline

◆ getCommunicateFunctor()

template<typename Stencil >
std::function< void()> walberla::blockforest::communication::UniformBufferedScheme< Stencil >::getCommunicateFunctor

◆ getStartCommunicateFunctor()

template<typename Stencil >
std::function< void()> walberla::blockforest::communication::UniformBufferedScheme< Stencil >::getStartCommunicateFunctor

◆ getWaitFunctor()

template<typename Stencil >
std::function< void()> walberla::blockforest::communication::UniformBufferedScheme< Stencil >::getWaitFunctor

◆ localBufferPacking()

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

◆ localBufferUnpacking()

template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::localBufferUnpacking ( const uint_t  index,
const PackInfo packInfo,
Block receiver,
const stencil::Direction dir 
)
protected

◆ localMode()

template<typename Stencil_T >
LocalCommunicationMode walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::localMode ( ) const
inline

◆ operator()()

template<typename Stencil_T >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::operator() ( )
inline

◆ readHeader()

template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::readHeader ( RecvBuffer buffer,
BlockID id,
stencil::Direction dir 
)
staticprotected

◆ receive()

template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::receive ( RecvBuffer buffer)
protected

◆ send()

template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::send ( SendBuffer buffer,
std::vector< SendBufferFunction > &  functions 
)
staticprotected

◆ setLocalMode()

template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::setLocalMode ( const LocalCommunicationMode mode)
inline

◆ startCommunication()

template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::startCommunication

◆ wait()

template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::wait

◆ writeHeader()

template<typename Stencil >
void walberla::blockforest::communication::UniformBufferedScheme< Stencil >::writeHeader ( SendBuffer buffer,
const BlockID id,
const stencil::Direction dir 
)
staticprotected

Member Data Documentation

◆ blockForest_

template<typename Stencil_T >
weak_ptr<StructuredBlockForest> walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::blockForest_
protected

◆ bufferSystem_

template<typename Stencil_T >
mpi::OpenMPBufferSystem walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::bufferSystem_
protected

◆ communicationInProgress_

template<typename Stencil_T >
bool walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::communicationInProgress_
protected

◆ forestModificationStamp_

template<typename Stencil_T >
uint_t walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::forestModificationStamp_
protected

◆ incompatibleBlockSelectors_

template<typename Stencil_T >
Set<SUID> walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::incompatibleBlockSelectors_
protected

◆ localBuffers_

template<typename Stencil_T >
std::vector< SendBuffer > walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::localBuffers_
protected

◆ localCommunication_

template<typename Stencil_T >
std::vector< VoidFunction > walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::localCommunication_
protected

◆ localCommunicationUnpack_

template<typename Stencil_T >
std::vector< VoidFunction > walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::localCommunicationUnpack_
protected

◆ localMode_

◆ packInfos_

template<typename Stencil_T >
std::vector< PackInfo > walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::packInfos_
protected

◆ requiredBlockSelectors_

template<typename Stencil_T >
Set<SUID> walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::requiredBlockSelectors_
protected

◆ setupBeforeNextCommunication_

template<typename Stencil_T >
bool walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::setupBeforeNextCommunication_
protected

◆ threadsafeLocalCommunication_

template<typename Stencil_T >
std::vector< VoidFunction > walberla::blockforest::communication::UniformBufferedScheme< Stencil_T >::threadsafeLocalCommunication_
protected

◆ threadsafeLocalCommunicationUnpack_

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: