-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add trait IsKernelArgumentTriviallyCopyable
#2198
add trait IsKernelArgumentTriviallyCopyable
#2198
Conversation
include/alpaka/kernel/Traits.hpp
Outdated
/// | ||
/// @tparam T type to check | ||
/// @{ | ||
template<typename T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding an additional template parameter typename = void
makes specialization usually simpler.
template<typename T> | |
template<typename T, typename = void> |
Instead of creating a specialization for every type, it can be generalized like:
template<typename Real>
struct IsKernelArgumentTriviallyCopyable<Real, typename std::enable_if<codi::isForwardType<Real>::value>::type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MaxSagebaum thanks for the suggestion, I think it makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You guys are going to love requires
clauses in C++20.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point I changed the template signature
include/alpaka/kernel/Traits.hpp
Outdated
}; | ||
|
||
template<typename T> | ||
constexpr bool IsKernelArgumentTriviallyCopyable_v = IsKernelArgumentTriviallyCopyable<T>::value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following the styles of the other alpaka traits (like isQueue<T>
, etc.) this should probably be
constexpr bool IsKernelArgumentTriviallyCopyable_v = IsKernelArgumentTriviallyCopyable<T>::value; | |
inline constexpr bool isKernelArgumentTriviallyCopyable = IsKernelArgumentTriviallyCopyable<T>::value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@psychocoderHPC I would follow the suggestion from @MaxSagebaum , and also change the variable template name to isKernelArgumentTriviallyCopyable<T>
.
include/alpaka/kernel/Traits.hpp
Outdated
/// | ||
/// @tparam T type to check | ||
/// @{ | ||
template<typename T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You guys are going to love requires
clauses in C++20.
include/alpaka/kernel/Traits.hpp
Outdated
}; | ||
|
||
template<typename T> | ||
constexpr bool IsKernelArgumentTriviallyCopyable_v = IsKernelArgumentTriviallyCopyable<T>::value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
d859b60
to
1373c87
Compare
include/alpaka/kernel/Traits.hpp
Outdated
// should be at least empty then (stateless). | ||
std::is_empty_v<T> || std::is_trivially_copyable_v<T>, | ||
"The kernel argument T must be trivially copyable!"); | ||
static_assert(IsKernelArgumentTriviallyCopyable_v<T>, "The kernel argument T must be trivially copyable!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static_assert(IsKernelArgumentTriviallyCopyable_v<T>, "The kernel argument T must be trivially copyable!"); | |
static_assert(isKernelArgumentTriviallyCopyable<T>, "The kernel argument T must be trivially copyable!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one fix to get it compiling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the usage to isKernelArgumentTriviallyCopyable
, alpaka uses different naming compared to std
.
e.g. isQueue
,isPlatform
, ...
fix alpaka-group#2195 Provide an alpaka specific trait to validate kernel argument conditions which can be specialized by the user for their own types and at their own risk.
1373c87
to
2bf1dba
Compare
fix #2195
Provide an alpaka specific trait to validate kernel argument conditions which can be specialized by the user for their own types and at their own risk.