walberla::gpu::GPUField< T > Class Template Reference

Detailed Description

template<typename T>
class walberla::gpu::GPUField< T >

GhostLayerField stored on a CUDA/HIP GPU.

Basically a wrapper around a CUDA/HIP device pointer together with size information about the field i.e. sizes in x,y,z,f directions and number of ghost layers.

Internally represented by a gpuPitchedPtr which is allocated with gpuMalloc3D to take padding of the innermost coordinate into account.

Supports Array-of-Structures (AoS,zyxf) layout and Structure-of-Arrays (SoA, fzyx) layout, in a similar way to field::Field

To work with the GPUField look at the gpu::fieldCpy functions to transfer a field::Field to a gpu::GPUField and vice versa. When writing device kernels for GPUFields have a look at the FieldIndexing and FieldAccessor concepts. These simplify the "iteration" i.e. indexing of cells in GPUFields.

#include <GPUField.h>

Public Types

typedef T value_type
 

Public Member Functions

 GPUField (uint_t _xSize, uint_t _ySize, uint_t _zSize, uint_t _fSize, uint_t _nrOfGhostLayers, const Layout &_layout=fzyx, bool usePitchedMem=true)
 
 ~GPUField ()
 
Layout layout () const
 
bool isPitchedMem () const
 
gpuPitchedPtr pitchedPtr () const
 
uint_t xSize () const
 
uint_t ySize () const
 
uint_t zSize () const
 
uint_t fSize () const
 
uint_t size () const
 
uint_t size (uint_t coord) const
 
uint_t xSizeWithGhostLayer () const
 
uint_t ySizeWithGhostLayer () const
 
uint_t zSizeWithGhostLayer () const
 
uint_t sizeWithGhostLayer (uint_t i) const
 
cell_idx_t xOff () const
 
cell_idx_t yOff () const
 
cell_idx_t zOff () const
 
cell_idx_t xStride () const
 
cell_idx_t yStride () const
 
cell_idx_t zStride () const
 
cell_idx_t fStride () const
 
uint_t xAllocSize () const
 
uint_t yAllocSize () const
 
uint_t zAllocSize () const
 
uint_t fAllocSize () const
 
uint_t allocSize () const
 
bool hasSameAllocSize (const GPUField< T > &other) const
 True if allocation sizes of all dimensions match. More...
 
bool hasSameSize (const GPUField< T > &other) const
 True if sizes of all dimensions match. More...
 
GPUField< T > * cloneUninitialized () const
 Creates a new GPUField that has equal size, layout and memory type as this field but has uninitialized memory. More...
 
void swapDataPointers (GPUField< T > &other)
 
void swapDataPointers (GPUField< T > *other)
 
uint_t nrOfGhostLayers () const
 
CellInterval xyzSize () const
 
CellInterval xyzSizeWithGhostLayer () const
 
bool operator== (const GPUField &other) const
 Implementation of equality operator, GPUField are equal if identical. More...
 
void getGhostRegion (stencil::Direction d, CellInterval &ci, cell_idx_t thickness, bool fullSlice=false) const
 
void getSliceBeforeGhostLayer (stencil::Direction d, CellInterval &ci, cell_idx_t thickness, bool fullSlice=false) const
 
void getSlice (stencil::Direction d, CellInterval &ci, cell_idx_t distance, cell_idx_t thickness, bool fullSlice) const
 
void * data ()
 
const void * data () const
 
T * dataAt (cell_idx_t x, cell_idx_t y, cell_idx_t z, cell_idx_t f)
 
const T * dataAt (cell_idx_t x, cell_idx_t y, cell_idx_t z, cell_idx_t f) const
 

TimestepCounter

gpuPitchedPtr pitchedPtr_
 
uint_t nrOfGhostLayers_
 
uint_t xSize_
 
uint_t ySize_
 
uint_t zSize_
 
uint_t fSize_
 
uint_t xAllocSize_
 
uint_t fAllocSize_
 
Layout layout_
 
bool usePitchedMem_
 
uint8_t timestepCounter_
 
uint8_t advanceTimestep ()
 
uint8_t getTimestep () const
 
uint8_t getTimestepPlusOne () const
 
bool isEvenTimeStep () const
 

Member Typedef Documentation

◆ value_type

template<typename T >
typedef T walberla::gpu::GPUField< T >::value_type

