Skip to content

Commit 6ff9cf7

Browse files
authored
[SYCL] Deprecate half from global namespace (#4363)
1 parent d171417 commit 6ff9cf7

File tree

9 files changed

+22
-21
lines changed

9 files changed

+22
-21
lines changed

sycl/include/CL/sycl/aliases.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@ class half;
2424
} // namespace sycl
2525
} // __SYCL_INLINE_NAMESPACE(cl)
2626

27-
// FIXME: line below exports 'half' into global namespace, which seems incorrect
28-
// However, SYCL 1.2.1 spec considers 'half' to be a fundamental C++ data type
29-
// which doesn't exist within the 'cl::sycl' namespace.
30-
// Related spec issue: KhronosGroup/SYCL-Docs#40
31-
using half = cl::sycl::detail::half_impl::half;
27+
using half __SYCL2020_DEPRECATED("use 'sycl::half' instead") =
28+
cl::sycl::detail::half_impl::half;
3229

3330
#define __SYCL_MAKE_VECTOR_ALIAS(ALIAS, TYPE, N) \
3431
using ALIAS##N = cl::sycl::vec<TYPE, N>;

sycl/source/detail/builtins_geometric.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ __SYCL_EXPORT s::cl_double Dot(s::vec<double, 1>, s::vec<double, 1>);
2828
__SYCL_EXPORT s::cl_double Dot(s::cl_double2, s::cl_double2);
2929
__SYCL_EXPORT s::cl_double Dot(s::cl_double3, s::cl_double3);
3030
__SYCL_EXPORT s::cl_double Dot(s::cl_double4, s::cl_double4);
31-
__SYCL_EXPORT s::cl_half Dot(s::vec<half, 1>, s::vec<half, 1>);
31+
__SYCL_EXPORT s::cl_half Dot(s::vec<s::half, 1>, s::vec<s::half, 1>);
3232
__SYCL_EXPORT s::cl_half Dot(s::cl_half2, s::cl_half2);
3333
__SYCL_EXPORT s::cl_half Dot(s::cl_half3, s::cl_half3);
3434
__SYCL_EXPORT s::cl_half Dot(s::cl_half4, s::cl_half4);
@@ -158,7 +158,7 @@ __SYCL_EXPORT s::cl_double length(s::vec<double, 1> p) { return __length(p); }
158158
__SYCL_EXPORT s::cl_double length(s::cl_double2 p) { return __length(p); }
159159
__SYCL_EXPORT s::cl_double length(s::cl_double3 p) { return __length(p); }
160160
__SYCL_EXPORT s::cl_double length(s::cl_double4 p) { return __length(p); }
161-
__SYCL_EXPORT s::cl_half length(s::vec<half, 1> p) { return __length(p); }
161+
__SYCL_EXPORT s::cl_half length(s::vec<s::half, 1> p) { return __length(p); }
162162
__SYCL_EXPORT s::cl_half length(s::cl_half2 p) { return __length(p); }
163163
__SYCL_EXPORT s::cl_half length(s::cl_half3 p) { return __length(p); }
164164
__SYCL_EXPORT s::cl_half length(s::cl_half4 p) { return __length(p); }
@@ -197,7 +197,8 @@ __SYCL_EXPORT s::cl_double distance(s::cl_double4 p0, s::cl_double4 p1) {
197197
__SYCL_EXPORT s::cl_half distance(s::cl_half p0, s::cl_half p1) {
198198
return length(p0 - p1);
199199
}
200-
__SYCL_EXPORT s::cl_float distance(s::vec<half, 1> p0, s::vec<half, 1> p1) {
200+
__SYCL_EXPORT s::cl_float distance(s::vec<s::half, 1> p0,
201+
s::vec<s::half, 1> p1) {
201202
return length(p0 - p1);
202203
}
203204
__SYCL_EXPORT s::cl_half distance(s::cl_half2 p0, s::cl_half2 p1) {

sycl/test/basic_tests/aliases.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ namespace s = cl::sycl;
2626
ASSERT(s::int, int, N) \
2727
ASSERT(s::long, long, N) \
2828
ASSERT(s::float, float, N) \
29-
ASSERT(s::double, double, N) \
30-
ASSERT(s::half, half, N);
29+
ASSERT(s::double, double, N);
3130

3231
// cl_char, cl_uchar, cl_short, cl_ushort, cl_int, cl_uint, cl_long, cl_ulong,
3332
// cl_float, cl_double and cl_half

sycl/test/basic_tests/types.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ template <typename T> inline void checkVectorsWithN() {
3333
}
3434

3535
inline void checkVectors() {
36-
checkVectorsWithN<half>();
36+
checkVectorsWithN<s::half>();
3737
checkVectorsWithN<float>();
3838
checkVectorsWithN<double>();
3939
checkVectorsWithN<char>();

sycl/test/basic_tests/vectors/vectors.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ template <typename From> void check_convert_from() {
4646
check_signed_unsigned_convert_to<From, int>();
4747
check_signed_unsigned_convert_to<From, long>();
4848
check_signed_unsigned_convert_to<From, long long>();
49-
check_signed_unsigned_convert_to<From, half>();
49+
check_signed_unsigned_convert_to<From, sycl::half>();
5050
check_signed_unsigned_convert_to<From, float>();
5151
check_signed_unsigned_convert_to<From, double>();
5252
}
@@ -122,7 +122,7 @@ int main() {
122122
check_convert_from<int>();
123123
check_convert_from<long>();
124124
check_convert_from<long long>();
125-
check_convert_from<half>();
125+
check_convert_from<sycl::half>();
126126
check_convert_from<float>();
127127
check_convert_from<double>();
128128

sycl/test/regression/isordered.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ int main() {
2121
double inputData_1D(0.3);
2222
resultPtr[1] = cl::sycl::isordered(inputData_0D, inputData_1D);
2323

24-
half inputData_0H(0.3);
25-
half inputData_1H(0.9);
24+
sycl::half inputData_0H(0.3);
25+
sycl::half inputData_1H(0.9);
2626
resultPtr[2] = cl::sycl::isordered(inputData_0H, inputData_1H);
2727
});
2828
});

sycl/test/type_traits/integer_n_bit.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ using TypeList =
3131
uint64_t, s::vec<int8_t, 2>, s::vec<int16_t, 2>,
3232
s::vec<int32_t, 2>, s::vec<int64_t, 2>, s::vec<uint8_t, 2>,
3333
s::vec<uint16_t, 2>, s::vec<uint32_t, 2>, s::vec<uint64_t, 2>,
34-
bool, float, double, half, s::vec<float, 2>, s::vec<double, 2>,
35-
s::vec<half, 2>>;
34+
bool, float, double, s::half, s::vec<float, 2>,
35+
s::vec<double, 2>, s::vec<s::half, 2>>;
3636

3737
int main() {
3838
check<d::is_igeninteger8bit, TypeList,

sycl/test/type_traits/type_traits.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,29 +133,29 @@ int main() {
133133
test_is_integral<s::int2>();
134134
test_is_integral<float, false>();
135135
test_is_integral<s::float2, false>();
136-
test_is_integral<half, false>();
136+
test_is_integral<s::half, false>();
137137
test_is_integral<s::half2, false>();
138138

139139
test_is_floating_point<int, false>();
140140
test_is_floating_point<s::int2, false>();
141141
test_is_floating_point<float>();
142142
test_is_floating_point<s::float2>();
143-
test_is_floating_point<half>();
143+
test_is_floating_point<s::half>();
144144
test_is_floating_point<s::half2>();
145145

146146
test_is_arithmetic<int>();
147147
test_is_arithmetic<s::int2>();
148148
test_is_arithmetic<float>();
149149
test_is_arithmetic<s::float2>();
150-
test_is_arithmetic<half>();
150+
test_is_arithmetic<s::half>();
151151
test_is_arithmetic<s::half2>();
152152

153153
test_make_type_t<int, d::gtl::scalar_unsigned_int_list, unsigned int>();
154154
test_make_type_t<s::cl_int, d::gtl::scalar_float_list, s::cl_float>();
155155
test_make_type_t<s::cl_int3, d::gtl::scalar_unsigned_int_list, s::cl_uint3>();
156156
test_make_type_t<s::cl_int3, d::gtl::scalar_float_list, s::cl_float3>();
157157

158-
test_make_larger_t<half, float>();
158+
test_make_larger_t<s::half, float>();
159159
test_make_larger_t<s::half3, s::float3>();
160160
test_make_larger_t<float, double>();
161161
test_make_larger_t<s::float3, s::double3>();

sycl/test/warnings/sycl_2020_deprecations.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,9 @@ int main() {
152152
auto SL = sycl::INTEL::source_language::opencl_c;
153153
(void)SL;
154154

155+
// expected-warning@+1{{'half' is deprecated: use 'sycl::half' instead}}
156+
half H;
157+
(void)H;
158+
155159
return 0;
156160
}

0 commit comments

Comments
 (0)