21 #ifndef ROCPRIM_TYPE_TRAITS_HPP_ 22 #define ROCPRIM_TYPE_TRAITS_HPP_ 24 #include <type_traits> 33 BEGIN_ROCPRIM_NAMESPACE
39 : std::integral_constant<
41 std::is_floating_point<T>::value ||
42 std::is_same<::rocprim::half, typename std::remove_cv<T>::type>::value ||
43 std::is_same<::rocprim::bfloat16, typename std::remove_cv<T>::type>::value
54 : std::integral_constant<
56 std::is_arithmetic<T>::value ||
57 std::is_same<::rocprim::half, typename std::remove_cv<T>::type>::value ||
58 std::is_same<::rocprim::bfloat16, typename std::remove_cv<T>::type>::value
65 : std::integral_constant<
67 std::is_fundamental<T>::value ||
68 std::is_same<::rocprim::half, typename std::remove_cv<T>::type>::value ||
69 std::is_same<::rocprim::bfloat16, typename std::remove_cv<T>::type>::value
80 : std::integral_constant<
82 std::is_signed<T>::value ||
83 std::is_same<::rocprim::half, typename std::remove_cv<T>::type>::value ||
84 std::is_same<::rocprim::bfloat16, typename std::remove_cv<T>::type>::value
91 : std::integral_constant<
93 std::is_scalar<T>::value ||
94 std::is_same<::rocprim::half, typename std::remove_cv<T>::type>::value ||
95 std::is_same<::rocprim::bfloat16, typename std::remove_cv<T>::type>::value
102 : std::integral_constant<
104 !is_fundamental<T>::value
110 template<
typename T,
int size = 0>
116 #ifndef DOXYGEN_SHOULD_SKIP_THIS // skip specialized versions 120 typedef uint8_t unsigned_type;
127 typedef uint16_t unsigned_type;
134 typedef uint32_t unsigned_type;
140 typedef uint64_t unsigned_type;
142 #endif // DOXYGEN_SHOULD_SKIP_THIS 144 #ifndef DOXYGEN_SHOULD_SKIP_THIS 145 template<
typename T,
typename Un
signedBits>
146 ROCPRIM_DEVICE ROCPRIM_INLINE
147 auto TwiddleIn(UnsignedBits key)
148 ->
typename std::enable_if<is_floating_point<T>::value, UnsignedBits>::type
150 static const UnsignedBits HIGH_BIT = UnsignedBits(1) << ((
sizeof(UnsignedBits) * 8) - 1);
151 UnsignedBits mask = (key & HIGH_BIT) ? UnsignedBits(-1) : HIGH_BIT;
155 template<
typename T,
typename Un
signedBits>
156 static ROCPRIM_DEVICE ROCPRIM_INLINE
157 auto TwiddleIn(UnsignedBits key)
158 ->
typename std::enable_if<is_unsigned<T>::value, UnsignedBits>::type
163 template<
typename T,
typename Un
signedBits>
164 static ROCPRIM_DEVICE ROCPRIM_INLINE
165 auto TwiddleIn(UnsignedBits key)
166 ->
typename std::enable_if<is_integral<T>::value &&
is_signed<T>::value, UnsignedBits>::type
168 static const UnsignedBits HIGH_BIT = UnsignedBits(1) << ((
sizeof(UnsignedBits) * 8) - 1);
169 return key ^ HIGH_BIT;
172 template<
typename T,
typename Un
signedBits>
173 ROCPRIM_DEVICE ROCPRIM_INLINE
174 auto TwiddleOut(UnsignedBits key)
175 ->
typename std::enable_if<is_floating_point<T>::value, UnsignedBits>::type
177 static const UnsignedBits HIGH_BIT = UnsignedBits(1) << ((
sizeof(UnsignedBits) * 8) - 1);
178 UnsignedBits mask = (key & HIGH_BIT) ? HIGH_BIT : UnsignedBits(-1);
182 template<
typename T,
typename Un
signedBits>
183 static ROCPRIM_DEVICE ROCPRIM_INLINE
184 auto TwiddleOut(UnsignedBits key)
185 ->
typename std::enable_if<is_unsigned<T>::value, UnsignedBits>::type
190 template<
typename T,
typename Un
signedBits>
191 static ROCPRIM_DEVICE ROCPRIM_INLINE
192 auto TwiddleOut(UnsignedBits key)
193 ->
typename std::enable_if<is_integral<T>::value &&
is_signed<T>::value, UnsignedBits>::type
195 static const UnsignedBits HIGH_BIT = UnsignedBits(1) << ((
sizeof(UnsignedBits) * 8) - 1);
196 return key ^ HIGH_BIT;
198 #endif // DOXYGEN_SHOULD_SKIP_THIS 201 END_ROCPRIM_NAMESPACE
206 #endif // ROCPRIM_TYPE_TRAITS_HPP_ Behaves like std::is_floating_point, but also includes half-precision and bfloat16-precision floating...
Definition: type_traits.hpp:38
Used to retrieve a type that can be treated as unsigned version of the template parameter.
Definition: type_traits.hpp:111
std::is_integral< T > is_integral
Alias for std::is_integral.
Definition: type_traits.hpp:48
Behaves like std::is_fundamental, but also includes half-precision and bfloat16-precision floating po...
Definition: type_traits.hpp:64
Behaves like std::is_arithmetic, but also includes half-precision and bfloat16-precision floating poi...
Definition: type_traits.hpp:53
std::is_unsigned< T > is_unsigned
Alias for std::is_unsigned.
Definition: type_traits.hpp:74
Behaves like std::is_scalar, but also includes half-precision and bfloat16-precision floating point t...
Definition: type_traits.hpp:90
get_unsigned_bits_type< T, sizeof(T)>::unsigned_type unsigned_type
Typedefed to the unsigned type.
Definition: type_traits.hpp:113
Behaves like std::is_compound, but also supports half-precision floating point type (rocprim::half)...
Definition: type_traits.hpp:101
Behaves like std::is_signed, but also includes half-precision and bfloat16-precision floating point t...
Definition: type_traits.hpp:79