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

Detailed Description

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

GhostLayerField stored on a CUDA GPU.

Basically a wrapper around a CUDA 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 cudaPitchedPtr which is allocated with cudaMalloc3D 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 similiar way to field::Field

To work with the GPUField look at the cuda::fieldCpy functions to transfer a field::Field to a cuda::GPUField and vice versa. When writing CUDA 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=zyxf, bool usePitchedMem=true)
 
 ~GPUField ()
 
Layout layout () const
 
bool isPitchedMem () const
 
cudaPitchedPtr 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) const
 
void getSliceBeforeGhostLayer (stencil::Direction d, CellInterval &ci, cell_idx_t thickness, bool fullSlice) 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
 

Protected Attributes

cudaPitchedPtr 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_
 

Member Typedef Documentation

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

Constructor & Destructor Documentation

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

Member Function Documentation

template<typename T >
uint_t walberla::cuda::GPUField< T >::allocSize ( ) const
inline
template<typename T >
GPUField< T > * walberla::cuda::GPUField< T >::cloneUninitialized ( ) const

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

Returns
a new FPUField that has to be freed by caller.
template<typename T >
void* walberla::cuda::GPUField< T >::data ( )
inline
template<typename T >
const void* walberla::cuda::GPUField< T >::data ( ) const
inline
template<typename T >
T * walberla::cuda::GPUField< T >::dataAt ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
cell_idx_t  f 
)
template<typename T >
const T * walberla::cuda::GPUField< T >::dataAt ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
cell_idx_t  f 
) const
template<typename T >
uint_t walberla::cuda::GPUField< T >::fAllocSize ( ) const
template<typename T >
uint_t walberla::cuda::GPUField< T >::fSize ( ) const
inline
template<typename T >
cell_idx_t walberla::cuda::GPUField< T >::fStride ( ) const
inline
template<typename T >
void walberla::cuda::GPUField< T >::getGhostRegion ( stencil::Direction  d,
CellInterval &  ci,
cell_idx_t  thickness,
bool  fullSlice 
) const
template<typename T >
void walberla::cuda::GPUField< T >::getSlice ( stencil::Direction  d,
CellInterval &  ci,
cell_idx_t  distance,
cell_idx_t  thickness,
bool  fullSlice 
) const
template<typename T >
void walberla::cuda::GPUField< T >::getSliceBeforeGhostLayer ( stencil::Direction  d,
CellInterval &  ci,
cell_idx_t  thickness,
bool  fullSlice 
) const
inline
template<typename T >
bool walberla::cuda::GPUField< T >::hasSameAllocSize ( const GPUField< T > &  other) const

True if allocation sizes of all dimensions match.

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

True if sizes of all dimensions match.

template<typename T >
bool walberla::cuda::GPUField< T >::isPitchedMem ( ) const
inline
template<typename T >
Layout walberla::cuda::GPUField< T >::layout ( ) const
inline
template<typename T >
uint_t walberla::cuda::GPUField< T >::nrOfGhostLayers ( ) const
inline
template<typename T >
bool walberla::cuda::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.

template<typename T >
cudaPitchedPtr walberla::cuda::GPUField< T >::pitchedPtr ( ) const
inline
template<typename T >
uint_t walberla::cuda::GPUField< T >::size ( ) const
inline
template<typename T >
uint_t walberla::cuda::GPUField< T >::size ( uint_t  coord) const
inline
template<typename T >
uint_t walberla::cuda::GPUField< T >::sizeWithGhostLayer ( uint_t  i) const
inline
template<typename T >
void walberla::cuda::GPUField< T >::swapDataPointers ( GPUField< T > &  other)
template<typename T >
void walberla::cuda::GPUField< T >::swapDataPointers ( GPUField< T > *  other)
inline
template<typename T >
uint_t walberla::cuda::GPUField< T >::xAllocSize ( ) const
template<typename T >
cell_idx_t walberla::cuda::GPUField< T >::xOff ( ) const
inline
template<typename T >
uint_t walberla::cuda::GPUField< T >::xSize ( ) const
inline
template<typename T >
uint_t walberla::cuda::GPUField< T >::xSizeWithGhostLayer ( ) const
inline
template<typename T >
cell_idx_t walberla::cuda::GPUField< T >::xStride ( ) const
inline
template<typename T >
CellInterval walberla::cuda::GPUField< T >::xyzSize ( ) const
inline
template<typename T >
CellInterval walberla::cuda::GPUField< T >::xyzSizeWithGhostLayer ( ) const
inline
template<typename T >
uint_t walberla::cuda::GPUField< T >::yAllocSize ( ) const
template<typename T >
cell_idx_t walberla::cuda::GPUField< T >::yOff ( ) const
inline
template<typename T >
uint_t walberla::cuda::GPUField< T >::ySize ( ) const
inline
template<typename T >
uint_t walberla::cuda::GPUField< T >::ySizeWithGhostLayer ( ) const
inline
template<typename T >
cell_idx_t walberla::cuda::GPUField< T >::yStride ( ) const
inline
template<typename T >
uint_t walberla::cuda::GPUField< T >::zAllocSize ( ) const
template<typename T >
cell_idx_t walberla::cuda::GPUField< T >::zOff ( ) const
inline
template<typename T >
uint_t walberla::cuda::GPUField< T >::zSize ( ) const
inline
template<typename T >
uint_t walberla::cuda::GPUField< T >::zSizeWithGhostLayer ( ) const
inline
template<typename T >
cell_idx_t walberla::cuda::GPUField< T >::zStride ( ) const
inline

Member Data Documentation

template<typename T >
uint_t walberla::cuda::GPUField< T >::fAllocSize_
protected
template<typename T >
uint_t walberla::cuda::GPUField< T >::fSize_
protected
template<typename T >
Layout walberla::cuda::GPUField< T >::layout_
protected
template<typename T >
uint_t walberla::cuda::GPUField< T >::nrOfGhostLayers_
protected
template<typename T >
cudaPitchedPtr walberla::cuda::GPUField< T >::pitchedPtr_
protected
template<typename T >
bool walberla::cuda::GPUField< T >::usePitchedMem_
protected
template<typename T >
uint_t walberla::cuda::GPUField< T >::xAllocSize_
protected
template<typename T >
uint_t walberla::cuda::GPUField< T >::xSize_
protected
template<typename T >
uint_t walberla::cuda::GPUField< T >::ySize_
protected
template<typename T >
uint_t walberla::cuda::GPUField< T >::zSize_
protected

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