waLBerla 7.2
Loading...
Searching...
No Matches
walberla::gpu::communication::MemcpyPackInfo< GPUFieldType > Class Template Reference

Detailed Description

template<typename GPUFieldType>
class walberla::gpu::communication::MemcpyPackInfo< GPUFieldType >

Data packing/unpacking for ghost layer based communication of a GPUField.

Encapsulate information on how to extract data from blocks that should be communicated to neighboring blocks (see pack()) and how to inject this data in a receiving block (see unpack()). This involves a device memory buffer and two device-to-device 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 device buffer, but can be sent directly. This involves a single device-to-device memory copy operation.

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()!

Template Parameters
GPUFieldTypeA fully qualified GPUField.

#include <MemcpyPackInfo.h>

+ Inheritance diagram for walberla::gpu::communication::MemcpyPackInfo< GPUFieldType >:

Public Member Functions

 MemcpyPackInfo (BlockDataID fieldId, const uint_t numGhostLayers=0)
 
 ~MemcpyPackInfo () override=default
 
void pack (stencil::Direction dir, unsigned char *buffer, IBlock *block, gpuStream_t stream) override
 Pack data from a block into a send buffer.
 
void communicateLocal (stencil::Direction dir, const IBlock *sender, IBlock *receiver, gpuStream_t stream) override
 Copy data from one local block to another local block.
 
void unpack (stencil::Direction dir, unsigned char *buffer, IBlock *block, gpuStream_t stream) override
 Unpack data from a receive buffer into a block.
 
uint_t size (stencil::Direction dir, IBlock *block) override
 
- Public Member Functions inherited from walberla::gpu::GeneratedGPUPackInfo
 GeneratedGPUPackInfo ()=default
 
virtual ~GeneratedGPUPackInfo ()=default
 

Private Member Functions

uint_t numberOfGhostLayersToCommunicate (const GPUFieldType *const field) const
 

Private Attributes

BlockDataID fieldId_
 
uint_t numberOfGhostLayers_ { 0 }
 
bool communicateAllGhostLayers_ { true }
 

Constructor & Destructor Documentation

◆ MemcpyPackInfo()

template<typename GPUFieldType >
walberla::gpu::communication::MemcpyPackInfo< GPUFieldType >::MemcpyPackInfo ( BlockDataID fieldId,
const uint_t numGhostLayers = 0 )
inline
Parameters
fieldId_BlockDataID of the field to be communicated
numGhostLayersNumber of ghost layers to be communicated. If left at zero, the number will be inferred from the field.

◆ ~MemcpyPackInfo()

template<typename GPUFieldType >
walberla::gpu::communication::MemcpyPackInfo< GPUFieldType >::~MemcpyPackInfo ( )
overridedefault

Member Function Documentation

◆ communicateLocal()

template<typename GPUFieldType >
void walberla::gpu::communication::MemcpyPackInfo< GPUFieldType >::communicateLocal ( stencil::Direction dir,
const IBlock * sender,
IBlock * receiver,
gpuStream_t stream )
overridevirtual

Copy data from one local block to another local block.

Both blocks are allocated on the same MPI rank.

Parameters
dirthe direction of the communication (from sender to receiver)
senderid of block where the data should be copied from
receiverid of block where the data should be copied to
streamGPU stream

Implements walberla::gpu::GeneratedGPUPackInfo.

◆ numberOfGhostLayersToCommunicate()

template<typename GPUFieldType >
uint_t walberla::gpu::communication::MemcpyPackInfo< GPUFieldType >::numberOfGhostLayersToCommunicate ( const GPUFieldType *const field) const
private

◆ pack()

template<typename GPUFieldType >
void walberla::gpu::communication::MemcpyPackInfo< GPUFieldType >::pack ( stencil::Direction dir,
unsigned char * buffer,
IBlock * block,
gpuStream_t stream )
overridevirtual

Pack data from a block into a send buffer.

Parameters
dirpack data for neighbor in this direction
bufferbuffer for writing the data into
blockthe block whose data should be packed into a buffer
streamGPU stream

Implements walberla::gpu::GeneratedGPUPackInfo.

◆ size()

template<typename GPUFieldType >
uint_t walberla::gpu::communication::MemcpyPackInfo< GPUFieldType >::size ( stencil::Direction dir,
IBlock * block )
overridevirtual

◆ unpack()

template<typename GPUFieldType >
void walberla::gpu::communication::MemcpyPackInfo< GPUFieldType >::unpack ( stencil::Direction dir,
unsigned char * buffer,
IBlock * block,
gpuStream_t stream )
overridevirtual

Unpack data from a receive buffer into a block.

Parameters
dirreceive data from neighbor in this direction
bufferbuffer for reading the data from
blockthe block where the unpacked data should be stored into
streamGPU stream

Implements walberla::gpu::GeneratedGPUPackInfo.

Member Data Documentation

◆ communicateAllGhostLayers_

template<typename GPUFieldType >
bool walberla::gpu::communication::MemcpyPackInfo< GPUFieldType >::communicateAllGhostLayers_ { true }
private

◆ fieldId_

template<typename GPUFieldType >
BlockDataID walberla::gpu::communication::MemcpyPackInfo< GPUFieldType >::fieldId_
private

◆ numberOfGhostLayers_

template<typename GPUFieldType >
uint_t walberla::gpu::communication::MemcpyPackInfo< GPUFieldType >::numberOfGhostLayers_ { 0 }
private

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