SWDEV-535738 - Use the type traits implementation from __hip_internal namespace in hip headers (#471)
Bu işleme şunda yer alıyor:
işlemeyi yapan:
GitHub
ebeveyn
c2f6c98006
işleme
1bce89ca51
@@ -64,8 +64,8 @@ template <typename T, unsigned int n>
|
||||
__attribute__((always_inline)) __HOST_DEVICE__ typename HIP_vector_base<T, n>::Native_vec_*
|
||||
get_native_pointer(HIP_vector_base<T, n>& base_vec) {
|
||||
static_assert(sizeof(base_vec) == sizeof(typename HIP_vector_base<T, n>::Native_vec_));
|
||||
static_assert(std::alignment_of<HIP_vector_base<T, n>>::value ==
|
||||
std::alignment_of<typename HIP_vector_base<T, n>::Native_vec_>::value);
|
||||
static_assert(__hip_internal::alignment_of<HIP_vector_base<T, n>>::value ==
|
||||
__hip_internal::alignment_of<typename HIP_vector_base<T, n>::Native_vec_>::value);
|
||||
return reinterpret_cast<typename HIP_vector_base<T, n>::Native_vec_*>(&base_vec.x);
|
||||
};
|
||||
|
||||
@@ -73,8 +73,8 @@ template <typename T, unsigned int n>
|
||||
__attribute__((always_inline)) __HOST_DEVICE__ const typename HIP_vector_base<T, n>::Native_vec_*
|
||||
get_native_pointer(const HIP_vector_base<T, n>& base_vec) {
|
||||
static_assert(sizeof(base_vec) == sizeof(typename HIP_vector_base<T, n>::Native_vec_));
|
||||
static_assert(std::alignment_of<HIP_vector_base<T, n>>::value ==
|
||||
std::alignment_of<typename HIP_vector_base<T, n>::Native_vec_>::value);
|
||||
static_assert(__hip_internal::alignment_of<HIP_vector_base<T, n>>::value ==
|
||||
__hip_internal::alignment_of<typename HIP_vector_base<T, n>::Native_vec_>::value);
|
||||
return reinterpret_cast<const typename HIP_vector_base<T, n>::Native_vec_*>(&base_vec.x);
|
||||
};
|
||||
} // Namespace hip_impl.
|
||||
@@ -334,14 +334,15 @@ get_native_pointer(const HIP_vector_base<T, n>& base_vec) {
|
||||
|
||||
template <typename T, size_t rank, size_t... indices>
|
||||
constexpr inline __HOST_DEVICE__ HIP_vector_type<T, rank> make_vector_type_impl(
|
||||
T val, std::index_sequence<indices...>) noexcept {
|
||||
T val, __hip_internal::index_sequence<indices...>) noexcept {
|
||||
// Fills vec with vals, and ignores the indices
|
||||
return HIP_vector_type<T, rank>{((void)indices, val)...};
|
||||
}
|
||||
|
||||
template <typename T, unsigned int rank>
|
||||
constexpr inline __HOST_DEVICE__ HIP_vector_type<T, rank> make_vector_type(T val) {
|
||||
return make_vector_type_impl<T, rank>(val, std::make_index_sequence<rank>{});
|
||||
return make_vector_type_impl<T, rank>(val,
|
||||
__hip_internal::make_index_sequence_value(__hip_internal::make_index_sequence<rank>{}));
|
||||
}
|
||||
|
||||
template <typename T, unsigned int rank>
|
||||
@@ -351,7 +352,7 @@ get_native_pointer(const HIP_vector_base<T, n>& base_vec) {
|
||||
__HOST_DEVICE__
|
||||
HIP_vector_type() = default;
|
||||
template <typename U,
|
||||
typename __hip_internal::enable_if<std::is_convertible<U, T>::value>::type* = nullptr>
|
||||
typename __hip_internal::enable_if<__hip_internal::is_convertible<U, T>::value>::type* = nullptr>
|
||||
__HOST_DEVICE__ explicit constexpr HIP_vector_type(U x_) noexcept
|
||||
: HIP_vector_base<T, rank>{static_cast<T>(x_)} {}
|
||||
template < // TODO: constrain based on type as well.
|
||||
|
||||
@@ -43,6 +43,7 @@ typedef signed char int8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef signed long long int64_t;
|
||||
typedef unsigned long size_t;
|
||||
|
||||
template <class _Tp, _Tp __v> struct integral_constant {
|
||||
static constexpr const _Tp value = __v;
|
||||
@@ -181,6 +182,34 @@ template<typename _Tp>
|
||||
|
||||
template <bool B, class T, class F> struct conditional { using type = T; };
|
||||
template <class T, class F> struct conditional<false, T, F> { using type = F; };
|
||||
|
||||
template<class T>
|
||||
struct alignment_of : integral_constant<size_t, alignof(T)> {};
|
||||
|
||||
template<typename T, T... Ints>
|
||||
struct integer_sequence {
|
||||
using value_type = T;
|
||||
static constexpr size_t size() noexcept { return sizeof...(Ints); }
|
||||
};
|
||||
|
||||
template<size_t... Ints>
|
||||
using index_sequence = integer_sequence<size_t, Ints...>;
|
||||
|
||||
template<size_t N, size_t... Ints>
|
||||
struct make_index_sequence_impl : make_index_sequence_impl<N - 1, N - 1, Ints...> {};
|
||||
|
||||
template<size_t... Ints>
|
||||
struct make_index_sequence_impl<0, Ints...> {
|
||||
using type = index_sequence<Ints...>;
|
||||
};
|
||||
|
||||
template<size_t N>
|
||||
using make_index_sequence = typename make_index_sequence_impl<N>::type;
|
||||
|
||||
template <size_t... Ints>
|
||||
constexpr index_sequence<Ints...> make_index_sequence_value(index_sequence<Ints...>) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
typedef __hip_internal::uint8_t __hip_uint8_t;
|
||||
typedef __hip_internal::uint16_t __hip_uint16_t;
|
||||
|
||||
Yeni konuda referans
Bir kullanıcı engelle