Skip to content

Commit 337aa79

Browse files
[NFCI][SYCL] Remove sycl/detail/type_list.hpp (#16058)
We don't need to manipulate typelists, only check if a type is same as one from the list of types, for which we have a standalone C++17-based trait.
1 parent f9c4aaf commit 337aa79

14 files changed

+57
-279
lines changed

sycl/include/sycl/accessor.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <sycl/detail/owner_less_base.hpp> // for OwnerLessBase
2323
#include <sycl/detail/property_helper.hpp> // for PropWithDataKind
2424
#include <sycl/detail/property_list_base.hpp> // for PropertyListBase
25-
#include <sycl/detail/type_list.hpp> // for is_contained
2625
#include <sycl/detail/type_traits.hpp> // for const_if_const_AS
2726
#include <sycl/exception.hpp> // for make_error_code
2827
#include <sycl/ext/oneapi/accessor_property_list.hpp> // for accessor_prope...

sycl/include/sycl/builtins_utils_scalar.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <sycl/aliases.hpp>
1313
#include <sycl/detail/defines_elementary.hpp>
1414
#include <sycl/detail/generic_type_traits.hpp>
15-
#include <sycl/detail/type_list.hpp>
1615
#include <sycl/detail/type_traits.hpp>
1716
#include <sycl/half_type.hpp>
1817
#include <sycl/multi_ptr.hpp>

sycl/include/sycl/detail/generic_type_traits.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <sycl/access/access.hpp> // for decorated, address_space
1212
#include <sycl/aliases.hpp> // for half, cl_char, cl_double
1313
#include <sycl/detail/helpers.hpp> // for marray
14-
#include <sycl/detail/type_list.hpp> // for is_contained, find_sam...
1514
#include <sycl/detail/type_traits.hpp> // for is_gen_based_on_type_s...
1615
#include <sycl/half_type.hpp> // for BIsRepresentationT
1716
#include <sycl/multi_ptr.hpp> // for multi_ptr, address_spa...

sycl/include/sycl/detail/image_accessor_util.hpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <sycl/detail/array.hpp> // for array
1919
#include <sycl/detail/export.hpp> // for __SYCL_EXPORT
2020
#include <sycl/detail/generic_type_traits.hpp> // for max_v, min_v, TryToGe...
21-
#include <sycl/detail/type_list.hpp> // for is_contained, type_list
2221
#include <sycl/exception.hpp>
2322
#include <sycl/id.hpp> // for id
2423
#include <sycl/image.hpp> // for image_channel_type
@@ -35,26 +34,25 @@ inline namespace _V1 {
3534
namespace detail {
3635

3736
template <typename T>
38-
using IsValidCoordType = typename is_contained<
39-
T, boost::mp11::mp_unique<type_list<opencl::cl_int, opencl::cl_float,
40-
std::int32_t, float>>>::type;
37+
inline constexpr bool is_valid_coord_type_v =
38+
check_type_in_v<T, opencl::cl_int, opencl::cl_float, std::int32_t, float>;
4139

4240
// The formula for unnormalization coordinates:
4341
// NormalizedCoords = [UnnormalizedCoords[i] * Range[i] for i in range(0, 3)]
4442
template <typename T>
45-
std::enable_if_t<IsValidCoordType<T>::value, T>
43+
std::enable_if_t<is_valid_coord_type_v<T>, T>
4644
UnnormalizeCoordinates(const T &Coords, const range<3> &Range) {
4745
return Coords * Range[0];
4846
}
4947

5048
template <typename T>
51-
std::enable_if_t<IsValidCoordType<T>::value, vec<T, 2>>
49+
std::enable_if_t<is_valid_coord_type_v<T>, vec<T, 2>>
5250
UnnormalizeCoordinates(const vec<T, 2> &Coords, const range<3> &Range) {
5351
return {Coords.x() * Range[0], Coords.y() * Range[1]};
5452
}
5553

5654
template <typename T>
57-
std::enable_if_t<IsValidCoordType<T>::value, vec<T, 4>>
55+
std::enable_if_t<is_valid_coord_type_v<T>, vec<T, 4>>
5856
UnnormalizeCoordinates(const vec<T, 4> &Coords, const range<3> &Range) {
5957
return {Coords.x() * Range[0], Coords.y() * Range[1], Coords.z() * Range[2],
6058
0};
@@ -65,19 +63,19 @@ UnnormalizeCoordinates(const vec<T, 4> &Coords, const range<3> &Range) {
6563
// calculation won't pass 0.
6664
// Non-valid coordinates are written as 0.
6765
template <typename T>
68-
std::enable_if_t<IsValidCoordType<T>::value, float4> convertToFloat4(T Coords) {
66+
std::enable_if_t<is_valid_coord_type_v<T>, float4> convertToFloat4(T Coords) {
6967
return {static_cast<float>(Coords), 0.5f, 0.5f, 0.f};
7068
}
7169

7270
template <typename T>
73-
std::enable_if_t<IsValidCoordType<T>::value, float4>
71+
std::enable_if_t<is_valid_coord_type_v<T>, float4>
7472
convertToFloat4(vec<T, 2> Coords) {
7573
return {static_cast<float>(Coords.x()), static_cast<float>(Coords.y()), 0.5f,
7674
0.f};
7775
}
7876

7977
template <typename T>
80-
std::enable_if_t<IsValidCoordType<T>::value, float4>
78+
std::enable_if_t<is_valid_coord_type_v<T>, float4>
8179
convertToFloat4(vec<T, 4> Coords) {
8280
return {static_cast<float>(Coords.x()), static_cast<float>(Coords.y()),
8381
static_cast<float>(Coords.z()), 0.f};

sycl/include/sycl/detail/spirv.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -796,13 +796,11 @@ AtomicMax(multi_ptr<T, AddressSpace, IsDecorated> MPtr, memory_scope Scope,
796796
// variants for all scalar types
797797
#ifndef __NVPTX__
798798

799-
using ProhibitedTypesForShuffleEmulation =
800-
type_list<double, long, long long, unsigned long, unsigned long long, half>;
801-
802799
template <typename T>
803800
struct TypeIsProhibitedForShuffleEmulation
804-
: std::bool_constant<is_contained<
805-
vector_element_t<T>, ProhibitedTypesForShuffleEmulation>::value> {};
801+
: std::bool_constant<
802+
check_type_in_v<vector_element_t<T>, double, long, long long,
803+
unsigned long, unsigned long long, half>> {};
806804

807805
template <typename T>
808806
struct VecTypeIsProhibitedForShuffleEmulation

sycl/include/sycl/detail/type_list.hpp

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

sycl/include/sycl/detail/type_traits.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
#include <sycl/detail/type_traits/vec_marray_traits.hpp>
1212

13-
#include <sycl/access/access.hpp> // for decorated, address_space
14-
#include <sycl/detail/type_list.hpp> // for is_contained, find_twi...
13+
#include <sycl/access/access.hpp> // for decorated, address_space
1514

1615
#include <array> // for array
1716
#include <cstddef> // for size_t

sycl/include/sycl/detail/vector_arith.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#include <sycl/aliases.hpp> // for half, cl_char, cl_int
1212
#include <sycl/detail/generic_type_traits.hpp> // for is_sigeninteger, is_s...
13-
#include <sycl/detail/type_list.hpp> // for is_contained
1413
#include <sycl/detail/type_traits.hpp> // for is_floating_point
1514

1615
#include <sycl/ext/oneapi/bfloat16.hpp> // bfloat16

sycl/include/sycl/group_algorithm.hpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <sycl/detail/array.hpp> // for array
1212
#include <sycl/detail/helpers.hpp> // for loop
1313
#include <sycl/detail/item_base.hpp> // for id, range
14-
#include <sycl/detail/type_list.hpp> // for is_contained, type_list
1514
#include <sycl/detail/type_traits.hpp> // for remove_pointer, is_pointer
1615
#include <sycl/exception.hpp> // for make_error_code, errc, exception
1716
#include <sycl/functional.hpp> // for plus, multiplies, maximum
@@ -82,19 +81,18 @@ template <typename Group> inline auto get_local_linear_id(Group g) {
8281
}
8382

8483
// ---- is_native_op
85-
template <typename T>
86-
using native_op_list =
87-
type_list<sycl::plus<T>, sycl::bit_or<T>, sycl::bit_xor<T>,
88-
sycl::bit_and<T>, sycl::maximum<T>, sycl::minimum<T>,
89-
sycl::multiplies<T>, sycl::logical_or<T>, sycl::logical_and<T>>;
84+
template <typename BinaryOperation, typename T>
85+
inline constexpr bool is_native_binop_on_v =
86+
check_type_in_v<BinaryOperation, sycl::plus<T>, sycl::bit_or<T>,
87+
sycl::bit_xor<T>, sycl::bit_and<T>, sycl::maximum<T>,
88+
sycl::minimum<T>, sycl::multiplies<T>, sycl::logical_or<T>,
89+
sycl::logical_and<T>>;
9090

9191
template <typename T, typename BinaryOperation> struct is_native_op {
9292
static constexpr bool value =
93-
is_contained<BinaryOperation,
94-
native_op_list<std::remove_const_t<T>>>::value ||
95-
is_contained<BinaryOperation,
96-
native_op_list<std::add_const_t<T>>>::value ||
97-
is_contained<BinaryOperation, native_op_list<void>>::value;
93+
is_native_binop_on_v<BinaryOperation, std::remove_const_t<T>> ||
94+
is_native_binop_on_v<BinaryOperation, std::add_const_t<T>> ||
95+
is_native_binop_on_v<BinaryOperation, void>;
9896
};
9997

10098
// ---- is_plus

sycl/include/sycl/image.hpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <sycl/detail/owner_less_base.hpp> // for OwnerLessBase
2323
#include <sycl/detail/stl_type_traits.hpp> // for iterator_value...
2424
#include <sycl/detail/sycl_mem_obj_allocator.hpp> // for SYCLMemObjAllo...
25-
#include <sycl/detail/type_list.hpp> // for is_contained
2625
#include <sycl/event.hpp> // for event
2726
#include <sycl/exception.hpp> // for make_error_code
2827
#include <sycl/ext/oneapi/accessor_property_list.hpp> // for accessor_prope...
@@ -112,15 +111,12 @@ namespace detail {
112111

113112
class image_impl;
114113

115-
// validImageDataT: cl_int4, cl_uint4, cl_float4, cl_half4
116-
template <typename T>
117-
using is_validImageDataT = typename detail::is_contained<
118-
T, type_list<vec<opencl::cl_int, 4>, vec<opencl::cl_uint, 4>,
119-
vec<opencl::cl_float, 4>, vec<opencl::cl_half, 4>>>::type;
120-
114+
// Valid image DataT: cl_int4, cl_uint4, cl_float4, cl_half4
121115
template <typename DataT>
122-
using EnableIfImgAccDataT =
123-
typename std::enable_if_t<is_validImageDataT<DataT>::value, DataT>;
116+
using EnableIfImgAccDataT = typename std::enable_if_t<
117+
check_type_in_v<DataT, vec<opencl::cl_int, 4>, vec<opencl::cl_uint, 4>,
118+
vec<opencl::cl_float, 4>, vec<opencl::cl_half, 4>>,
119+
DataT>;
124120

125121
inline image_channel_type FormatChannelType(image_format Format) {
126122
switch (Format) {

sycl/include/sycl/types.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
1515
#include <sycl/detail/generic_type_traits.hpp> // for is_sigeninteger, is_s...
1616
#include <sycl/detail/is_device_copyable.hpp>
17-
#include <sycl/detail/type_list.hpp> // for is_contained
1817
#include <sycl/detail/type_traits.hpp> // for is_floating_point
1918
#include <sycl/exception.hpp> // for make_error_code, errc
2019
#include <sycl/half_type.hpp> // for StorageT, half, Vec16...

sycl/test/include_deps/sycl_accessor.hpp.cpp

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,14 @@
2525
// CHECK-NEXT: info/aspects_deprecated.def
2626
// CHECK-NEXT: detail/type_traits.hpp
2727
// CHECK-NEXT: detail/type_traits/vec_marray_traits.hpp
28-
// CHECK-NEXT: detail/type_list.hpp
29-
// CHECK-NEXT: detail/boost/mp11/algorithm.hpp
30-
// CHECK-NEXT: detail/boost/mp11/list.hpp
31-
// CHECK-NEXT: detail/boost/mp11/integral.hpp
32-
// CHECK-NEXT: detail/boost/mp11/version.hpp
33-
// CHECK-NEXT: detail/boost/mp11/detail/mp_value.hpp
34-
// CHECK-NEXT: detail/boost/mp11/detail/config.hpp
35-
// CHECK-NEXT: detail/boost/mp11/detail/mp_list.hpp
36-
// CHECK-NEXT: detail/boost/mp11/detail/mp_list_v.hpp
37-
// CHECK-NEXT: detail/boost/mp11/detail/mp_is_list.hpp
38-
// CHECK-NEXT: detail/boost/mp11/detail/mp_is_value_list.hpp
39-
// CHECK-NEXT: detail/boost/mp11/detail/mp_front.hpp
40-
// CHECK-NEXT: detail/boost/mp11/detail/mp_rename.hpp
41-
// CHECK-NEXT: detail/boost/mp11/detail/mp_defer.hpp
42-
// CHECK-NEXT: detail/boost/mp11/detail/mp_append.hpp
43-
// CHECK-NEXT: detail/boost/mp11/detail/mp_count.hpp
44-
// CHECK-NEXT: detail/boost/mp11/detail/mp_plus.hpp
45-
// CHECK-NEXT: detail/boost/mp11/utility.hpp
46-
// CHECK-NEXT: detail/boost/mp11/detail/mp_fold.hpp
47-
// CHECK-NEXT: detail/boost/mp11/set.hpp
48-
// CHECK-NEXT: detail/boost/mp11/function.hpp
49-
// CHECK-NEXT: detail/boost/mp11/detail/mp_min_element.hpp
50-
// CHECK-NEXT: detail/boost/mp11/detail/mp_void.hpp
51-
// CHECK-NEXT: detail/boost/mp11/detail/mp_copy_if.hpp
52-
// CHECK-NEXT: detail/boost/mp11/detail/mp_remove_if.hpp
53-
// CHECK-NEXT: detail/boost/mp11/detail/mp_map_find.hpp
54-
// CHECK-NEXT: detail/boost/mp11/detail/mp_with_index.hpp
55-
// CHECK-NEXT: stl_wrappers/cassert
56-
// CHECK-NEXT: stl_wrappers/assert.h
57-
// CHECK-NEXT: detail/boost/mp11/integer_sequence.hpp
5828
// CHECK-NEXT: buffer.hpp
5929
// CHECK-NEXT: backend_types.hpp
6030
// CHECK-NEXT: detail/array.hpp
6131
// CHECK-NEXT: exception.hpp
6232
// CHECK-NEXT: detail/string.hpp
6333
// CHECK-NEXT: detail/common.hpp
34+
// CHECK-NEXT: stl_wrappers/cassert
35+
// CHECK-NEXT: stl_wrappers/assert.h
6436
// CHECK-NEXT: detail/is_device_copyable.hpp
6537
// CHECK-NEXT: detail/owner_less_base.hpp
6638
// CHECK-NEXT: detail/impl_utils.hpp

0 commit comments

Comments
 (0)