@@ -133,124 +133,63 @@ inline __SYCL_CONSTEXPR_HALF float half2Float(const uint16_t &Val) {
133133
134134namespace host_half_impl {
135135
136- // This class is legacy and it is needed only to avoid breaking ABI
136+ // The main host half class
137137class __SYCL_EXPORT half {
138138public:
139139 half () = default ;
140140 constexpr half (const half &) = default;
141141 constexpr half (half &&) = default;
142142
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)) {}
205144
206- constexpr half_v2 &operator =(const half_v2 &rhs) = default ;
145+ constexpr half &operator =(const half &rhs) = default ;
207146
208147 // Operator +=, -=, *=, /=
209- __SYCL_CONSTEXPR_HALF half_v2 &operator +=(const half_v2 &rhs) {
148+ __SYCL_CONSTEXPR_HALF half &operator +=(const half &rhs) {
210149 *this = operator float () + static_cast <float >(rhs);
211150 return *this ;
212151 }
213152
214- __SYCL_CONSTEXPR_HALF half_v2 &operator -=(const half_v2 &rhs) {
153+ __SYCL_CONSTEXPR_HALF half &operator -=(const half &rhs) {
215154 *this = operator float () - static_cast <float >(rhs);
216155 return *this ;
217156 }
218157
219- __SYCL_CONSTEXPR_HALF half_v2 &operator *=(const half_v2 &rhs) {
158+ __SYCL_CONSTEXPR_HALF half &operator *=(const half &rhs) {
220159 *this = operator float () * static_cast <float >(rhs);
221160 return *this ;
222161 }
223162
224- __SYCL_CONSTEXPR_HALF half_v2 &operator /=(const half_v2 &rhs) {
163+ __SYCL_CONSTEXPR_HALF half &operator /=(const half &rhs) {
225164 *this = operator float () / static_cast <float >(rhs);
226165 return *this ;
227166 }
228167
229168 // Operator ++, --
230- __SYCL_CONSTEXPR_HALF half_v2 &operator ++() {
169+ __SYCL_CONSTEXPR_HALF half &operator ++() {
231170 *this += 1 ;
232171 return *this ;
233172 }
234173
235- __SYCL_CONSTEXPR_HALF half_v2 operator ++(int ) {
236- half_v2 ret (*this );
174+ __SYCL_CONSTEXPR_HALF half operator ++(int ) {
175+ half ret (*this );
237176 operator ++();
238177 return ret;
239178 }
240179
241- __SYCL_CONSTEXPR_HALF half_v2 &operator --() {
180+ __SYCL_CONSTEXPR_HALF half &operator --() {
242181 *this -= 1 ;
243182 return *this ;
244183 }
245184
246- __SYCL_CONSTEXPR_HALF half_v2 operator --(int ) {
247- half_v2 ret (*this );
185+ __SYCL_CONSTEXPR_HALF half operator --(int ) {
186+ half ret (*this );
248187 operator --();
249188 return ret;
250189 }
251190
252191 // Operator neg
253- constexpr half_v2 &operator -() {
192+ constexpr half &operator -() {
254193 Buf ^= 0x8000 ;
255194 return *this ;
256195 }
@@ -261,7 +200,7 @@ class __SYCL_EXPORT half_v2 {
261200 template <typename Key> friend struct std ::hash;
262201
263202 // Initialize underlying data
264- constexpr explicit half_v2 (uint16_t x) : Buf(x) {}
203+ constexpr explicit half (uint16_t x) : Buf(x) {}
265204
266205 friend class sycl ::ext::intel::esimd::detail::WrapperElementTypeProxy;
267206
@@ -298,7 +237,7 @@ using Vec4StorageT = StorageT __attribute__((ext_vector_type(4)));
298237using Vec8StorageT = StorageT __attribute__ ((ext_vector_type(8 )));
299238using Vec16StorageT = StorageT __attribute__ ((ext_vector_type(16 )));
300239#else
301- using StorageT = detail::host_half_impl::half_v2 ;
240+ using StorageT = detail::host_half_impl::half ;
302241// No need to extract underlying data type for built-in functions operating on
303242// host
304243using BIsRepresentationT = half;
@@ -339,8 +278,8 @@ class half {
339278#ifndef __SYCL_DEVICE_ONLY__
340279 // Since StorageT and BIsRepresentationT are different on host, these two
341280 // 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; }
344283#endif // __SYCL_DEVICE_ONLY__
345284
346285 // Operator +=, -=, *=, /=
@@ -688,7 +627,7 @@ template <> struct numeric_limits<sycl::half> {
688627#ifdef __SYCL_DEVICE_ONLY__
689628 return __builtin_huge_valf ();
690629#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 ));
692631#endif
693632 }
694633
0 commit comments