Wrapper class around a GPU kernel, to call kernels also from code not compiled with the device compiler.
Example:
Why use this strange wrapper class instead of the nice kernel call syntax "<<<griddim, blockdim >>>" ??
Drawbacks of this class compared to kernel call syntax: Type checking of parameters can only be done at runtime (is done only in Debug mode!). Consider the following example:
The parameter types of the kernel and the parameters added at the gpu::Kernel class do not match. This is only detected when the code is run and was compiled in DEBUG mode!
Advantages of this class compared to kernel call syntax: Integrates nicely with waLBerlas field indexing and accessor concepts:
When using at least one FieldIndexingParameter configure() does not have to be called, since the thread and grid setup is done by the indexing scheme. If two FieldIndexingParameters are passed, the two indexing schemes have to be consistent.
#include <Kernel.h>
Public Member Functions | |
Kernel (FuncPtr funcPtr) | |
template<typename T > | |
void | addParam (const T ¶m) |
template<typename T > | |
void | addFieldIndexingParam (const T &indexing) |
void | configure (dim3 gridDim, dim3 blockDim, std::size_t sharedMemSize=0) |
void | operator() (gpuStream_t stream=nullptr) const |
template<typename Indexing > | |
void | addFieldIndexingParam (const Indexing &indexing) |
Protected Attributes | |
Members | |
| |
FuncPtr | funcPtr_ |
bool | configured_ { false } |
dim3 | gridDim_ |
dim3 | blockDim_ |
std::size_t | sharedMemSize_ { 0 } |
std::vector< std::vector< char > > | params_ |
Type checking of parameters | |
typedef std::remove_pointer< FuncPtr >::type | FuncType |
template<typename T > | |
bool | checkParameter0 (typename std::enable_if<(FunctionTraits< FuncType >::arity > 0), T >::type *=0) |
template<typename T > | |
bool | checkParameter0 (typename std::enable_if<(FunctionTraits< FuncType >::arity<=0), T >::type *=0) |
template<typename T > | |
bool | checkParameter1 (typename std::enable_if<(FunctionTraits< FuncType >::arity > 1), T >::type *=0) |
template<typename T > | |
bool | checkParameter1 (typename std::enable_if<(FunctionTraits< FuncType >::arity<=1), T >::type *=0) |
template<typename T > | |
bool | checkParameter2 (typename std::enable_if<(FunctionTraits< FuncType >::arity > 2), T >::type *=0) |
template<typename T > | |
bool | checkParameter2 (typename std::enable_if<(FunctionTraits< FuncType >::arity<=2), T >::type *=0) |
template<typename T > | |
bool | checkParameter3 (typename std::enable_if<(FunctionTraits< FuncType >::arity > 3), T >::type *=0) |
template<typename T > | |
bool | checkParameter3 (typename std::enable_if<(FunctionTraits< FuncType >::arity<=3), T >::type *=0) |
template<typename T > | |
bool | checkParameter4 (typename std::enable_if<(FunctionTraits< FuncType >::arity > 4), T >::type *=0) |
template<typename T > | |
bool | checkParameter4 (typename std::enable_if<(FunctionTraits< FuncType >::arity<=4), T >::type *=0) |
template<typename T > | |
bool | checkParameter5 (typename std::enable_if<(FunctionTraits< FuncType >::arity > 5), T >::type *=0) |
template<typename T > | |
bool | checkParameter5 (typename std::enable_if<(FunctionTraits< FuncType >::arity<=5), T >::type *=0) |
template<typename T > | |
bool | checkParameter6 (typename std::enable_if<(FunctionTraits< FuncType >::arity > 6), T >::type *=0) |
template<typename T > | |
bool | checkParameter6 (typename std::enable_if<(FunctionTraits< FuncType >::arity<=6), T >::type *=0) |
template<typename T > | |
bool | checkParameter7 (typename std::enable_if<(FunctionTraits< FuncType >::arity > 7), T >::type *=0) |
template<typename T > | |
bool | checkParameter7 (typename std::enable_if<(FunctionTraits< FuncType >::arity<=7), T >::type *=0) |
template<typename T > | |
bool | checkParameter (uint_t n) |
|
protected |
walberla::gpu::Kernel< FP >::Kernel | ( | FuncPtr | funcPtr | ) |
void walberla::gpu::Kernel< FuncPtr >::addFieldIndexingParam | ( | const Indexing & | indexing | ) |
void walberla::gpu::Kernel< FuncPtr >::addFieldIndexingParam | ( | const T & | indexing | ) |
void walberla::gpu::Kernel< FP >::addParam | ( | const T & | param | ) |
|
protected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
void walberla::gpu::Kernel< FP >::configure | ( | dim3 | gridDim, |
dim3 | blockDim, | ||
std::size_t | sharedMemSize = 0 |
||
) |
void walberla::gpu::Kernel< FP >::operator() | ( | gpuStream_t | stream = nullptr | ) | const |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |