diff --git a/sycl/include/sycl/atomic_ref.hpp b/sycl/include/sycl/atomic_ref.hpp index 7e8fc372d3a11..f20549f847e58 100644 --- a/sycl/include/sycl/atomic_ref.hpp +++ b/sycl/include/sycl/atomic_ref.hpp @@ -49,9 +49,9 @@ template struct IsValidAtomicRefAddressSpace { // DefaultOrder parameter is limited to read-modify-write orders template -using IsValidDefaultOrder = std::bool_constant; +using IsValidDefaultOrder = bool_constant; template struct memory_order_traits; diff --git a/sycl/include/sycl/buffer.hpp b/sycl/include/sycl/buffer.hpp index f968f40ac7a6f..f1af1135e89d4 100644 --- a/sycl/include/sycl/buffer.hpp +++ b/sycl/include/sycl/buffer.hpp @@ -159,11 +159,11 @@ class buffer : public detail::buffer_plain, // using same requirement for contiguous container as std::span template using EnableIfContiguous = - std::void_t().data())> (*)[], - const T (*)[]>::value>, - decltype(std::declval().size())>; + detail::void_t().data())> (*)[], + const T (*)[]>::value>, + decltype(std::declval().size())>; template using EnableIfItInputIterator = std::enable_if_t< std::is_convertible::iterator_category, @@ -344,9 +344,9 @@ class buffer : public detail::buffer_plain, using IteratorValueType = detail::iterator_value_type_t; using IteratorNonConstValueType = - std::remove_const_t; + detail::remove_const_t; using IteratorPointerToNonConstValueType = - std::add_pointer_t; + detail::add_pointer_t; std::copy(first, last, static_cast(ToPtr)); }, @@ -377,9 +377,9 @@ class buffer : public detail::buffer_plain, using IteratorValueType = detail::iterator_value_type_t; using IteratorNonConstValueType = - std::remove_const_t; + detail::remove_const_t; using IteratorPointerToNonConstValueType = - std::add_pointer_t; + detail::add_pointer_t; std::copy(first, last, static_cast(ToPtr)); }, diff --git a/sycl/include/sycl/context.hpp b/sycl/include/sycl/context.hpp index 1b3be63396991..580a4eae12ce0 100644 --- a/sycl/include/sycl/context.hpp +++ b/sycl/include/sycl/context.hpp @@ -236,8 +236,9 @@ class __SYCL_EXPORT context : public detail::OwnerLessBase { friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject); template - friend typename std::add_pointer_t - detail::getRawSyclObjImpl(const T &SyclObject); + friend + typename detail::add_pointer_t + detail::getRawSyclObjImpl(const T &SyclObject); template friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj); diff --git a/sycl/include/sycl/detail/common.hpp b/sycl/include/sycl/detail/common.hpp index 6b4e7126b214e..999ba73056928 100644 --- a/sycl/include/sycl/detail/common.hpp +++ b/sycl/include/sycl/detail/common.hpp @@ -254,7 +254,7 @@ template decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject) { // must make sure the returned pointer is not captured in a field or otherwise // stored - i.e. must live only as on-stack value. template -typename std::add_pointer_t +typename detail::add_pointer_t getRawSyclObjImpl(const T &SyclObject) { return SyclObject.impl.get(); } diff --git a/sycl/include/sycl/detail/generic_type_lists.hpp b/sycl/include/sycl/detail/generic_type_lists.hpp index 0238d273c0999..069beffbb413c 100644 --- a/sycl/include/sycl/detail/generic_type_lists.hpp +++ b/sycl/include/sycl/detail/generic_type_lists.hpp @@ -423,39 +423,36 @@ using marray_byte_list = type_list, marray, #endif // integer types -using scalar_signed_integer_list = - type_list::value, +using scalar_signed_integer_list = type_list< + conditional_t::value, type_list, scalar_signed_char_list>, - scalar_signed_short_list, scalar_signed_int_list, - scalar_signed_long_list, scalar_signed_longlong_list>; + scalar_signed_short_list, scalar_signed_int_list, scalar_signed_long_list, + scalar_signed_longlong_list>; -using vector_signed_integer_list = - type_list::value, +using vector_signed_integer_list = type_list< + conditional_t::value, type_list, vector_signed_char_list>, - vector_signed_short_list, vector_signed_int_list, - vector_signed_long_list, vector_signed_longlong_list>; + vector_signed_short_list, vector_signed_int_list, vector_signed_long_list, + vector_signed_longlong_list>; -using marray_signed_integer_list = - type_list::value, +using marray_signed_integer_list = type_list< + conditional_t::value, type_list, marray_signed_char_list>, - marray_signed_short_list, marray_signed_int_list, - marray_signed_long_list, marray_signed_longlong_list>; + marray_signed_short_list, marray_signed_int_list, marray_signed_long_list, + marray_signed_longlong_list>; using signed_integer_list = type_list; using scalar_unsigned_integer_list = - type_list::value, - type_list, - scalar_unsigned_char_list>, + type_list::value, + type_list, + scalar_unsigned_char_list>, scalar_unsigned_short_list, scalar_unsigned_int_list, scalar_unsigned_long_list, scalar_unsigned_longlong_list #if (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0) @@ -465,10 +462,10 @@ using scalar_unsigned_integer_list = >; using vector_unsigned_integer_list = - type_list::value, - type_list, - vector_unsigned_char_list>, + type_list::value, + type_list, + vector_unsigned_char_list>, vector_unsigned_short_list, vector_unsigned_int_list, vector_unsigned_long_list, vector_unsigned_longlong_list #if (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0) @@ -478,10 +475,10 @@ using vector_unsigned_integer_list = >; using marray_unsigned_integer_list = - type_list::value, - type_list, - marray_unsigned_char_list>, + type_list::value, + type_list, + marray_unsigned_char_list>, marray_unsigned_short_list, marray_unsigned_int_list, marray_unsigned_long_list, marray_unsigned_longlong_list #if (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0) diff --git a/sycl/include/sycl/detail/generic_type_traits.hpp b/sycl/include/sycl/detail/generic_type_traits.hpp index 5377f0b669ddf..4114f55c53300 100644 --- a/sycl/include/sycl/detail/generic_type_traits.hpp +++ b/sycl/include/sycl/detail/generic_type_traits.hpp @@ -228,17 +228,17 @@ template using is_geninteger64bit = is_gen_based_on_type_sizeof; template -using is_genintptr = std::bool_constant< +using is_genintptr = bool_constant< is_pointer::value && is_genint>::value && is_address_space_compliant::value>; template -using is_genfloatptr = std::bool_constant< +using is_genfloatptr = bool_constant< is_pointer::value && is_genfloat>::value && is_address_space_compliant::value>; template -using is_genptr = std::bool_constant< +using is_genptr = bool_constant< is_pointer::value && is_gentype>::value && is_address_space_compliant::value>; @@ -424,10 +424,10 @@ using mptr_or_vec_elem_type_t = typename mptr_or_vec_elem_type::type; // select_apply_cl_scalar_t selects from T8/T16/T32/T64 basing on // sizeof(IN). expected to handle scalar types. template -using select_apply_cl_scalar_t = std::conditional_t< - sizeof(T) == 1, T8, - std::conditional_t>>; +using select_apply_cl_scalar_t = + conditional_t>>; // Shortcuts for selecting scalar int/unsigned int/fp type. template @@ -447,21 +447,21 @@ using select_cl_scalar_float_t = template using select_cl_scalar_integral_t = - std::conditional_t::value, - select_cl_scalar_integral_signed_t, - select_cl_scalar_integral_unsigned_t>; + conditional_t::value, + select_cl_scalar_integral_signed_t, + select_cl_scalar_integral_unsigned_t>; // select_cl_scalar_t picks corresponding cl_* type for input // scalar T or returns T if T is not scalar. template -using select_cl_scalar_t = std::conditional_t< +using select_cl_scalar_t = conditional_t< std::is_integral::value, select_cl_scalar_integral_t, - std::conditional_t< + conditional_t< std::is_floating_point::value, select_cl_scalar_float_t, // half is a special case: it is implemented differently on host and // device and therefore, might lower to different types - std::conditional_t::value, - sycl::detail::half_impl::BIsRepresentationT, T>>>; + conditional_t::value, + sycl::detail::half_impl::BIsRepresentationT, T>>>; // select_cl_vector_or_scalar_or_ptr does cl_* type selection for element type // of a vector type T, pointer type substitution, and scalar type substitution. @@ -476,10 +476,9 @@ struct select_cl_vector_or_scalar_or_ptr< // select_cl_scalar_t returns _Float16, so, we try to instantiate vec // class with _Float16 DataType, which is not expected there // So, leave vector as-is - vec, half>::value, - mptr_or_vec_elem_type_t, - select_cl_scalar_t>>, + vec, half>::value, + mptr_or_vec_elem_type_t, + select_cl_scalar_t>>, T::size()>; }; @@ -548,10 +547,10 @@ using SelectMatchingOpenCLType_t = // Converts T to OpenCL friendly // template -using ConvertToOpenCLType_t = std::conditional_t< +using ConvertToOpenCLType_t = conditional_t< TryToGetVectorT>::value, typename TryToGetVectorT>::type, - std::conditional_t< + conditional_t< TryToGetPointerT>::value, typename TryToGetPointerVecT>::type, SelectMatchingOpenCLType_t>>; @@ -594,12 +593,12 @@ template inline constexpr bool msbIsSet(const T x) { // TODO: marray support isn't implemented yet. template using common_rel_ret_t = - std::conditional_t::value, make_singed_integer_t, bool>; + conditional_t::value, make_singed_integer_t, bool>; // TODO: Remove this when common_rel_ret_t is promoted. template using internal_host_rel_ret_t = - std::conditional_t::value, make_singed_integer_t, int>; + conditional_t::value, make_singed_integer_t, int>; #else // SYCL 1.2.1 4.13.7 (Relation functions), e.g. // @@ -613,7 +612,7 @@ using internal_host_rel_ret_t = // Fixing it would be an ABI-breaking change so isn't done. template using common_rel_ret_t = - std::conditional_t::value, make_singed_integer_t, int>; + conditional_t::value, make_singed_integer_t, int>; template using internal_host_rel_ret_t = common_rel_ret_t; #endif diff --git a/sycl/include/sycl/detail/spirv.hpp b/sycl/include/sycl/detail/spirv.hpp index e6c19750816dc..50de456ee52d5 100644 --- a/sycl/include/sycl/detail/spirv.hpp +++ b/sycl/include/sycl/detail/spirv.hpp @@ -105,9 +105,8 @@ template bool GroupAny(bool pred) { // Native broadcasts map directly to a SPIR-V GroupBroadcast intrinsic // FIXME: Do not special-case for half once all backends support all data types. template -using is_native_broadcast = - std::bool_constant::value && - !std::is_same::value>; +using is_native_broadcast = bool_constant::value && + !std::is_same::value>; template using EnableIfNativeBroadcast = std::enable_if_t< @@ -116,7 +115,7 @@ using EnableIfNativeBroadcast = std::enable_if_t< // Bitcast broadcasts can be implemented using a single SPIR-V GroupBroadcast // intrinsic, but require type-punning via an appropriate integer type template -using is_bitcast_broadcast = std::bool_constant< +using is_bitcast_broadcast = bool_constant< !is_native_broadcast::value && std::is_trivially_copyable::value && (sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8)>; @@ -133,9 +132,9 @@ using ConvertToNativeBroadcastType_t = select_cl_scalar_integral_unsigned_t; // - At most one 32-bit, 16-bit and 8-bit chunk left over template using is_generic_broadcast = - std::bool_constant::value && - !is_bitcast_broadcast::value && - std::is_trivially_copyable::value>; + bool_constant::value && + !is_bitcast_broadcast::value && + std::is_trivially_copyable::value>; template using EnableIfGenericBroadcast = std::enable_if_t< @@ -143,11 +142,10 @@ using EnableIfGenericBroadcast = std::enable_if_t< // FIXME: Disable widening once all backends support all data types. template -using WidenOpenCLTypeTo32_t = std::conditional_t< +using WidenOpenCLTypeTo32_t = conditional_t< std::is_same() || std::is_same(), cl_int, - std::conditional_t() || - std::is_same(), - cl_uint, T>>; + conditional_t() || std::is_same(), + cl_uint, T>>; // Broadcast with scalar local index // Work-group supports any integral type diff --git a/sycl/include/sycl/detail/stl_type_traits.hpp b/sycl/include/sycl/detail/stl_type_traits.hpp index 75ea871f4fbb6..152a0b08dcd74 100644 --- a/sycl/include/sycl/detail/stl_type_traits.hpp +++ b/sycl/include/sycl/detail/stl_type_traits.hpp @@ -17,9 +17,34 @@ namespace sycl { __SYCL_INLINE_VER_NAMESPACE(_V1) { namespace detail { -// Custom type traits. -// FIXME: Those doesn't seem to be a part of any published/future C++ standard -// so should probably be moved to a different place. +// Type traits identical to those in std in newer versions. Can be removed when +// SYCL requires a newer version of the C++ standard. +// C++14 +template +using conditional_t = typename std::conditional::type; + +template +using remove_const_t = typename std::remove_const::type; + +template using remove_cv_t = typename std::remove_cv::type; + +template +using remove_reference_t = typename std::remove_reference::type; + +template using add_pointer_t = typename std::add_pointer::type; + +// C++17 +template using bool_constant = std::integral_constant; + +template using void_t = void; + +// Custom type traits +template +using allocator_value_type_t = typename std::allocator_traits::value_type; + +template +using allocator_pointer_t = typename std::allocator_traits::pointer; + template using iterator_category_t = typename std::iterator_traits::iterator_category; @@ -37,9 +62,9 @@ using iterator_to_const_type_t = // https://en.cppreference.com/w/cpp/named_req/OutputIterator template using output_iterator_requirements = - std::void_t, - decltype(*std::declval() = - std::declval>())>; + void_t, + decltype(*std::declval() = + std::declval>())>; template struct is_output_iterator { static constexpr bool value = false; diff --git a/sycl/include/sycl/detail/type_list.hpp b/sycl/include/sycl/detail/type_list.hpp index d322c1ee822b4..441e5dfd4ba02 100644 --- a/sycl/include/sycl/detail/type_list.hpp +++ b/sycl/include/sycl/detail/type_list.hpp @@ -26,8 +26,8 @@ using empty_type_list = type_list<>; template struct is_empty_type_list - : std::conditional_t::value, - std::true_type, std::false_type> {}; + : conditional_t::value, std::true_type, + std::false_type> {}; template <> struct type_list<> {}; @@ -46,16 +46,14 @@ struct type_list, Tail2...> { public: using head = head_t>; - using tail = - std::conditional_t; + using tail = conditional_t; }; // is_contained template struct is_contained - : std::conditional_t< - std::is_same, head_t>::value, - std::true_type, is_contained>> {}; + : conditional_t, head_t>::value, + std::true_type, is_contained>> {}; template struct is_contained : std::false_type {}; @@ -73,8 +71,8 @@ template struct value_list {}; // is_contained_value template struct is_contained_value - : std::conditional_t>> {}; + : conditional_t>> {}; template struct is_contained_value> : std::false_type {}; @@ -89,21 +87,21 @@ using is_one_of_spaces = // size type predicates template -struct is_type_size_equal : std::bool_constant<(sizeof(T1) == sizeof(T2))> {}; +struct is_type_size_equal : bool_constant<(sizeof(T1) == sizeof(T2))> {}; template -struct is_type_size_greater : std::bool_constant<(sizeof(T1) > sizeof(T2))> {}; +struct is_type_size_greater : bool_constant<(sizeof(T1) > sizeof(T2))> {}; template struct is_type_size_double_of - : std::bool_constant<(sizeof(T1) == (sizeof(T2) * 2))> {}; + : bool_constant<(sizeof(T1) == (sizeof(T2) * 2))> {}; template -struct is_type_size_less : std::bool_constant<(sizeof(T1) < sizeof(T2))> {}; +struct is_type_size_less : bool_constant<(sizeof(T1) < sizeof(T2))> {}; template -struct is_type_size_half_of - : std::bool_constant<(sizeof(T1) == (sizeof(T2) / 2))> {}; +struct is_type_size_half_of : bool_constant<(sizeof(T1) == (sizeof(T2) / 2))> { +}; // find required type template class Comp, @@ -111,7 +109,7 @@ template class Comp, struct find_type { using head = head_t; using tail = typename find_type, Comp, T>::type; - using type = std::conditional_t::value, head, tail>; + using type = conditional_t::value, head, tail>; }; template