|
67 | 67 | #include <sycl/detail/helpers.hpp> |
68 | 68 | #include <sycl/detail/type_traits.hpp> |
69 | 69 | #include <sycl/detail/type_traits/vec_marray_traits.hpp> |
70 | | -#include <sycl/detail/vector_convert.hpp> |
| 70 | +#include <sycl/half_type.hpp> |
71 | 71 | #include <sycl/marray.hpp> |
72 | 72 | #include <sycl/vector.hpp> |
73 | 73 |
|
@@ -203,6 +203,28 @@ template <class T, int N> marray<T, N> to_marray(vec<T, N> X) { |
203 | 203 | return Marray; |
204 | 204 | } |
205 | 205 |
|
| 206 | +// Relation builtins widen signed-char masks to the required integer element |
| 207 | +// type. Keep that conversion local here so builtins.hpp does not need to pull |
| 208 | +// in vector_convert.hpp just for vec::convert. |
| 209 | +template <typename NewElemT, int N> |
| 210 | +vec<NewElemT, N> relational_mask_widen(vec<signed char, N> X) { |
| 211 | + static_assert(is_scalar_arithmetic_v<NewElemT>); |
| 212 | + |
| 213 | +#ifdef __SYCL_DEVICE_ONLY__ |
| 214 | + if constexpr (N > 1) { |
| 215 | + using src_vector_t = signed char __attribute__((ext_vector_type(N))); |
| 216 | + using dst_vector_t = NewElemT __attribute__((ext_vector_type(N))); |
| 217 | + auto OpenCLVec = bit_cast<src_vector_t>(X); |
| 218 | + return bit_cast<vec<NewElemT, N>>( |
| 219 | + __builtin_convertvector(OpenCLVec, dst_vector_t)); |
| 220 | + } |
| 221 | +#endif |
| 222 | + |
| 223 | + vec<NewElemT, N> Result{}; |
| 224 | + loop<N>([&](auto idx) { Result[idx] = static_cast<NewElemT>(X[idx]); }); |
| 225 | + return Result; |
| 226 | +} |
| 227 | + |
206 | 228 | namespace builtins { |
207 | 229 | #ifdef __SYCL_DEVICE_ONLY__ |
208 | 230 | template <typename T> auto convert_arg(T &&x) { |
|
0 commit comments