Skip to content

Commit

Permalink
[NFCI][SYCL] Remove sycl/detail/type_list.hpp (#16058)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aelovikov-intel authored Nov 13, 2024
1 parent f9c4aaf commit 337aa79
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 279 deletions.
1 change: 0 additions & 1 deletion sycl/include/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <sycl/detail/owner_less_base.hpp> // for OwnerLessBase
#include <sycl/detail/property_helper.hpp> // for PropWithDataKind
#include <sycl/detail/property_list_base.hpp> // for PropertyListBase
#include <sycl/detail/type_list.hpp> // for is_contained
#include <sycl/detail/type_traits.hpp> // for const_if_const_AS
#include <sycl/exception.hpp> // for make_error_code
#include <sycl/ext/oneapi/accessor_property_list.hpp> // for accessor_prope...
Expand Down
1 change: 0 additions & 1 deletion sycl/include/sycl/builtins_utils_scalar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <sycl/aliases.hpp>
#include <sycl/detail/defines_elementary.hpp>
#include <sycl/detail/generic_type_traits.hpp>
#include <sycl/detail/type_list.hpp>
#include <sycl/detail/type_traits.hpp>
#include <sycl/half_type.hpp>
#include <sycl/multi_ptr.hpp>
Expand Down
1 change: 0 additions & 1 deletion sycl/include/sycl/detail/generic_type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <sycl/access/access.hpp> // for decorated, address_space
#include <sycl/aliases.hpp> // for half, cl_char, cl_double
#include <sycl/detail/helpers.hpp> // for marray
#include <sycl/detail/type_list.hpp> // for is_contained, find_sam...
#include <sycl/detail/type_traits.hpp> // for is_gen_based_on_type_s...
#include <sycl/half_type.hpp> // for BIsRepresentationT
#include <sycl/multi_ptr.hpp> // for multi_ptr, address_spa...
Expand Down
18 changes: 8 additions & 10 deletions sycl/include/sycl/detail/image_accessor_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <sycl/detail/array.hpp> // for array
#include <sycl/detail/export.hpp> // for __SYCL_EXPORT
#include <sycl/detail/generic_type_traits.hpp> // for max_v, min_v, TryToGe...
#include <sycl/detail/type_list.hpp> // for is_contained, type_list
#include <sycl/exception.hpp>
#include <sycl/id.hpp> // for id
#include <sycl/image.hpp> // for image_channel_type
Expand All @@ -35,26 +34,25 @@ inline namespace _V1 {
namespace detail {

template <typename T>
using IsValidCoordType = typename is_contained<
T, boost::mp11::mp_unique<type_list<opencl::cl_int, opencl::cl_float,
std::int32_t, float>>>::type;
inline constexpr bool is_valid_coord_type_v =
check_type_in_v<T, opencl::cl_int, opencl::cl_float, std::int32_t, float>;

// The formula for unnormalization coordinates:
// NormalizedCoords = [UnnormalizedCoords[i] * Range[i] for i in range(0, 3)]
template <typename T>
std::enable_if_t<IsValidCoordType<T>::value, T>
std::enable_if_t<is_valid_coord_type_v<T>, T>
UnnormalizeCoordinates(const T &Coords, const range<3> &Range) {
return Coords * Range[0];
}

template <typename T>
std::enable_if_t<IsValidCoordType<T>::value, vec<T, 2>>
std::enable_if_t<is_valid_coord_type_v<T>, vec<T, 2>>
UnnormalizeCoordinates(const vec<T, 2> &Coords, const range<3> &Range) {
return {Coords.x() * Range[0], Coords.y() * Range[1]};
}

template <typename T>
std::enable_if_t<IsValidCoordType<T>::value, vec<T, 4>>
std::enable_if_t<is_valid_coord_type_v<T>, vec<T, 4>>
UnnormalizeCoordinates(const vec<T, 4> &Coords, const range<3> &Range) {
return {Coords.x() * Range[0], Coords.y() * Range[1], Coords.z() * Range[2],
0};
Expand All @@ -65,19 +63,19 @@ UnnormalizeCoordinates(const vec<T, 4> &Coords, const range<3> &Range) {
// calculation won't pass 0.
// Non-valid coordinates are written as 0.
template <typename T>
std::enable_if_t<IsValidCoordType<T>::value, float4> convertToFloat4(T Coords) {
std::enable_if_t<is_valid_coord_type_v<T>, float4> convertToFloat4(T Coords) {
return {static_cast<float>(Coords), 0.5f, 0.5f, 0.f};
}

template <typename T>
std::enable_if_t<IsValidCoordType<T>::value, float4>
std::enable_if_t<is_valid_coord_type_v<T>, float4>
convertToFloat4(vec<T, 2> Coords) {
return {static_cast<float>(Coords.x()), static_cast<float>(Coords.y()), 0.5f,
0.f};
}

template <typename T>
std::enable_if_t<IsValidCoordType<T>::value, float4>
std::enable_if_t<is_valid_coord_type_v<T>, float4>
convertToFloat4(vec<T, 4> Coords) {
return {static_cast<float>(Coords.x()), static_cast<float>(Coords.y()),
static_cast<float>(Coords.z()), 0.f};
Expand Down
8 changes: 3 additions & 5 deletions sycl/include/sycl/detail/spirv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,13 +796,11 @@ AtomicMax(multi_ptr<T, AddressSpace, IsDecorated> MPtr, memory_scope Scope,
// variants for all scalar types
#ifndef __NVPTX__

using ProhibitedTypesForShuffleEmulation =
type_list<double, long, long long, unsigned long, unsigned long long, half>;

template <typename T>
struct TypeIsProhibitedForShuffleEmulation
: std::bool_constant<is_contained<
vector_element_t<T>, ProhibitedTypesForShuffleEmulation>::value> {};
: std::bool_constant<
check_type_in_v<vector_element_t<T>, double, long, long long,
unsigned long, unsigned long long, half>> {};

template <typename T>
struct VecTypeIsProhibitedForShuffleEmulation
Expand Down
91 changes: 0 additions & 91 deletions sycl/include/sycl/detail/type_list.hpp

This file was deleted.

3 changes: 1 addition & 2 deletions sycl/include/sycl/detail/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

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

#include <sycl/access/access.hpp> // for decorated, address_space
#include <sycl/detail/type_list.hpp> // for is_contained, find_twi...
#include <sycl/access/access.hpp> // for decorated, address_space

#include <array> // for array
#include <cstddef> // for size_t
Expand Down
1 change: 0 additions & 1 deletion sycl/include/sycl/detail/vector_arith.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include <sycl/aliases.hpp> // for half, cl_char, cl_int
#include <sycl/detail/generic_type_traits.hpp> // for is_sigeninteger, is_s...
#include <sycl/detail/type_list.hpp> // for is_contained
#include <sycl/detail/type_traits.hpp> // for is_floating_point

#include <sycl/ext/oneapi/bfloat16.hpp> // bfloat16
Expand Down
20 changes: 9 additions & 11 deletions sycl/include/sycl/group_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <sycl/detail/array.hpp> // for array
#include <sycl/detail/helpers.hpp> // for loop
#include <sycl/detail/item_base.hpp> // for id, range
#include <sycl/detail/type_list.hpp> // for is_contained, type_list
#include <sycl/detail/type_traits.hpp> // for remove_pointer, is_pointer
#include <sycl/exception.hpp> // for make_error_code, errc, exception
#include <sycl/functional.hpp> // for plus, multiplies, maximum
Expand Down Expand Up @@ -82,19 +81,18 @@ template <typename Group> inline auto get_local_linear_id(Group g) {
}

// ---- is_native_op
template <typename T>
using native_op_list =
type_list<sycl::plus<T>, sycl::bit_or<T>, sycl::bit_xor<T>,
sycl::bit_and<T>, sycl::maximum<T>, sycl::minimum<T>,
sycl::multiplies<T>, sycl::logical_or<T>, sycl::logical_and<T>>;
template <typename BinaryOperation, typename T>
inline constexpr bool is_native_binop_on_v =
check_type_in_v<BinaryOperation, sycl::plus<T>, sycl::bit_or<T>,
sycl::bit_xor<T>, sycl::bit_and<T>, sycl::maximum<T>,
sycl::minimum<T>, sycl::multiplies<T>, sycl::logical_or<T>,
sycl::logical_and<T>>;

template <typename T, typename BinaryOperation> struct is_native_op {
static constexpr bool value =
is_contained<BinaryOperation,
native_op_list<std::remove_const_t<T>>>::value ||
is_contained<BinaryOperation,
native_op_list<std::add_const_t<T>>>::value ||
is_contained<BinaryOperation, native_op_list<void>>::value;
is_native_binop_on_v<BinaryOperation, std::remove_const_t<T>> ||
is_native_binop_on_v<BinaryOperation, std::add_const_t<T>> ||
is_native_binop_on_v<BinaryOperation, void>;
};

// ---- is_plus
Expand Down
14 changes: 5 additions & 9 deletions sycl/include/sycl/image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <sycl/detail/owner_less_base.hpp> // for OwnerLessBase
#include <sycl/detail/stl_type_traits.hpp> // for iterator_value...
#include <sycl/detail/sycl_mem_obj_allocator.hpp> // for SYCLMemObjAllo...
#include <sycl/detail/type_list.hpp> // for is_contained
#include <sycl/event.hpp> // for event
#include <sycl/exception.hpp> // for make_error_code
#include <sycl/ext/oneapi/accessor_property_list.hpp> // for accessor_prope...
Expand Down Expand Up @@ -112,15 +111,12 @@ namespace detail {

class image_impl;

// validImageDataT: cl_int4, cl_uint4, cl_float4, cl_half4
template <typename T>
using is_validImageDataT = typename detail::is_contained<
T, type_list<vec<opencl::cl_int, 4>, vec<opencl::cl_uint, 4>,
vec<opencl::cl_float, 4>, vec<opencl::cl_half, 4>>>::type;

// Valid image DataT: cl_int4, cl_uint4, cl_float4, cl_half4
template <typename DataT>
using EnableIfImgAccDataT =
typename std::enable_if_t<is_validImageDataT<DataT>::value, DataT>;
using EnableIfImgAccDataT = typename std::enable_if_t<
check_type_in_v<DataT, vec<opencl::cl_int, 4>, vec<opencl::cl_uint, 4>,
vec<opencl::cl_float, 4>, vec<opencl::cl_half, 4>>,
DataT>;

inline image_channel_type FormatChannelType(image_format Format) {
switch (Format) {
Expand Down
1 change: 0 additions & 1 deletion sycl/include/sycl/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
#include <sycl/detail/generic_type_traits.hpp> // for is_sigeninteger, is_s...
#include <sycl/detail/is_device_copyable.hpp>
#include <sycl/detail/type_list.hpp> // for is_contained
#include <sycl/detail/type_traits.hpp> // for is_floating_point
#include <sycl/exception.hpp> // for make_error_code, errc
#include <sycl/half_type.hpp> // for StorageT, half, Vec16...
Expand Down
32 changes: 2 additions & 30 deletions sycl/test/include_deps/sycl_accessor.hpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,14 @@
// CHECK-NEXT: info/aspects_deprecated.def
// CHECK-NEXT: detail/type_traits.hpp
// CHECK-NEXT: detail/type_traits/vec_marray_traits.hpp
// CHECK-NEXT: detail/type_list.hpp
// CHECK-NEXT: detail/boost/mp11/algorithm.hpp
// CHECK-NEXT: detail/boost/mp11/list.hpp
// CHECK-NEXT: detail/boost/mp11/integral.hpp
// CHECK-NEXT: detail/boost/mp11/version.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_value.hpp
// CHECK-NEXT: detail/boost/mp11/detail/config.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_list.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_list_v.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_is_list.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_is_value_list.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_front.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_rename.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_defer.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_append.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_count.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_plus.hpp
// CHECK-NEXT: detail/boost/mp11/utility.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_fold.hpp
// CHECK-NEXT: detail/boost/mp11/set.hpp
// CHECK-NEXT: detail/boost/mp11/function.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_min_element.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_void.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_copy_if.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_remove_if.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_map_find.hpp
// CHECK-NEXT: detail/boost/mp11/detail/mp_with_index.hpp
// CHECK-NEXT: stl_wrappers/cassert
// CHECK-NEXT: stl_wrappers/assert.h
// CHECK-NEXT: detail/boost/mp11/integer_sequence.hpp
// CHECK-NEXT: buffer.hpp
// CHECK-NEXT: backend_types.hpp
// CHECK-NEXT: detail/array.hpp
// CHECK-NEXT: exception.hpp
// CHECK-NEXT: detail/string.hpp
// CHECK-NEXT: detail/common.hpp
// CHECK-NEXT: stl_wrappers/cassert
// CHECK-NEXT: stl_wrappers/assert.h
// CHECK-NEXT: detail/is_device_copyable.hpp
// CHECK-NEXT: detail/owner_less_base.hpp
// CHECK-NEXT: detail/impl_utils.hpp
Expand Down
Loading

0 comments on commit 337aa79

Please sign in to comment.