@@ -166,8 +166,20 @@ __esimd_convertvector_to(vector_type_t<StdTy, N> Val)
166
166
// element_type_traits<WrapperTy>::use_native_cpp_ops is false.
167
167
#else
168
168
{
169
- // TODO implement for host
170
- __ESIMD_UNSUPPORTED_ON_HOST;
169
+ vector_type_t <__raw_t <WrapperTy>, N> Output = 0 ;
170
+
171
+ if constexpr (std::is_same_v<WrapperTy, sycl::half>) {
172
+ for (int i = 0 ; i < N; i += 1 ) {
173
+ // 1. Convert Val[i] to float (x) using c++ static_cast
174
+ // 2. Convert x to half (using float2half)
175
+ // 3. Output[i] = half_of(x)
176
+ Output[i] = ::sycl::detail::float2Half (static_cast <float >(Val[i]));
177
+ }
178
+ } else {
179
+ __ESIMD_UNSUPPORTED_ON_HOST;
180
+ }
181
+
182
+ return Output;
171
183
}
172
184
#endif // __SYCL_DEVICE_ONLY__
173
185
@@ -179,8 +191,20 @@ __esimd_convertvector_from(vector_type_t<__raw_t<WrapperTy>, N> Val)
179
191
// element_type_traits<WrapperTy>::use_native_cpp_ops is false.
180
192
#else
181
193
{
182
- // TODO implement for host
183
- __ESIMD_UNSUPPORTED_ON_HOST;
194
+ vector_type_t <StdTy, N> Output;
195
+
196
+ if constexpr (std::is_same_v<WrapperTy, sycl::half>) {
197
+ for (int i = 0 ; i < N; i += 1 ) {
198
+ // 1. Convert Val[i] to float y(using half2float)
199
+ // 2. Convert y to StdTy using c++ static_cast
200
+ // 3. Store in Output[i]
201
+ Output[i] = static_cast <StdTy>(::sycl::detail::half2Float (Val[i]));
202
+ }
203
+ } else {
204
+ __ESIMD_UNSUPPORTED_ON_HOST;
205
+ }
206
+
207
+ return Output;
184
208
}
185
209
#endif // __SYCL_DEVICE_ONLY__
186
210
0 commit comments