Skip to content

Commit 10e07a3

Browse files
[SYCL] Implement is_group trait (#8711)
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]>
1 parent 488c7c9 commit 10e07a3

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

sycl/include/sycl/detail/type_traits.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ template <typename ElementType, access::address_space Space,
6565
class multi_ptr;
6666

6767
template <class T>
68-
inline constexpr bool is_group_v =
69-
detail::is_group<T>::value || detail::is_sub_group<T>::value;
68+
struct is_group : std::bool_constant<detail::is_group<T>::value ||
69+
detail::is_sub_group<T>::value> {};
70+
71+
template <class T> inline constexpr bool is_group_v = is_group<T>::value;
7072

7173
namespace ext::oneapi::experimental {
7274
template <class T>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %clangxx -fsycl %s
2+
3+
#include <sycl/sycl.hpp>
4+
5+
template <typename T, typename ExpectedBaseType> void Check() {
6+
static_assert(std::is_base_of_v<ExpectedBaseType, sycl::is_group<T>>);
7+
static_assert(sycl::is_group<T>::value == ExpectedBaseType::value);
8+
static_assert(sycl::is_group_v<T> == ExpectedBaseType::value);
9+
}
10+
11+
int main() {
12+
Check<sycl::group<1>, std::true_type>();
13+
Check<sycl::group<2>, std::true_type>();
14+
Check<sycl::group<3>, std::true_type>();
15+
Check<sycl::sub_group, std::true_type>();
16+
17+
Check<int, std::false_type>();
18+
Check<sycl::queue, std::false_type>();
19+
Check<sycl::device, std::false_type>();
20+
21+
return 0;
22+
}

0 commit comments

Comments
 (0)