Skip to content

Commit

Permalink
add trait IsKernelTriviallyCopyable
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraPerego committed Jun 22, 2024
1 parent 7b06ada commit be63b3d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions include/alpaka/kernel/Traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,19 @@ namespace alpaka
}
} // namespace detail

template<typename T, typename = void>
struct IsKernelTriviallyCopyable
#if BOOST_COMP_NVCC
: std::bool_constant<std::is_trivially_copyable_v<T> || __nv_is_extended_device_lambda_closure_type(T) || __nv_is_extended_host_device_lambda_closure_type(T)>
#else
: std::bool_constant<std::is_trivially_copyable_v<T>>
#endif
{
};

template<typename T>
inline constexpr bool isKernelTriviallyCopyable = IsKernelTriviallyCopyable<T>::value;

//! Creates a kernel execution task.
//!
//! \tparam TAcc The accelerator type.
Expand All @@ -266,11 +279,10 @@ namespace alpaka

#if BOOST_COMP_NVCC
static_assert(
std::is_trivially_copyable_v<TKernelFnObj> || __nv_is_extended_device_lambda_closure_type(TKernelFnObj)
|| __nv_is_extended_host_device_lambda_closure_type(TKernelFnObj),
isKernelTriviallyCopyable<TKernelFnObj>,
"Kernels must be trivially copyable or an extended CUDA lambda expression!");
#else
static_assert(std::is_trivially_copyable_v<TKernelFnObj>, "Kernels must be trivially copyable!");
static_assert(isKernelTriviallyCopyable<TKernelFnObj>, "Kernels must be trivially copyable!");
#endif
(detail::assertKernelArgIsTriviallyCopyable<std::decay_t<TArgs>>(), ...);
static_assert(
Expand Down

0 comments on commit be63b3d

Please sign in to comment.