Skip to content

Commit d9da9ff

Browse files
authored
[SYCL][ABI-break] Remove host_half_impl::half (#6527)
1 parent 94c4b80 commit d9da9ff

File tree

7 files changed

+24
-181
lines changed

7 files changed

+24
-181
lines changed

sycl/include/sycl/ext/intel/esimd/detail/elem_type_traits.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ class WrapperElementTypeProxy {
582582
template <class T = sycl::half>
583583
static inline T bitcast_to_half(__raw_t<T> Bits) {
584584
#ifndef __SYCL_DEVICE_ONLY__
585-
return sycl::half(::sycl::detail::host_half_impl::half_v2(Bits));
585+
return sycl::half(::sycl::detail::host_half_impl::half(Bits));
586586
#else
587587
sycl::half Res;
588588
Res.Data = Bits;

sycl/include/sycl/half_type.hpp

Lines changed: 19 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -133,124 +133,63 @@ inline __SYCL_CONSTEXPR_HALF float half2Float(const uint16_t &Val) {
133133

134134
namespace host_half_impl {
135135

136-
// This class is legacy and it is needed only to avoid breaking ABI
136+
// The main host half class
137137
class __SYCL_EXPORT half {
138138
public:
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)));
298237
using Vec8StorageT = StorageT __attribute__((ext_vector_type(8)));
299238
using 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
304243
using 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

sycl/include/sycl/known_identity.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ struct known_identity_impl<
166166
#ifdef __SYCL_DEVICE_ONLY__
167167
0;
168168
#else
169-
sycl::detail::host_half_impl::half_v2(static_cast<uint16_t>(0));
169+
sycl::detail::host_half_impl::half(static_cast<uint16_t>(0));
170170
#endif
171171
};
172172

@@ -206,7 +206,7 @@ struct known_identity_impl<
206206
#ifdef __SYCL_DEVICE_ONLY__
207207
1;
208208
#else
209-
sycl::detail::host_half_impl::half_v2(static_cast<uint16_t>(0x3C00));
209+
sycl::detail::host_half_impl::half(static_cast<uint16_t>(0x3C00));
210210
#endif
211211
};
212212

sycl/include/sycl/types.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,13 +702,13 @@ template <typename Type, int NumElements> class vec {
702702
using EnableIfNotHostHalf = typename detail::enable_if_t<
703703
!std::is_same<DataT, sycl::detail::half_impl::half>::value ||
704704
!std::is_same<sycl::detail::half_impl::StorageT,
705-
sycl::detail::host_half_impl::half_v2>::value,
705+
sycl::detail::host_half_impl::half>::value,
706706
T>;
707707
template <typename T = void>
708708
using EnableIfHostHalf = typename detail::enable_if_t<
709709
std::is_same<DataT, sycl::detail::half_impl::half>::value &&
710710
std::is_same<sycl::detail::half_impl::StorageT,
711-
sycl::detail::host_half_impl::half_v2>::value,
711+
sycl::detail::host_half_impl::half>::value,
712712
T>;
713713
714714
template <typename Ty = DataT>

sycl/source/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ set(SYCL_SOURCES
171171
"exception.cpp"
172172
"exception_list.cpp"
173173
"function_pointer.cpp"
174-
"half_type.cpp"
175174
"handler.cpp"
176175
"interop_handle.cpp"
177176
"interop_handler.cpp"

sycl/source/half_type.cpp

Lines changed: 0 additions & 88 deletions
This file was deleted.

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3841,12 +3841,6 @@ _ZN4sycl3_V16detail13make_platformEmNS0_7backendE
38413841
_ZN4sycl3_V16detail13select_deviceERKSt8functionIFiRKNS0_6deviceEEE
38423842
_ZN4sycl3_V16detail13select_deviceERKSt8functionIFiRKNS0_6deviceEEERKNS0_7contextE
38433843
_ZN4sycl3_V16detail14getBorderColorENS0_19image_channel_orderE
3844-
_ZN4sycl3_V16detail14host_half_impl4halfC1ERKf
3845-
_ZN4sycl3_V16detail14host_half_impl4halfC2ERKf
3846-
_ZN4sycl3_V16detail14host_half_impl4halfdVERKS3_
3847-
_ZN4sycl3_V16detail14host_half_impl4halfmIERKS3_
3848-
_ZN4sycl3_V16detail14host_half_impl4halfmLERKS3_
3849-
_ZN4sycl3_V16detail14host_half_impl4halfpLERKS3_
38503844
_ZN4sycl3_V16detail15getOrWaitEventsESt6vectorINS0_5eventESaIS3_EESt10shared_ptrINS1_12context_implEE
38513845
_ZN4sycl3_V16detail16AccessorImplHost6resizeEm
38523846
_ZN4sycl3_V16detail16AccessorImplHostD1Ev
@@ -4112,7 +4106,6 @@ _ZNK4sycl3_V16detail11stream_impl8get_sizeEv
41124106
_ZNK4sycl3_V16detail12sampler_impl18get_filtering_modeEv
41134107
_ZNK4sycl3_V16detail12sampler_impl19get_addressing_modeEv
41144108
_ZNK4sycl3_V16detail12sampler_impl33get_coordinate_normalization_modeEv
4115-
_ZNK4sycl3_V16detail14host_half_impl4halfcvfEv
41164109
_ZNK4sycl3_V16detail18device_image_plain10has_kernelERKNS0_9kernel_idE
41174110
_ZNK4sycl3_V16detail18device_image_plain10has_kernelERKNS0_9kernel_idERKNS0_6deviceE
41184111
_ZNK4sycl3_V16detail18device_image_plain9getNativeEv

0 commit comments

Comments
 (0)