@@ -133,124 +133,63 @@ inline __SYCL_CONSTEXPR_HALF float half2Float(const uint16_t &Val) {
133
133
134
134
namespace host_half_impl {
135
135
136
- // This class is legacy and it is needed only to avoid breaking ABI
136
+ // The main host half class
137
137
class __SYCL_EXPORT half {
138
138
public:
139
139
half () = default ;
140
140
constexpr half (const half &) = default;
141
141
constexpr half (half &&) = default;
142
142
143
- half (const float &rhs);
144
-
145
- half &operator =(const half &rhs) = default ;
146
-
147
- // Operator +=, -=, *=, /=
148
- half &operator +=(const half &rhs);
149
-
150
- half &operator -=(const half &rhs);
151
-
152
- half &operator *=(const half &rhs);
153
-
154
- half &operator /=(const half &rhs);
155
-
156
- // Operator ++, --
157
- half &operator ++() {
158
- *this += 1 ;
159
- return *this ;
160
- }
161
-
162
- half operator ++(int ) {
163
- half ret (*this );
164
- operator ++();
165
- return ret;
166
- }
167
-
168
- half &operator --() {
169
- *this -= 1 ;
170
- return *this ;
171
- }
172
-
173
- half operator --(int ) {
174
- half ret (*this );
175
- operator --();
176
- return ret;
177
- }
178
-
179
- // Operator neg
180
- constexpr half &operator -() {
181
- Buf ^= 0x8000 ;
182
- return *this ;
183
- }
184
-
185
- // Operator float
186
- operator float () const ;
187
-
188
- template <typename Key> friend struct std ::hash;
189
-
190
- // Initialize underlying data
191
- constexpr explicit half (uint16_t x) : Buf(x) {}
192
-
193
- private:
194
- uint16_t Buf;
195
- };
196
-
197
- // The main host half class
198
- class __SYCL_EXPORT half_v2 {
199
- public:
200
- half_v2 () = default ;
201
- constexpr half_v2 (const half_v2 &) = default;
202
- constexpr half_v2 (half_v2 &&) = default;
203
-
204
- __SYCL_CONSTEXPR_HALF half_v2 (const float &rhs) : Buf(float2Half(rhs)) {}
143
+ __SYCL_CONSTEXPR_HALF half (const float &rhs) : Buf(float2Half(rhs)) {}
205
144
206
- constexpr half_v2 &operator =(const half_v2 &rhs) = default ;
145
+ constexpr half &operator =(const half &rhs) = default ;
207
146
208
147
// Operator +=, -=, *=, /=
209
- __SYCL_CONSTEXPR_HALF half_v2 &operator +=(const half_v2 &rhs) {
148
+ __SYCL_CONSTEXPR_HALF half &operator +=(const half &rhs) {
210
149
*this = operator float () + static_cast <float >(rhs);
211
150
return *this ;
212
151
}
213
152
214
- __SYCL_CONSTEXPR_HALF half_v2 &operator -=(const half_v2 &rhs) {
153
+ __SYCL_CONSTEXPR_HALF half &operator -=(const half &rhs) {
215
154
*this = operator float () - static_cast <float >(rhs);
216
155
return *this ;
217
156
}
218
157
219
- __SYCL_CONSTEXPR_HALF half_v2 &operator *=(const half_v2 &rhs) {
158
+ __SYCL_CONSTEXPR_HALF half &operator *=(const half &rhs) {
220
159
*this = operator float () * static_cast <float >(rhs);
221
160
return *this ;
222
161
}
223
162
224
- __SYCL_CONSTEXPR_HALF half_v2 &operator /=(const half_v2 &rhs) {
163
+ __SYCL_CONSTEXPR_HALF half &operator /=(const half &rhs) {
225
164
*this = operator float () / static_cast <float >(rhs);
226
165
return *this ;
227
166
}
228
167
229
168
// Operator ++, --
230
- __SYCL_CONSTEXPR_HALF half_v2 &operator ++() {
169
+ __SYCL_CONSTEXPR_HALF half &operator ++() {
231
170
*this += 1 ;
232
171
return *this ;
233
172
}
234
173
235
- __SYCL_CONSTEXPR_HALF half_v2 operator ++(int ) {
236
- half_v2 ret (*this );
174
+ __SYCL_CONSTEXPR_HALF half operator ++(int ) {
175
+ half ret (*this );
237
176
operator ++();
238
177
return ret;
239
178
}
240
179
241
- __SYCL_CONSTEXPR_HALF half_v2 &operator --() {
180
+ __SYCL_CONSTEXPR_HALF half &operator --() {
242
181
*this -= 1 ;
243
182
return *this ;
244
183
}
245
184
246
- __SYCL_CONSTEXPR_HALF half_v2 operator --(int ) {
247
- half_v2 ret (*this );
185
+ __SYCL_CONSTEXPR_HALF half operator --(int ) {
186
+ half ret (*this );
248
187
operator --();
249
188
return ret;
250
189
}
251
190
252
191
// Operator neg
253
- constexpr half_v2 &operator -() {
192
+ constexpr half &operator -() {
254
193
Buf ^= 0x8000 ;
255
194
return *this ;
256
195
}
@@ -261,7 +200,7 @@ class __SYCL_EXPORT half_v2 {
261
200
template <typename Key> friend struct std ::hash;
262
201
263
202
// Initialize underlying data
264
- constexpr explicit half_v2 (uint16_t x) : Buf(x) {}
203
+ constexpr explicit half (uint16_t x) : Buf(x) {}
265
204
266
205
friend class sycl ::ext::intel::esimd::detail::WrapperElementTypeProxy;
267
206
@@ -298,7 +237,7 @@ using Vec4StorageT = StorageT __attribute__((ext_vector_type(4)));
298
237
using Vec8StorageT = StorageT __attribute__ ((ext_vector_type(8 )));
299
238
using Vec16StorageT = StorageT __attribute__ ((ext_vector_type(16 )));
300
239
#else
301
- using StorageT = detail::host_half_impl::half_v2 ;
240
+ using StorageT = detail::host_half_impl::half ;
302
241
// No need to extract underlying data type for built-in functions operating on
303
242
// host
304
243
using BIsRepresentationT = half;
@@ -339,8 +278,8 @@ class half {
339
278
#ifndef __SYCL_DEVICE_ONLY__
340
279
// Since StorageT and BIsRepresentationT are different on host, these two
341
280
// helpers are required for 'vec' class
342
- constexpr half (const detail::host_half_impl::half_v2 &rhs) : Data(rhs) {}
343
- constexpr operator detail::host_half_impl::half_v2 () const { return Data; }
281
+ constexpr half (const detail::host_half_impl::half &rhs) : Data(rhs) {}
282
+ constexpr operator detail::host_half_impl::half () const { return Data; }
344
283
#endif // __SYCL_DEVICE_ONLY__
345
284
346
285
// Operator +=, -=, *=, /=
@@ -688,7 +627,7 @@ template <> struct numeric_limits<sycl::half> {
688
627
#ifdef __SYCL_DEVICE_ONLY__
689
628
return __builtin_huge_valf ();
690
629
#else
691
- return sycl::detail::host_half_impl::half_v2 (static_cast <uint16_t >(0x7C00 ));
630
+ return sycl::detail::host_half_impl::half (static_cast <uint16_t >(0x7C00 ));
692
631
#endif
693
632
}
694
633
0 commit comments