Skip to content

Commit

Permalink
[SYCL] Implement is_group trait (#8711)
Browse files Browse the repository at this point in the history
This commit adds the missing SYCL 2020 is_group trait and changes the
definition of is_group_v to be in line with SYCL 2020.

Fixes #8704.

Signed-off-by: Larsen, Steffen <[email protected]>
  • Loading branch information
steffenlarsen authored Mar 22, 2023
1 parent 488c7c9 commit 10e07a3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
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;
}

0 comments on commit 10e07a3

Please sign in to comment.