Constructor & Destructor Documentation

◆ GPUField()

template<typename T >
walberla::gpu::GPUField< T >::GPUField ( uint_t  _xSize,
uint_t  _ySize,
uint_t  _zSize,
uint_t  _fSize,
uint_t  _nrOfGhostLayers,
const Layout &  _layout = fzyx,
bool  usePitchedMem = true 
)

◆ ~GPUField()

template<typename T >
walberla::gpu::GPUField< T >::~GPUField

Member Function Documentation

◆ advanceTimestep()

template<typename T >
uint8_t walberla::gpu::GPUField< T >::advanceTimestep ( )
inline

◆ allocSize()

template<typename T >
uint_t walberla::gpu::GPUField< T >::allocSize ( ) const
inline

◆ cloneUninitialized()

template<typename T >
GPUField< T > * walberla::gpu::GPUField< T >::cloneUninitialized

Creates a new GPUField that has equal size, layout and memory type as this field but has uninitialized memory.

Returns
a new GPUField that has to be freed by caller.

◆ data() [1/2]

template<typename T >
void* walberla::gpu::GPUField< T >::data ( )
inline

◆ data() [2/2]

template<typename T >
const void* walberla::gpu::GPUField< T >::data ( ) const
inline

◆ dataAt() [1/2]

template<typename T >
T * walberla::gpu::GPUField< T >::dataAt ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
cell_idx_t  f 
)

◆ dataAt() [2/2]

template<typename T >
const T * walberla::gpu::GPUField< T >::dataAt ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
cell_idx_t  f 
) const

◆ fAllocSize()

template<typename T >
uint_t walberla::gpu::GPUField< T >::fAllocSize

◆ fSize()

template<typename T >
uint_t walberla::gpu::GPUField< T >::fSize ( ) const
inline

◆ fStride()

template<typename T >
cell_idx_t walberla::gpu::GPUField< T >::fStride ( ) const
inline

◆ getGhostRegion()

template<typename T >
void walberla::gpu::GPUField< T >::getGhostRegion ( stencil::Direction  d,
CellInterval ci,
cell_idx_t  thickness,
bool  fullSlice = false 
) const

◆ getSlice()

template<typename T >
void walberla::gpu::GPUField< T >::getSlice ( stencil::Direction  d,
CellInterval ci,
cell_idx_t  distance,
cell_idx_t  thickness,
bool  fullSlice 
) const

◆ getSliceBeforeGhostLayer()

template<typename T >
void walberla::gpu::GPUField< T >::getSliceBeforeGhostLayer ( stencil::Direction  d,
CellInterval ci,
cell_idx_t  thickness,
bool  fullSlice = false 
) const
inline

◆ getTimestep()

template<typename T >
uint8_t walberla::gpu::GPUField< T >::getTimestep ( ) const
inline

◆ getTimestepPlusOne()

template<typename T >
uint8_t walberla::gpu::GPUField< T >::getTimestepPlusOne ( ) const
inline

◆ hasSameAllocSize()

template<typename T >
bool walberla::gpu::GPUField< T >::hasSameAllocSize ( const GPUField< T > &  other) const

True if allocation sizes of all dimensions match.

◆ hasSameSize()

template<typename T >
bool walberla::gpu::GPUField< T >::hasSameSize ( const GPUField< T > &  other) const

True if sizes of all dimensions match.

◆ isEvenTimeStep()

template<typename T >
bool walberla::gpu::GPUField< T >::isEvenTimeStep ( ) const
inline

◆ isPitchedMem()

template<typename T >
bool walberla::gpu::GPUField< T >::isPitchedMem ( ) const
inline

◆ layout()

template<typename T >
Layout walberla::gpu::GPUField< T >::layout ( ) const
inline

◆ nrOfGhostLayers()

template<typename T >
uint_t walberla::gpu::GPUField< T >::nrOfGhostLayers ( ) const
inline

◆ operator==()

template<typename T >
bool walberla::gpu::GPUField< T >::operator== ( const GPUField< T > &  o) const

Implementation of equality operator, GPUField are equal if identical.

operator== is required in order to store GPUFields as block data. Implementing a correct equality check would require to call a kernel, which should be done manually. Therefore only identical GPUFields are considered equal.

◆ pitchedPtr()

template<typename T >
gpuPitchedPtr walberla::gpu::GPUField< T >::pitchedPtr ( ) const
inline

