KokkosNDLambdaWrapperReduction< dim, FUN > Struct Template Reference#

DiFfRG: DiFfRG::KokkosNDLambdaWrapperReduction< dim, FUN > Struct Template Reference
DiFfRG
DiFfRG::KokkosNDLambdaWrapperReduction< dim, FUN > Struct Template Reference

This is a functor which wraps a lambda for reduction. Basically, this is necessary when one wants to call a variadic lambda on an NVIDIA GPU. CUDA seems to be unable to expand the variadic arguments - in contrast, a direct approach does indeed work for openMP or serial compilation. To get around this limitation, the KokkosNDLambdaWrapperReduction packs the indices into an array. Uses compile-time index sequences to extract the first dim args as indices and the last arg as the reduction value, avoiding recursive tuple_first/tuple_cat overhead per GPU thread. More...

#include <kokkos.hh>

Public Member Functions

KOKKOS_FUNCTION KokkosNDLambdaWrapperReduction (const FUN &_fun)
 
template<typename... Args>
requires (sizeof...(Args) == dim + 1)
KOKKOS_FORCEINLINE_FUNCTION void operator() (Args &&...args) const
 

Public Attributes

FUN fun
 

Private Member Functions

template<size_t... Is, typename... Args>
KOKKOS_FORCEINLINE_FUNCTION void impl (device::integer_sequence< size_t, Is... >, Args &&...args) const
 

Detailed Description

template<int dim, typename FUN>
struct DiFfRG::KokkosNDLambdaWrapperReduction< dim, FUN >

This is a functor which wraps a lambda for reduction. Basically, this is necessary when one wants to call a variadic lambda on an NVIDIA GPU. CUDA seems to be unable to expand the variadic arguments - in contrast, a direct approach does indeed work for openMP or serial compilation. To get around this limitation, the KokkosNDLambdaWrapperReduction packs the indices into an array. Uses compile-time index sequences to extract the first dim args as indices and the last arg as the reduction value, avoiding recursive tuple_first/tuple_cat overhead per GPU thread.

Template Parameters
dimNumber of arguments taken
FUNThe lambda to which we forward the indices

Constructor & Destructor Documentation

◆ KokkosNDLambdaWrapperReduction()

template<int dim, typename FUN >
KOKKOS_FUNCTION DiFfRG::KokkosNDLambdaWrapperReduction< dim, FUN >::KokkosNDLambdaWrapperReduction ( const FUN & _fun)
inline

Member Function Documentation

◆ impl()

template<int dim, typename FUN >
template<size_t... Is, typename... Args>
KOKKOS_FORCEINLINE_FUNCTION void DiFfRG::KokkosNDLambdaWrapperReduction< dim, FUN >::impl ( device::integer_sequence< size_t, Is... > ,
Args &&... args ) const
inlineprivate

◆ operator()()

template<int dim, typename FUN >
template<typename... Args>
requires (sizeof...(Args) == dim + 1)
KOKKOS_FORCEINLINE_FUNCTION void DiFfRG::KokkosNDLambdaWrapperReduction< dim, FUN >::operator() ( Args &&... args) const
inline

Member Data Documentation

◆ fun

template<int dim, typename FUN >
FUN DiFfRG::KokkosNDLambdaWrapperReduction< dim, FUN >::fun

The documentation for this struct was generated from the following file:
  • /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/common/kokkos.hh