waLBerla 7.2
|
Data packing/unpacking for ghost layer based communication of a field.
Encapsulate information on how to extract data from blocks that should be communicated to neighboring blocks (see packData()) and how to inject this data in a receiving block (see unpackData()). This involves a memory buffer and two memory copy operations.
A special method exists for communication between two blocks which are allocated on the same process (see communicateLocal()). In this case the data does not have be communicated via a buffer, but can be copied directly.
Data that is packed in direction "dir" at one block is unpacked in direction "stencil::inverseDir[dir]" at the neighboring block. This behavior must be implemented in communicateLocal()!
#include <UniformPackInfo.h>
Construction & Destruction | |
std::map< const IBlock *, std::map< stencil::Direction, size_t > > | bufferSize_ |
UniformPackInfo ()=default | |
virtual | ~UniformPackInfo ()=default |
virtual bool | constantDataExchange () const =0 |
Should return true if the amount of data that is packed for a given block in direction "dir" is guaranteed to remain constant over time. | |
virtual bool | threadsafeReceiving () const =0 |
Must return false if calling unpackData and/or communicateLocal is not thread-safe. | |
void | packData (const IBlock *sender, stencil::Direction dir, mpi::SendBuffer &buffer) const |
Pack data from a block into a send buffer. | |
virtual void | unpackData (IBlock *receiver, stencil::Direction dir, mpi::RecvBuffer &buffer)=0 |
Unpack received Data. | |
virtual void | communicateLocal (const IBlock *sender, IBlock *receiver, stencil::Direction dir)=0 |
Copy data from one local block to another local block. | |
virtual void | beforeStartCommunication () |
This function is called once before the communication is started by the UniformBufferedScheme. | |
virtual void | afterStartCommunication () |
This function is called once after the communication has been started by the UniformBufferedScheme. | |
virtual void | beforeWait () |
This function is called once before the UniformBufferedScheme waits for the communication to finish. | |
virtual void | afterWait () |
This function is called once after the communication has been finished by the UniformBufferedScheme. | |
virtual void | packDataImpl (const IBlock *sender, stencil::Direction dir, mpi::SendBuffer &buffer) const =0 |
Pack data from a block into a send buffer. | |
|
default |
|
virtualdefault |
|
inlinevirtual |
This function is called once after the communication has been started by the UniformBufferedScheme.
|
inlinevirtual |
This function is called once after the communication has been finished by the UniformBufferedScheme.
|
inlinevirtual |
This function is called once before the communication is started by the UniformBufferedScheme.
|
inlinevirtual |
This function is called once before the UniformBufferedScheme waits for the communication to finish.
|
pure virtual |
Copy data from one local block to another local block.
Both blocks are allocated on the current process. If NOT thread-safe, threadsafeReceiving must return false!
sender | id of block where the data should be copied from |
receiver | id of block where the data should be copied to |
dir | the direction of the communication ( from sender to receiver ) |
Implemented in walberla::boundary::HandlingPackInfo< Handling_T >, walberla::field::communication::PackInfo< GhostLayerField_T >, walberla::field::communication::PackInfo< GhostLayerField< BubbleID, 1 > >, walberla::field::communication::StencilRestrictedPackInfo< GhostLayerField_T, Stencil_T >, walberla::field::communication::UniformPullReductionPackInfo< ReduceOperation, GhostLayerField_T >, walberla::free_surface::bubble_model::BubbleIDFieldPackInfo< Stencil_T >, walberla::gpu::communication::GPUPackInfo< GPUField_T >, walberla::lbm::CombinedInPlaceCpuPackInfo< EvenPackInfo, OddPackInfo >, walberla::lbm::SparsePdfFieldPackInfo< LatticeModel_T, FlagField_T >, and walberla::lbm_generated::CombinedInPlaceCpuPackInfo< LatticeStorageSpecification_T, EvenPackInfo, OddPackInfo >.
|
pure virtual |
Should return true if the amount of data that is packed for a given block in direction "dir" is guaranteed to remain constant over time.
False otherwise. If you are not sure what to return, return false! Returning false is always safe. Falsely returning true will lead to errors! However, if the data can be guaranteed to remain constant over time, returning true enables performance optimizations during the communication.
Implemented in walberla::boundary::HandlingPackInfo< Handling_T >, walberla::field::communication::PackInfo< GhostLayerField_T >, walberla::field::communication::PackInfo< GhostLayerField< BubbleID, 1 > >, walberla::field::communication::StencilRestrictedPackInfo< GhostLayerField_T, Stencil_T >, walberla::field::communication::UniformPullReductionPackInfo< ReduceOperation, GhostLayerField_T >, walberla::gpu::communication::GPUPackInfo< GPUField_T >, walberla::lbm::CombinedInPlaceCpuPackInfo< EvenPackInfo, OddPackInfo >, walberla::lbm::SparsePdfFieldPackInfo< LatticeModel_T, FlagField_T >, walberla::lbm_generated::CombinedInPlaceCpuPackInfo< LatticeStorageSpecification_T, EvenPackInfo, OddPackInfo >, and walberla::lbm_generated::UniformGeneratedPdfPackInfo< PdfField_T >.
|
inline |
Pack data from a block into a send buffer.
Must be thread-safe! Calls packDataImpl.
sender | the block whose data should be packed into a buffer |
dir | pack data for neighbor in this direction |
buffer | buffer for writing the data into |
|
protectedpure virtual |
Pack data from a block into a send buffer.
Must be thread-safe!
Implementations must reserve extra space and advance the send buffer pointer according to the alignment of the ghost layer data type! The buffer is char-aligned.
sender | the block whose data should be packed into a buffer |
dir | pack data for neighbor in this direction |
buffer | buffer for writing the data into |
Implemented in walberla::boundary::HandlingPackInfo< Handling_T >, walberla::field::communication::PackInfo< GhostLayerField_T >, walberla::field::communication::PackInfo< GhostLayerField< BubbleID, 1 > >, walberla::field::communication::StencilRestrictedPackInfo< GhostLayerField_T, Stencil_T >, walberla::field::communication::UniformPullReductionPackInfo< ReduceOperation, GhostLayerField_T >, walberla::gpu::communication::GPUPackInfo< GPUField_T >, walberla::lbm::CombinedInPlaceCpuPackInfo< EvenPackInfo, OddPackInfo >, walberla::lbm::SparsePdfFieldPackInfo< LatticeModel_T, FlagField_T >, and walberla::lbm_generated::CombinedInPlaceCpuPackInfo< LatticeStorageSpecification_T, EvenPackInfo, OddPackInfo >.
|
pure virtual |
Must return false if calling unpackData and/or communicateLocal is not thread-safe.
True otherwise. If you are not sure what to return, return false! Returning false is always safe. Falsely returning true will most likely lead to errors! However, if both unpackData AND communicateLocal are thread-safe, returning true can lead to performance improvements.
Implemented in walberla::boundary::HandlingPackInfo< Handling_T >, walberla::field::communication::PackInfo< GhostLayerField_T >, walberla::field::communication::PackInfo< GhostLayerField< BubbleID, 1 > >, walberla::field::communication::StencilRestrictedPackInfo< GhostLayerField_T, Stencil_T >, walberla::field::communication::UniformPullReductionPackInfo< ReduceOperation, GhostLayerField_T >, walberla::free_surface::bubble_model::BubbleIDFieldPackInfo< Stencil_T >, walberla::gpu::communication::GPUPackInfo< GPUField_T >, walberla::lbm::CombinedInPlaceCpuPackInfo< EvenPackInfo, OddPackInfo >, walberla::lbm::SparsePdfFieldPackInfo< LatticeModel_T, FlagField_T >, walberla::lbm_generated::CombinedInPlaceCpuPackInfo< LatticeStorageSpecification_T, EvenPackInfo, OddPackInfo >, and walberla::lbm_generated::UniformGeneratedPdfPackInfo< PdfField_T >.
|
pure virtual |
Unpack received Data.
If NOT thread-safe, threadsafeReceiving must return false!
Implementations must reserve extra space and advance the send buffer pointer according to the alignment of the ghost layer data type! The buffer is char-aligned.
receiver | the block where the unpacked data should be stored into |
dir | receive data from neighbor in this direction |
buffer | buffer for reading the data from |
Implemented in walberla::boundary::HandlingPackInfo< Handling_T >, walberla::field::communication::PackInfo< GhostLayerField_T >, walberla::field::communication::PackInfo< GhostLayerField< BubbleID, 1 > >, walberla::field::communication::StencilRestrictedPackInfo< GhostLayerField_T, Stencil_T >, walberla::field::communication::UniformPullReductionPackInfo< ReduceOperation, GhostLayerField_T >, walberla::free_surface::bubble_model::BubbleIDFieldPackInfo< Stencil_T >, walberla::gpu::communication::GPUPackInfo< GPUField_T >, walberla::lbm::CombinedInPlaceCpuPackInfo< EvenPackInfo, OddPackInfo >, walberla::lbm::SparsePdfFieldPackInfo< LatticeModel_T, FlagField_T >, and walberla::lbm_generated::CombinedInPlaceCpuPackInfo< LatticeStorageSpecification_T, EvenPackInfo, OddPackInfo >.
|
mutableprotected |