◆ size() [1/2]

template<typename T >
uint_t walberla::gpu::GPUField< T >::size ( ) const
inline

◆ size() [2/2]

template<typename T >
uint_t walberla::gpu::GPUField< T >::size ( uint_t  coord) const
inline

◆ sizeWithGhostLayer()

template<typename T >
uint_t walberla::gpu::GPUField< T >::sizeWithGhostLayer ( uint_t  i) const
inline

◆ swapDataPointers() [1/2]

template<typename T >
void walberla::gpu::GPUField< T >::swapDataPointers ( GPUField< T > &  other)

◆ swapDataPointers() [2/2]

template<typename T >
void walberla::gpu::GPUField< T >::swapDataPointers ( GPUField< T > *  other)
inline

◆ xAllocSize()

template<typename T >
uint_t walberla::gpu::GPUField< T >::xAllocSize

◆ xOff()

template<typename T >
cell_idx_t walberla::gpu::GPUField< T >::xOff ( ) const
inline

◆ xSize()

template<typename T >
uint_t walberla::gpu::GPUField< T >::xSize ( ) const
inline

◆ xSizeWithGhostLayer()

template<typename T >
uint_t walberla::gpu::GPUField< T >::xSizeWithGhostLayer ( ) const
inline

◆ xStride()

template<typename T >
cell_idx_t walberla::gpu::GPUField< T >::xStride ( ) const
inline

◆ xyzSize()

template<typename T >
CellInterval walberla::gpu::GPUField< T >::xyzSize
inline

◆ xyzSizeWithGhostLayer()

template<typename T >
CellInterval walberla::gpu::GPUField< T >::xyzSizeWithGhostLayer
inline

◆ yAllocSize()

template<typename T >
uint_t walberla::gpu::GPUField< T >::yAllocSize

◆ yOff()

template<typename T >
cell_idx_t walberla::gpu::GPUField< T >::yOff ( ) const
inline

◆ ySize()

template<typename T >
uint_t walberla::gpu::GPUField< T >::ySize ( ) const
inline

◆ ySizeWithGhostLayer()

template<typename T >
uint_t walberla::gpu::GPUField< T >::ySizeWithGhostLayer ( ) const
inline

◆ yStride()

template<typename T >
cell_idx_t walberla::gpu::GPUField< T >::yStride ( ) const
inline

◆ zAllocSize()

template<typename T >
uint_t walberla::gpu::GPUField< T >::zAllocSize

◆ zOff()

template<typename T >
cell_idx_t walberla::gpu::GPUField< T >::zOff ( ) const
inline

◆ zSize()

template<typename T >
uint_t walberla::gpu::GPUField< T >::zSize ( ) const
inline

◆ zSizeWithGhostLayer()

template<typename T >
uint_t walberla::gpu::GPUField< T >::zSizeWithGhostLayer ( ) const
inline

◆ zStride()

template<typename T >
cell_idx_t walberla::gpu::GPUField< T >::zStride ( ) const
inline

Member Data Documentation

◆ fAllocSize_

template<typename T >
uint_t walberla::gpu::GPUField< T >::fAllocSize_
protected

◆ fSize_

template<typename T >
uint_t walberla::gpu::GPUField< T >::fSize_
protected

◆ layout_

template<typename T >
Layout walberla::gpu::GPUField< T >::layout_
protected

◆ nrOfGhostLayers_

template<typename T >
uint_t walberla::gpu::GPUField< T >::nrOfGhostLayers_
protected

◆ pitchedPtr_

template<typename T >
gpuPitchedPtr walberla::gpu::GPUField< T >::pitchedPtr_
protected

◆ timestepCounter_

template<typename T >
uint8_t walberla::gpu::GPUField< T >::timestepCounter_
protected

◆ usePitchedMem_

template<typename T >
bool walberla::gpu::GPUField< T >::usePitchedMem_
protected

◆ xAllocSize_

template<typename T >
uint_t walberla::gpu::GPUField< T >::xAllocSize_
protected

◆ xSize_

template<typename T >
uint_t walberla::gpu::GPUField< T >::xSize_
protected

◆ ySize_

template<typename T >
uint_t walberla::gpu::GPUField< T >::ySize_
protected

◆ zSize_

template<typename T >
uint_t walberla::gpu::GPUField< T >::zSize_
protected

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