Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
477 changes: 0 additions & 477 deletions sycl/include/sycl/detail/generic_type_lists.hpp

This file was deleted.

60 changes: 37 additions & 23 deletions sycl/include/sycl/detail/generic_type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include <sycl/access/access.hpp> // for decorated, address_space
#include <sycl/aliases.hpp> // for half, cl_char, cl_double
#include <sycl/detail/generic_type_lists.hpp> // for nonconst_address_space...
#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...
Expand All @@ -28,51 +27,66 @@ namespace sycl {
inline namespace _V1 {
namespace detail {
template <typename T>
inline constexpr bool is_svgenfloatf_v =
is_contained_v<T, gtl::scalar_vector_float_list>;
using is_byte = typename
#if (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
std::is_same<T, std::byte>;
#else
std::false_type;
#endif

template <typename T> inline constexpr bool is_byte_v = is_byte<T>::value;

template <typename T>
inline constexpr bool is_svgenfloath_v =
is_contained_v<T, gtl::scalar_vector_half_list>;
inline constexpr bool is_svgenfloatf_v =
std::is_same_v<T, float> ||
(is_vec_v<T> && std::is_same_v<element_type_t<T>, float>);

template <typename T>
inline constexpr bool is_genfloat_v = is_contained_v<T, gtl::floating_list>;
inline constexpr bool is_svgenfloath_v =
std::is_same_v<T, half> ||
(is_vec_v<T> && std::is_same_v<element_type_t<T>, half>);

template <typename T>
inline constexpr bool is_sgenfloat_v =
is_contained_v<T, gtl::scalar_floating_list>;
check_type_in_v<T, float, double, half, ext::oneapi::bfloat16>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given that you replace is_contained_v with check_type_in_v its implementation should probably be changed to the is_base_of way of checking membership for best performance

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll look into that separately.


template <typename T>
inline constexpr bool is_vgenfloat_v =
is_contained_v<T, gtl::vector_floating_list>;
is_vec_v<T> && is_sgenfloat_v<element_type_t<T>>;

template <typename T>
inline constexpr bool is_geninteger_v = is_contained_v<T, gtl::integer_list>;

template <typename T>
inline constexpr bool is_sgeninteger_v =
is_contained_v<T, gtl::scalar_integer_list>;
inline constexpr bool is_genfloat_v =
is_sgenfloat_v<T> || is_vgenfloat_v<T> ||
(is_marray_v<T> && is_sgenfloat_v<element_type_t<T>> &&
is_allowed_vec_size_v<num_elements_v<T>>);

template <typename T>
inline constexpr bool is_sigeninteger_v =
is_contained_v<T, gtl::scalar_signed_integer_list>;
check_type_in_v<T, signed char, short, int, long, long long> ||
(std::is_same_v<T, char> && std::is_signed_v<char>);

template <typename T>
inline constexpr bool is_sugeninteger_v =
is_contained_v<T, gtl::scalar_unsigned_integer_list>;
check_type_in_v<T, unsigned char, unsigned short, unsigned int,
unsigned long, unsigned long long> ||
(std::is_same_v<T, char> && std::is_unsigned_v<char>) || is_byte_v<T>;

template <typename T>
inline constexpr bool is_genbool_v = is_contained_v<T, gtl::bool_list>;
inline constexpr bool is_sgeninteger_v =
is_sigeninteger_v<T> || is_sugeninteger_v<T>;

template <typename T>
using is_byte = typename
#if (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
std::is_same<T, std::byte>;
#else
std::false_type;
#endif
inline constexpr bool is_geninteger_v =
is_sgeninteger_v<T> ||
(is_vec_v<T> && is_sgeninteger_v<element_type_t<T>>) ||
(is_marray_v<T> && is_sgeninteger_v<element_type_t<T>> &&
is_allowed_vec_size_v<num_elements_v<T>>);

template <typename T> inline constexpr bool is_byte_v = is_byte<T>::value;
template <typename T>
inline constexpr bool is_genbool_v =
std::is_same_v<T, bool> ||
(is_marray_v<T> && std::is_same_v<element_type_t<T>, bool> &&
is_allowed_vec_size_v<num_elements_v<T>>);

template <int Size>
using fixed_width_unsigned = std::conditional_t<
Expand Down
1 change: 0 additions & 1 deletion sycl/include/sycl/detail/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <sycl/detail/type_traits/vec_marray_traits.hpp>

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

#include <array> // for array
Expand Down
4 changes: 4 additions & 0 deletions sycl/include/sycl/detail/type_traits/vec_marray_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ struct element_type<T __attribute__((ext_vector_type(N)))> {
#endif
template <typename T> using element_type_t = typename element_type<T>::type;

template <int N>
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
1 change: 0 additions & 1 deletion sycl/include/sycl/ext/oneapi/bf16_storage_builtins.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <sycl/__spirv/spirv_ops.hpp>
#include <sycl/builtins.hpp>
#include <sycl/detail/builtins/builtins.hpp>
#include <sycl/detail/generic_type_lists.hpp>
#include <sycl/detail/generic_type_traits.hpp>
#include <sycl/detail/type_traits.hpp>

Expand Down
37 changes: 9 additions & 28 deletions sycl/include/sycl/ext/oneapi/experimental/cuda/builtins.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,19 @@ namespace ext {
namespace oneapi {
namespace experimental {
namespace cuda {

namespace detail {
using ldg_vector_types = sycl::detail::type_list<
sycl::vec<char, 2>, sycl::vec<char, 3>, sycl::vec<char, 4>,
sycl::vec<signed char, 2>, sycl::vec<signed char, 3>,
sycl::vec<signed char, 4>, sycl::vec<short, 2>, sycl::vec<short, 3>,
sycl::vec<short, 4>, sycl::vec<int, 2>, sycl::vec<int, 3>,
sycl::vec<int, 4>, sycl::vec<long, 2>, sycl::vec<long, 3>,
sycl::vec<long, 4>, sycl::vec<long long, 2>, sycl::vec<long long, 3>,
sycl::vec<long long, 4>, sycl::vec<unsigned char, 2>,
sycl::vec<unsigned char, 3>, sycl::vec<unsigned char, 4>,
sycl::vec<unsigned short, 2>, sycl::vec<unsigned short, 3>,
sycl::vec<unsigned short, 4>, sycl::vec<unsigned int, 2>,
sycl::vec<unsigned int, 3>, sycl::vec<unsigned int, 4>,
sycl::vec<unsigned long, 2>, sycl::vec<unsigned long, 3>,
sycl::vec<unsigned long, 4>, sycl::vec<unsigned long long, 2>,
sycl::vec<unsigned long long, 3>, sycl::vec<unsigned long long, 4>,
sycl::vec<half, 2>, sycl::vec<half, 3>, sycl::vec<half, 4>,
sycl::vec<float, 2>, sycl::vec<float, 3>, sycl::vec<float, 4>,
sycl::vec<double, 2>, sycl::vec<double, 3>, sycl::vec<double, 4>>;

using ldg_types =
sycl::detail::tl_append<ldg_vector_types,
sycl::detail::gtl::scalar_floating_list,
sycl::detail::gtl::scalar_signed_integer_list,
sycl::detail::gtl::scalar_unsigned_integer_list>;
} // namespace detail
using namespace sycl::detail;
}

template <typename T>
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<detail::element_type_t<T>, char, signed char, short,
Copy link
Contributor Author

@aelovikov-intel aelovikov-intel Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this part isn't NFC in a sense that gtl::scalar_floating_list on the left included bfloat16 but the code in this file hasn't been adjusted to actually handle it when it was added there. As such, the change here is actually good.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we leave a TODO reminding it on code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, that's up to the @intel/llvm-reviewers-cuda to decide if any changes are necessary here.

int, long, long long, unsigned char, unsigned short,
unsigned int, unsigned long, unsigned long long,
half, float, double> &&
(std::is_same_v<detail::element_type_t<T>, T> ||
(detail::is_vec_v<T> && detail::num_elements_v<T> >= 2 &&
detail::num_elements_v<T> <= 4)),
T>
ldg(const T *ptr) {
#if defined(__SYCL_DEVICE_ONLY__)
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 @@ -12,7 +12,6 @@
#include <sycl/aliases.hpp> // for half, cl_char, cl_int
#include <sycl/detail/common.hpp> // for ArrayCreator, RepeatV...
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
#include <sycl/detail/generic_type_lists.hpp> // for vector_basic_list
#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
Expand Down
3 changes: 1 addition & 2 deletions sycl/include/sycl/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ class __SYCL_EBO vec
static_assert(std::is_same_v<DataT, std::remove_cv_t<DataT>>,
"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<NumElements>,
"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");
Expand Down
1 change: 0 additions & 1 deletion sycl/test-e2e/DotProduct/dot_product_int_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion sycl/test-e2e/DotProduct/dot_product_vec_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion sycl/test/include_deps/sycl_accessor.hpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion sycl/test/include_deps/sycl_detail_core.hpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading