Skip to content

[SYCL] Implement is_group trait #8711

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions sycl/include/sycl/detail/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ template <typename ElementType, access::address_space Space,
class multi_ptr;

template <class T>
inline constexpr bool is_group_v =
detail::is_group<T>::value || detail::is_sub_group<T>::value;
struct is_group : std::bool_constant<detail::is_group<T>::value ||
detail::is_sub_group<T>::value> {};

template <class T> inline constexpr bool is_group_v = is_group<T>::value;

namespace ext::oneapi::experimental {
template <class T>
Expand Down
22 changes: 22 additions & 0 deletions sycl/test/basic_tests/is_group_trait.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// RUN: %clangxx -fsycl %s

#include <sycl/sycl.hpp>

template <typename T, typename ExpectedBaseType> void Check() {
static_assert(std::is_base_of_v<ExpectedBaseType, sycl::is_group<T>>);
static_assert(sycl::is_group<T>::value == ExpectedBaseType::value);
static_assert(sycl::is_group_v<T> == ExpectedBaseType::value);
}

int main() {
Check<sycl::group<1>, std::true_type>();
Check<sycl::group<2>, std::true_type>();
Check<sycl::group<3>, std::true_type>();
Check<sycl::sub_group, std::true_type>();

Check<int, std::false_type>();
Check<sycl::queue, std::false_type>();
Check<sycl::device, std::false_type>();

return 0;
}