From 0771130fd67f552b799e2c6d7f232b39496a67a9 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Tue, 15 Oct 2024 09:26:53 -0700 Subject: [PATCH 1/2] [SYCL] Remove `generic_type_lists.hpp` We don't need to instantiate all the `vec`/`marray` types to implement `generic_type_traits.hpp`. --- .../sycl/detail/generic_type_lists.hpp | 477 ------------------ .../sycl/detail/generic_type_traits.hpp | 60 ++- sycl/include/sycl/detail/type_traits.hpp | 1 - .../detail/type_traits/vec_marray_traits.hpp | 4 + .../sycl/ext/oneapi/bf16_storage_builtins.hpp | 1 - .../ext/oneapi/experimental/cuda/builtins.hpp | 36 +- sycl/include/sycl/types.hpp | 1 - sycl/include/sycl/vector.hpp | 3 +- .../DotProduct/dot_product_int_test.cpp | 1 - .../DotProduct/dot_product_vec_test.cpp | 1 - sycl/test/include_deps/sycl_accessor.hpp.cpp | 1 - .../include_deps/sycl_detail_core.hpp.cpp | 1 - 12 files changed, 49 insertions(+), 538 deletions(-) delete mode 100644 sycl/include/sycl/detail/generic_type_lists.hpp diff --git a/sycl/include/sycl/detail/generic_type_lists.hpp b/sycl/include/sycl/detail/generic_type_lists.hpp deleted file mode 100644 index f212fd1df1c4f..0000000000000 --- a/sycl/include/sycl/detail/generic_type_lists.hpp +++ /dev/null @@ -1,477 +0,0 @@ -//==-------- generic_type_lists.hpp - SYCL Generic type lists --------------==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#pragma once - -#include // for address_space -#include // for type_list, address_space_list - -#include // for byte, size_t -#include // for conditional_t, is_signed_v, is_... - -// Generic type name description, which serves as a description for all valid -// types of parameters to kernel functions - -// Forward declarations -namespace sycl { -inline namespace _V1 { -template class __SYCL_EBO vec; -template class marray; - -namespace detail { -namespace half_impl { -class half; -} -} // namespace detail -using half = detail::half_impl::half; - -namespace ext::oneapi { -class bfloat16; -} -namespace detail { -namespace gtl { -// floating point types -using scalar_half_list = type_list; - -using vector_half_list = type_list, vec, vec, - vec, vec, vec>; - -using marray_half_list = - type_list, marray, marray, - marray, marray, marray>; - -using scalar_vector_half_list = tl_append; - -using half_list = - tl_append; - -using scalar_bfloat16_list = type_list; - -using vector_bfloat16_list = type_list< - vec, vec, - vec, vec, - vec, vec>; - -using marray_bfloat16_list = type_list, - marray, - marray, - marray, - marray, - marray>; - -using scalar_vector_bfloat16_list = - tl_append; - -using bfloat16_list = - tl_append; - -using scalar_float_list = type_list; - -using vector_float_list = - type_list, vec, vec, vec, - vec, vec>; - -using marray_float_list = - type_list, marray, marray, - marray, marray, marray>; - -using scalar_vector_float_list = - tl_append; - -using float_list = - tl_append; - -using scalar_double_list = type_list; - -using vector_double_list = - type_list, vec, vec, vec, - vec, vec>; - -using marray_double_list = - type_list, marray, marray, - marray, marray, marray>; - -using scalar_vector_double_list = - tl_append; - -using double_list = - tl_append; - -using scalar_floating_list = tl_append; - -using vector_floating_list = tl_append; - -using marray_floating_list = tl_append; - -using scalar_vector_floating_list = - tl_append; - -using floating_list = - tl_append; - -using scalar_default_char_list = type_list; - -using vector_default_char_list = - type_list, vec, vec, vec, - vec, vec>; - -using marray_default_char_list = - type_list, marray, marray, - marray, marray, marray>; - -using default_char_list = - tl_append; - -using scalar_signed_char_list = type_list; - -using vector_signed_char_list = - type_list, vec, vec, - vec, vec, vec>; - -using marray_signed_char_list = - type_list, marray, - marray, marray, - marray, marray>; - -using scalar_unsigned_char_list = type_list; - -using vector_unsigned_char_list = - type_list, vec, - vec, vec, - vec, vec>; - -using marray_unsigned_char_list = - type_list, marray, - marray, marray, - marray, marray>; - -// short int types -using scalar_signed_short_list = type_list; - -using vector_signed_short_list = - type_list, vec, vec, - vec, vec, - vec>; - -using marray_signed_short_list = - type_list, marray, - marray, marray, - marray, marray>; - -using scalar_unsigned_short_list = type_list; - -using vector_unsigned_short_list = - type_list, vec, - vec, vec, - vec, vec>; - -using marray_unsigned_short_list = - type_list, marray, - marray, marray, - marray, marray>; - -using unsigned_short_list = - tl_append; - -using scalar_short_list = - tl_append; - -using vector_short_list = - tl_append; - -using short_list = tl_append; - -// int types -using scalar_signed_int_list = type_list; - -using vector_signed_int_list = - type_list, vec, vec, - vec, vec, vec>; - -using marray_signed_int_list = - type_list, marray, - marray, marray, - marray, marray>; - -using signed_int_list = - tl_append; - -using scalar_unsigned_int_list = type_list; - -using vector_unsigned_int_list = - type_list, vec, vec, - vec, vec, - vec>; - -using marray_unsigned_int_list = - type_list, marray, - marray, marray, - marray, marray>; - -using unsigned_int_list = - tl_append; - -using scalar_int_list = - tl_append; - -using vector_int_list = - tl_append; - -using marray_int_list = - tl_append; - -using int_list = tl_append; - -// long types -using scalar_signed_long_list = type_list; - -using vector_signed_long_list = - type_list, vec, vec, - vec, vec, vec>; - -using marray_signed_long_list = - type_list, marray, - marray, marray, - marray, marray>; - -using signed_long_list = - tl_append; - -using scalar_unsigned_long_list = type_list; - -using vector_unsigned_long_list = - type_list, vec, - vec, vec, - vec, vec>; - -using marray_unsigned_long_list = - type_list, marray, - marray, marray, - marray, marray>; - -using unsigned_long_list = - tl_append; - -using scalar_long_list = - tl_append; - -using vector_long_list = - tl_append; - -using marray_long_list = - tl_append; - -using long_list = - tl_append; - -// long long types -using scalar_signed_longlong_list = type_list; - -using vector_signed_longlong_list = - type_list, vec, - vec, vec, - vec, vec>; - -using marray_signed_longlong_list = - type_list, marray, - marray, marray, - marray, marray>; - -using signed_longlong_list = - tl_append; - -using scalar_unsigned_longlong_list = type_list; - -using vector_unsigned_longlong_list = - type_list, vec, - vec, vec, - vec, vec>; - -using marray_unsigned_longlong_list = - type_list, marray, - marray, marray, - marray, marray>; - -using unsigned_longlong_list = - tl_append; - -using scalar_longlong_list = - tl_append; - -using vector_longlong_list = - tl_append; - -using marray_longlong_list = - tl_append; - -using longlong_list = - tl_append; - -// long integer types -using scalar_signed_long_integer_list = - tl_append; - -using vector_signed_long_integer_list = - tl_append; - -using marray_signed_long_integer_list = - tl_append; - -using signed_long_integer_list = - tl_append; - -using scalar_unsigned_long_integer_list = - tl_append; - -using vector_unsigned_long_integer_list = - tl_append; - -using marray_unsigned_long_integer_list = - tl_append; - -using unsigned_long_integer_list = tl_append; - -using scalar_long_integer_list = tl_append; - -using vector_long_integer_list = tl_append; - -using marray_long_integer_list = tl_append; - -using long_integer_list = - tl_append; - -#if (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0) -// std::byte -using scalar_byte_list = type_list; - -using vector_byte_list = - type_list, vec, vec, - vec, vec, vec>; - -using marray_byte_list = type_list, marray, - marray, marray, - marray, marray>; -#endif - -// integer types -using scalar_signed_integer_list = - tl_append, - tl_append, - scalar_signed_char_list>, - scalar_signed_short_list, scalar_signed_int_list, - scalar_signed_long_list, scalar_signed_longlong_list>; - -using vector_signed_integer_list = - tl_append, - tl_append, - vector_signed_char_list>, - vector_signed_short_list, vector_signed_int_list, - vector_signed_long_list, vector_signed_longlong_list>; - -using marray_signed_integer_list = - tl_append, - tl_append, - marray_signed_char_list>, - marray_signed_short_list, marray_signed_int_list, - marray_signed_long_list, marray_signed_longlong_list>; - -using signed_integer_list = - tl_append; - -using scalar_unsigned_integer_list = - tl_append, - tl_append, - 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) - , - scalar_byte_list -#endif - >; - -using vector_unsigned_integer_list = - tl_append, - tl_append, - 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) - , - vector_byte_list -#endif - >; - -using marray_unsigned_integer_list = - tl_append, - tl_append, - 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) - , - marray_byte_list -#endif - >; - -using unsigned_integer_list = - tl_append; - -using scalar_integer_list = - tl_append; - -using vector_integer_list = - tl_append; - -using marray_integer_list = - tl_append; - -using integer_list = - tl_append; - -// bool types - -using marray_bool_list = - type_list, marray, marray, - marray, marray, marray>; - -using scalar_bool_list = type_list; - -using bool_list = tl_append; - -} // namespace gtl -} // namespace detail -} // namespace _V1 -} // namespace sycl diff --git a/sycl/include/sycl/detail/generic_type_traits.hpp b/sycl/include/sycl/detail/generic_type_traits.hpp index 4f05d84bf864e..6d00a39304d0c 100644 --- a/sycl/include/sycl/detail/generic_type_traits.hpp +++ b/sycl/include/sycl/detail/generic_type_traits.hpp @@ -10,7 +10,6 @@ #include // for decorated, address_space #include // for half, cl_char, cl_double -#include // for nonconst_address_space... #include // for marray #include // for is_contained, find_sam... #include // for is_gen_based_on_type_s... @@ -28,51 +27,66 @@ namespace sycl { inline namespace _V1 { namespace detail { template -inline constexpr bool is_svgenfloatf_v = - is_contained_v; +using is_byte = typename +#if (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0) + std::is_same; +#else + std::false_type; +#endif + +template inline constexpr bool is_byte_v = is_byte::value; template -inline constexpr bool is_svgenfloath_v = - is_contained_v; +inline constexpr bool is_svgenfloatf_v = + std::is_same_v || + (is_vec_v && std::is_same_v, float>); template -inline constexpr bool is_genfloat_v = is_contained_v; +inline constexpr bool is_svgenfloath_v = + std::is_same_v || + (is_vec_v && std::is_same_v, half>); template inline constexpr bool is_sgenfloat_v = - is_contained_v; + check_type_in_v; template inline constexpr bool is_vgenfloat_v = - is_contained_v; + is_vec_v && is_sgenfloat_v>; template -inline constexpr bool is_geninteger_v = is_contained_v; - -template -inline constexpr bool is_sgeninteger_v = - is_contained_v; +inline constexpr bool is_genfloat_v = + is_sgenfloat_v || is_vgenfloat_v || + (is_marray_v && is_sgenfloat_v> && + is_allowed_vec_size_v>); template inline constexpr bool is_sigeninteger_v = - is_contained_v; + check_type_in_v || + (std::is_same_v && std::is_signed_v); template inline constexpr bool is_sugeninteger_v = - is_contained_v; + check_type_in_v || + (std::is_same_v && std::is_unsigned_v) || is_byte_v; template -inline constexpr bool is_genbool_v = is_contained_v; +inline constexpr bool is_sgeninteger_v = + is_sigeninteger_v || is_sugeninteger_v; template -using is_byte = typename -#if (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0) - std::is_same; -#else - std::false_type; -#endif +inline constexpr bool is_geninteger_v = + is_sgeninteger_v || + (is_vec_v && is_sgeninteger_v>) || + (is_marray_v && is_sgeninteger_v> && + is_allowed_vec_size_v>); -template inline constexpr bool is_byte_v = is_byte::value; +template +inline constexpr bool is_genbool_v = + std::is_same_v || + (is_marray_v && std::is_same_v, bool> && + is_allowed_vec_size_v>); template using fixed_width_unsigned = std::conditional_t< diff --git a/sycl/include/sycl/detail/type_traits.hpp b/sycl/include/sycl/detail/type_traits.hpp index 17eb9faba79c4..df5f9ea53a045 100644 --- a/sycl/include/sycl/detail/type_traits.hpp +++ b/sycl/include/sycl/detail/type_traits.hpp @@ -11,7 +11,6 @@ #include #include // for decorated, address_space -#include // for vec, marray, integer_list #include // for is_contained, find_twi... #include // for array diff --git a/sycl/include/sycl/detail/type_traits/vec_marray_traits.hpp b/sycl/include/sycl/detail/type_traits/vec_marray_traits.hpp index cac13bc73de33..8097451352e75 100644 --- a/sycl/include/sycl/detail/type_traits/vec_marray_traits.hpp +++ b/sycl/include/sycl/detail/type_traits/vec_marray_traits.hpp @@ -99,6 +99,10 @@ struct element_type { #endif template using element_type_t = typename element_type::type; +template +inline constexpr bool is_allowed_vec_size_v = + N == 1 || N == 2 || N == 3 || N == 4 || N == 8 || N == 16; + } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/include/sycl/ext/oneapi/bf16_storage_builtins.hpp b/sycl/include/sycl/ext/oneapi/bf16_storage_builtins.hpp index ee1bea39cae69..4352705693730 100644 --- a/sycl/include/sycl/ext/oneapi/bf16_storage_builtins.hpp +++ b/sycl/include/sycl/ext/oneapi/bf16_storage_builtins.hpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include diff --git a/sycl/include/sycl/ext/oneapi/experimental/cuda/builtins.hpp b/sycl/include/sycl/ext/oneapi/experimental/cuda/builtins.hpp index 23b0eeeb814e2..c85bbcc84f721 100644 --- a/sycl/include/sycl/ext/oneapi/experimental/cuda/builtins.hpp +++ b/sycl/include/sycl/ext/oneapi/experimental/cuda/builtins.hpp @@ -25,37 +25,15 @@ namespace oneapi { namespace experimental { namespace cuda { -namespace detail { -using ldg_vector_types = sycl::detail::type_list< - sycl::vec, sycl::vec, sycl::vec, - sycl::vec, sycl::vec, - sycl::vec, sycl::vec, sycl::vec, - sycl::vec, sycl::vec, sycl::vec, - sycl::vec, sycl::vec, sycl::vec, - sycl::vec, sycl::vec, sycl::vec, - sycl::vec, sycl::vec, - sycl::vec, sycl::vec, - sycl::vec, sycl::vec, - sycl::vec, sycl::vec, - sycl::vec, sycl::vec, - sycl::vec, sycl::vec, - sycl::vec, sycl::vec, - sycl::vec, sycl::vec, - sycl::vec, sycl::vec, sycl::vec, - sycl::vec, sycl::vec, sycl::vec, - sycl::vec, sycl::vec, sycl::vec>; - -using ldg_types = - sycl::detail::tl_append; -} // namespace detail - template inline __SYCL_ALWAYS_INLINE std::enable_if_t< - sycl::detail::is_contained< - T, sycl::ext::oneapi::experimental::cuda::detail::ldg_types>::value, + detail::check_type_in_v, char, signed char, short, + int, long, long long, unsigned char, unsigned short, + unsigned int, unsigned long, unsigned long long, + half, float, double> && + (std::is_same_v, T> || + (detail::is_vec_v && detail::num_elements_v >= 2 && + detail::num_elements_v <= 4)), T> ldg(const T *ptr) { #if defined(__SYCL_DEVICE_ONLY__) diff --git a/sycl/include/sycl/types.hpp b/sycl/include/sycl/types.hpp index 87698c835a3ee..599ba89819241 100644 --- a/sycl/include/sycl/types.hpp +++ b/sycl/include/sycl/types.hpp @@ -12,7 +12,6 @@ #include // for half, cl_char, cl_int #include // for ArrayCreator, RepeatV... #include // for __SYCL2020_DEPRECATED -#include // for vector_basic_list #include // for is_sigeninteger, is_s... #include #include // for is_contained diff --git a/sycl/include/sycl/vector.hpp b/sycl/include/sycl/vector.hpp index baf8737f6e0d1..01e70f639e7b5 100644 --- a/sycl/include/sycl/vector.hpp +++ b/sycl/include/sycl/vector.hpp @@ -137,8 +137,7 @@ class __SYCL_EBO vec static_assert(std::is_same_v>, "DataT must be cv-unqualified"); - static_assert(NumElements == 1 || NumElements == 2 || NumElements == 3 || - NumElements == 4 || NumElements == 8 || NumElements == 16, + static_assert(detail::is_allowed_vec_size_v, "Invalid number of elements for sycl::vec: only 1, 2, 3, 4, 8 " "or 16 are supported"); static_assert(sizeof(bool) == sizeof(uint8_t), "bool size is not 1 byte"); diff --git a/sycl/test-e2e/DotProduct/dot_product_int_test.cpp b/sycl/test-e2e/DotProduct/dot_product_int_test.cpp index 41749efd13055..0a0542149d866 100644 --- a/sycl/test-e2e/DotProduct/dot_product_int_test.cpp +++ b/sycl/test-e2e/DotProduct/dot_product_int_test.cpp @@ -15,7 +15,6 @@ static int testCount = 4; static int passCount; using namespace sycl; -using namespace sycl::detail::gtl; using namespace sycl::ext::oneapi; constexpr int RangeLength = 100; diff --git a/sycl/test-e2e/DotProduct/dot_product_vec_test.cpp b/sycl/test-e2e/DotProduct/dot_product_vec_test.cpp index a83774d712e40..28ac47cc66993 100644 --- a/sycl/test-e2e/DotProduct/dot_product_vec_test.cpp +++ b/sycl/test-e2e/DotProduct/dot_product_vec_test.cpp @@ -15,7 +15,6 @@ static int testCount = 4; static int passCount; using namespace sycl; -using namespace sycl::detail::gtl; using namespace sycl::ext::oneapi; constexpr int RangeLength = 100; diff --git a/sycl/test/include_deps/sycl_accessor.hpp.cpp b/sycl/test/include_deps/sycl_accessor.hpp.cpp index fd5f7b86ad79a..622ea90da7006 100644 --- a/sycl/test/include_deps/sycl_accessor.hpp.cpp +++ b/sycl/test/include_deps/sycl_accessor.hpp.cpp @@ -25,7 +25,6 @@ // CHECK-NEXT: info/aspects_deprecated.def // CHECK-NEXT: detail/type_traits.hpp // CHECK-NEXT: detail/type_traits/vec_marray_traits.hpp -// CHECK-NEXT: detail/generic_type_lists.hpp // CHECK-NEXT: detail/type_list.hpp // CHECK-NEXT: detail/boost/mp11/algorithm.hpp // CHECK-NEXT: detail/boost/mp11/list.hpp diff --git a/sycl/test/include_deps/sycl_detail_core.hpp.cpp b/sycl/test/include_deps/sycl_detail_core.hpp.cpp index 16d3cd5cfbbca..d7141579c0f48 100644 --- a/sycl/test/include_deps/sycl_detail_core.hpp.cpp +++ b/sycl/test/include_deps/sycl_detail_core.hpp.cpp @@ -26,7 +26,6 @@ // CHECK-NEXT: info/aspects_deprecated.def // CHECK-NEXT: detail/type_traits.hpp // CHECK-NEXT: detail/type_traits/vec_marray_traits.hpp -// CHECK-NEXT: detail/generic_type_lists.hpp // CHECK-NEXT: detail/type_list.hpp // CHECK-NEXT: detail/boost/mp11/algorithm.hpp // CHECK-NEXT: detail/boost/mp11/list.hpp From 097a0728c625b8c6388bc3bb87c655a59b544c4f Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Wed, 16 Oct 2024 08:45:35 -0700 Subject: [PATCH 2/2] Fix check-sycl --- sycl/include/sycl/ext/oneapi/experimental/cuda/builtins.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sycl/include/sycl/ext/oneapi/experimental/cuda/builtins.hpp b/sycl/include/sycl/ext/oneapi/experimental/cuda/builtins.hpp index c85bbcc84f721..067e238c2e36c 100644 --- a/sycl/include/sycl/ext/oneapi/experimental/cuda/builtins.hpp +++ b/sycl/include/sycl/ext/oneapi/experimental/cuda/builtins.hpp @@ -24,6 +24,9 @@ namespace ext { namespace oneapi { namespace experimental { namespace cuda { +namespace detail { +using namespace sycl::detail; +} template inline __SYCL_ALWAYS_INLINE std::enable_if_t<