Skip to content

Commit 37c6766

Browse files
[SYCL] Remove generic_type_lists.hpp (#15714)
We don't need to instantiate all the `vec`/`marray` types to implement `generic_type_traits.hpp`.
1 parent e19e557 commit 37c6766

File tree

12 files changed

+51
-537
lines changed

12 files changed

+51
-537
lines changed

sycl/include/sycl/detail/generic_type_lists.hpp

Lines changed: 0 additions & 477 deletions
This file was deleted.

sycl/include/sycl/detail/generic_type_traits.hpp

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#include <sycl/access/access.hpp> // for decorated, address_space
1212
#include <sycl/aliases.hpp> // for half, cl_char, cl_double
13-
#include <sycl/detail/generic_type_lists.hpp> // for nonconst_address_space...
1413
#include <sycl/detail/helpers.hpp> // for marray
1514
#include <sycl/detail/type_list.hpp> // for is_contained, find_sam...
1615
#include <sycl/detail/type_traits.hpp> // for is_gen_based_on_type_s...
@@ -28,51 +27,66 @@ namespace sycl {
2827
inline namespace _V1 {
2928
namespace detail {
3029
template <typename T>
31-
inline constexpr bool is_svgenfloatf_v =
32-
is_contained_v<T, gtl::scalar_vector_float_list>;
30+
using is_byte = typename
31+
#if (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
32+
std::is_same<T, std::byte>;
33+
#else
34+
std::false_type;
35+
#endif
36+
37+
template <typename T> inline constexpr bool is_byte_v = is_byte<T>::value;
3338

3439
template <typename T>
35-
inline constexpr bool is_svgenfloath_v =
36-
is_contained_v<T, gtl::scalar_vector_half_list>;
40+
inline constexpr bool is_svgenfloatf_v =
41+
std::is_same_v<T, float> ||
42+
(is_vec_v<T> && std::is_same_v<element_type_t<T>, float>);
3743

3844
template <typename T>
39-
inline constexpr bool is_genfloat_v = is_contained_v<T, gtl::floating_list>;
45+
inline constexpr bool is_svgenfloath_v =
46+
std::is_same_v<T, half> ||
47+
(is_vec_v<T> && std::is_same_v<element_type_t<T>, half>);
4048

4149
template <typename T>
4250
inline constexpr bool is_sgenfloat_v =
43-
is_contained_v<T, gtl::scalar_floating_list>;
51+
check_type_in_v<T, float, double, half, ext::oneapi::bfloat16>;
4452

4553
template <typename T>
4654
inline constexpr bool is_vgenfloat_v =
47-
is_contained_v<T, gtl::vector_floating_list>;
55+
is_vec_v<T> && is_sgenfloat_v<element_type_t<T>>;
4856

4957
template <typename T>
50-
inline constexpr bool is_geninteger_v = is_contained_v<T, gtl::integer_list>;
51-
52-
template <typename T>
53-
inline constexpr bool is_sgeninteger_v =
54-
is_contained_v<T, gtl::scalar_integer_list>;
58+
inline constexpr bool is_genfloat_v =
59+
is_sgenfloat_v<T> || is_vgenfloat_v<T> ||
60+
(is_marray_v<T> && is_sgenfloat_v<element_type_t<T>> &&
61+
is_allowed_vec_size_v<num_elements_v<T>>);
5562

5663
template <typename T>
5764
inline constexpr bool is_sigeninteger_v =
58-
is_contained_v<T, gtl::scalar_signed_integer_list>;
65+
check_type_in_v<T, signed char, short, int, long, long long> ||
66+
(std::is_same_v<T, char> && std::is_signed_v<char>);
5967

6068
template <typename T>
6169
inline constexpr bool is_sugeninteger_v =
62-
is_contained_v<T, gtl::scalar_unsigned_integer_list>;
70+
check_type_in_v<T, unsigned char, unsigned short, unsigned int,
71+
unsigned long, unsigned long long> ||
72+
(std::is_same_v<T, char> && std::is_unsigned_v<char>) || is_byte_v<T>;
6373

6474
template <typename T>
65-
inline constexpr bool is_genbool_v = is_contained_v<T, gtl::bool_list>;
75+
inline constexpr bool is_sgeninteger_v =
76+
is_sigeninteger_v<T> || is_sugeninteger_v<T>;
6677

6778
template <typename T>
68-
using is_byte = typename
69-
#if (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
70-
std::is_same<T, std::byte>;
71-
#else
72-
std::false_type;
73-
#endif
79+
inline constexpr bool is_geninteger_v =
80+
is_sgeninteger_v<T> ||
81+
(is_vec_v<T> && is_sgeninteger_v<element_type_t<T>>) ||
82+
(is_marray_v<T> && is_sgeninteger_v<element_type_t<T>> &&
83+
is_allowed_vec_size_v<num_elements_v<T>>);
7484

75-
template <typename T> inline constexpr bool is_byte_v = is_byte<T>::value;
85+
template <typename T>
86+
inline constexpr bool is_genbool_v =
87+
std::is_same_v<T, bool> ||
88+
(is_marray_v<T> && std::is_same_v<element_type_t<T>, bool> &&
89+
is_allowed_vec_size_v<num_elements_v<T>>);
7690

7791
template <int Size>
7892
using fixed_width_unsigned = std::conditional_t<

sycl/include/sycl/detail/type_traits.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <sycl/detail/type_traits/vec_marray_traits.hpp>
1212

1313
#include <sycl/access/access.hpp> // for decorated, address_space
14-
#include <sycl/detail/generic_type_lists.hpp> // for vec, marray, integer_list
1514
#include <sycl/detail/type_list.hpp> // for is_contained, find_twi...
1615

1716
#include <array> // for array

sycl/include/sycl/detail/type_traits/vec_marray_traits.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ struct element_type<T __attribute__((ext_vector_type(N)))> {
9999
#endif
100100
template <typename T> using element_type_t = typename element_type<T>::type;
101101

102+
template <int N>
103+
inline constexpr bool is_allowed_vec_size_v =
104+
N == 1 || N == 2 || N == 3 || N == 4 || N == 8 || N == 16;
105+
102106
} // namespace detail
103107
} // namespace _V1
104108
} // namespace sycl

sycl/include/sycl/ext/oneapi/bf16_storage_builtins.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <sycl/__spirv/spirv_ops.hpp>
1212
#include <sycl/builtins.hpp>
1313
#include <sycl/detail/builtins/builtins.hpp>
14-
#include <sycl/detail/generic_type_lists.hpp>
1514
#include <sycl/detail/generic_type_traits.hpp>
1615
#include <sycl/detail/type_traits.hpp>
1716

sycl/include/sycl/ext/oneapi/experimental/cuda/builtins.hpp

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,19 @@ namespace ext {
2424
namespace oneapi {
2525
namespace experimental {
2626
namespace cuda {
27-
2827
namespace detail {
29-
using ldg_vector_types = sycl::detail::type_list<
30-
sycl::vec<char, 2>, sycl::vec<char, 3>, sycl::vec<char, 4>,
31-
sycl::vec<signed char, 2>, sycl::vec<signed char, 3>,
32-
sycl::vec<signed char, 4>, sycl::vec<short, 2>, sycl::vec<short, 3>,
33-
sycl::vec<short, 4>, sycl::vec<int, 2>, sycl::vec<int, 3>,
34-
sycl::vec<int, 4>, sycl::vec<long, 2>, sycl::vec<long, 3>,
35-
sycl::vec<long, 4>, sycl::vec<long long, 2>, sycl::vec<long long, 3>,
36-
sycl::vec<long long, 4>, sycl::vec<unsigned char, 2>,
37-
sycl::vec<unsigned char, 3>, sycl::vec<unsigned char, 4>,
38-
sycl::vec<unsigned short, 2>, sycl::vec<unsigned short, 3>,
39-
sycl::vec<unsigned short, 4>, sycl::vec<unsigned int, 2>,
40-
sycl::vec<unsigned int, 3>, sycl::vec<unsigned int, 4>,
41-
sycl::vec<unsigned long, 2>, sycl::vec<unsigned long, 3>,
42-
sycl::vec<unsigned long, 4>, sycl::vec<unsigned long long, 2>,
43-
sycl::vec<unsigned long long, 3>, sycl::vec<unsigned long long, 4>,
44-
sycl::vec<half, 2>, sycl::vec<half, 3>, sycl::vec<half, 4>,
45-
sycl::vec<float, 2>, sycl::vec<float, 3>, sycl::vec<float, 4>,
46-
sycl::vec<double, 2>, sycl::vec<double, 3>, sycl::vec<double, 4>>;
47-
48-
using ldg_types =
49-
sycl::detail::tl_append<ldg_vector_types,
50-
sycl::detail::gtl::scalar_floating_list,
51-
sycl::detail::gtl::scalar_signed_integer_list,
52-
sycl::detail::gtl::scalar_unsigned_integer_list>;
53-
} // namespace detail
28+
using namespace sycl::detail;
29+
}
5430

5531
template <typename T>
5632
inline __SYCL_ALWAYS_INLINE std::enable_if_t<
57-
sycl::detail::is_contained<
58-
T, sycl::ext::oneapi::experimental::cuda::detail::ldg_types>::value,
33+
detail::check_type_in_v<detail::element_type_t<T>, char, signed char, short,
34+
int, long, long long, unsigned char, unsigned short,
35+
unsigned int, unsigned long, unsigned long long,
36+
half, float, double> &&
37+
(std::is_same_v<detail::element_type_t<T>, T> ||
38+
(detail::is_vec_v<T> && detail::num_elements_v<T> >= 2 &&
39+
detail::num_elements_v<T> <= 4)),
5940
T>
6041
ldg(const T *ptr) {
6142
#if defined(__SYCL_DEVICE_ONLY__)

sycl/include/sycl/types.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <sycl/aliases.hpp> // for half, cl_char, cl_int
1313
#include <sycl/detail/common.hpp> // for ArrayCreator, RepeatV...
1414
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
15-
#include <sycl/detail/generic_type_lists.hpp> // for vector_basic_list
1615
#include <sycl/detail/generic_type_traits.hpp> // for is_sigeninteger, is_s...
1716
#include <sycl/detail/is_device_copyable.hpp>
1817
#include <sycl/detail/type_list.hpp> // for is_contained

sycl/include/sycl/vector.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ class __SYCL_EBO vec
137137
static_assert(std::is_same_v<DataT, std::remove_cv_t<DataT>>,
138138
"DataT must be cv-unqualified");
139139

140-
static_assert(NumElements == 1 || NumElements == 2 || NumElements == 3 ||
141-
NumElements == 4 || NumElements == 8 || NumElements == 16,
140+
static_assert(detail::is_allowed_vec_size_v<NumElements>,
142141
"Invalid number of elements for sycl::vec: only 1, 2, 3, 4, 8 "
143142
"or 16 are supported");
144143
static_assert(sizeof(bool) == sizeof(uint8_t), "bool size is not 1 byte");

sycl/test-e2e/DotProduct/dot_product_int_test.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ static int testCount = 4;
1515
static int passCount;
1616

1717
using namespace sycl;
18-
using namespace sycl::detail::gtl;
1918
using namespace sycl::ext::oneapi;
2019

2120
constexpr int RangeLength = 100;

sycl/test-e2e/DotProduct/dot_product_vec_test.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ static int testCount = 4;
1515
static int passCount;
1616

1717
using namespace sycl;
18-
using namespace sycl::detail::gtl;
1918
using namespace sycl::ext::oneapi;
2019

2120
constexpr int RangeLength = 100;

0 commit comments

Comments
 (0)