Skip to content

Commit 32bdcb5

Browse files
[SYCL] fast_{length|distance|normalize} should only accept float element type (#12183)
1 parent 8efe97f commit 32bdcb5

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

sycl/include/sycl/builtins_legacy_marray_vec.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,8 @@ float fast_distance(T p0, T p1) {
964964
// double fast_distance (gengeodouble p0, gengeodouble p1)
965965
template <typename T,
966966
typename = std::enable_if_t<detail::is_gengeodouble_v<T>, T>>
967+
__SYCL_DEPRECATED("fast_distance for double precision types is non-standard "
968+
"and has been deprecated")
967969
double fast_distance(T p0, T p1) {
968970
return __sycl_std::__invoke_fast_distance<double>(p0, p1);
969971
}
@@ -978,6 +980,8 @@ float fast_length(T p) {
978980
// double fast_length (gengeodouble p)
979981
template <typename T,
980982
typename = std::enable_if_t<detail::is_gengeodouble_v<T>, T>>
983+
__SYCL_DEPRECATED("fast_length for double precision types is non-standard "
984+
"and has been deprecated")
981985
double fast_length(T p) {
982986
return __sycl_std::__invoke_fast_length<double>(p);
983987
}
@@ -990,6 +994,8 @@ std::enable_if_t<detail::is_gengeofloat_v<T>, T> fast_normalize(T p) {
990994

991995
// gengeodouble fast_normalize (gengeodouble p)
992996
template <typename T>
997+
__SYCL_DEPRECATED("fast_normalize for double precision types is non-standard "
998+
"and has been deprecated")
993999
std::enable_if_t<detail::is_gengeodouble_v<T>, T> fast_normalize(T p) {
9941000
return __sycl_std::__invoke_fast_normalize<T>(p);
9951001
}

sycl/source/builtins_generator.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -999,15 +999,9 @@ def custom_nan_invoke(return_type, arg_types, arg_names):
999999
"normalize": [Def("gengeofloat", ["gengeofloat"], template_scalar_args=True),
10001000
Def("gengeodouble", ["gengeodouble"], template_scalar_args=True),
10011001
Def("gengeohalf", ["gengeohalf"], template_scalar_args=True)],
1002-
"fast_distance": [Def("float", ["gengeofloat", "gengeofloat"], template_scalar_args=True),
1003-
Def("double", ["gengeodouble", "gengeodouble"], template_scalar_args=True),
1004-
Def("half", ["gengeohalf", "gengeohalf"], template_scalar_args=True)],
1005-
"fast_length": [Def("float", ["gengeofloat"], template_scalar_args=True),
1006-
Def("double", ["gengeodouble"], template_scalar_args=True),
1007-
Def("half", ["gengeohalf"], template_scalar_args=True)],
1008-
"fast_normalize": [Def("gengeofloat", ["gengeofloat"], template_scalar_args=True),
1009-
Def("gengeodouble", ["gengeodouble"], template_scalar_args=True),
1010-
Def("gengeohalf", ["gengeohalf"], template_scalar_args=True)],
1002+
"fast_distance": [Def("float", ["gengeofloat", "gengeofloat"], template_scalar_args=True)],
1003+
"fast_length": [Def("float", ["gengeofloat"], template_scalar_args=True)],
1004+
"fast_normalize": [Def("gengeofloat", ["gengeofloat"], template_scalar_args=True)],
10111005
# Relational functions
10121006
"isequal": [RelDef("samesizesignedint0", ["vgenfloat", "vgenfloat"], invoke_name="FOrdEqual"),
10131007
RelDef("bool", ["sgenfloat", "sgenfloat"], invoke_name="FOrdEqual"),

sycl/test/basic_tests/builtins_templates.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
CHECK_INNER(NUM_ARGS, FUNC_NAME, sycl::vec<float, 4>) \
2525
CHECK_INNER(NUM_ARGS, FUNC_NAME, sycl::marray<float, 4>)
2626

27+
#define FLOAT_CHECK(NUM_ARGS, FUNC_NAME) \
28+
CHECK_INNER(NUM_ARGS, FUNC_NAME, float) \
29+
NONSCALAR_FLOAT_CHECK(NUM_ARGS, FUNC_NAME)
30+
2731
#define NONSCALAR_GENFLOAT_CHECK(NUM_ARGS, FUNC_NAME) \
2832
NONSCALAR_FLOAT_CHECK(NUM_ARGS, FUNC_NAME) \
2933
CHECK_INNER(NUM_ARGS, FUNC_NAME, sycl::vec<sycl::half, 4>) \
@@ -224,9 +228,9 @@ void check() {
224228
GENFLOAT_CHECK(TWO_ARGS, distance)
225229
GENFLOAT_CHECK(ONE_ARG, length)
226230
GENFLOAT_CHECK(ONE_ARG, normalize)
227-
GENFLOAT_CHECK(TWO_ARGS, fast_distance)
228-
GENFLOAT_CHECK(ONE_ARG, fast_length)
229-
GENFLOAT_CHECK(ONE_ARG, fast_normalize)
231+
FLOAT_CHECK(TWO_ARGS, fast_distance)
232+
FLOAT_CHECK(ONE_ARG, fast_length)
233+
FLOAT_CHECK(ONE_ARG, fast_normalize)
230234

231235
NONSCALAR_GENFLOAT_CHECK(TWO_ARGS, isequal)
232236
NONSCALAR_GENFLOAT_CHECK(TWO_ARGS, isnotequal)

sycl/test/warnings/sycl_2020_deprecations.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,5 +448,11 @@ int main() {
448448
size_t StreamMaxStatementSize = Stream.get_max_statement_size();
449449
});
450450

451+
// expected-warning@+1 {{'fast_distance<double, double>' is deprecated: fast_distance for double precision types is non-standard and has been deprecated}}
452+
std::ignore = sycl::fast_distance(double{1.0}, double{2.0});
453+
// expected-warning@+2 {{'fast_distance<sycl::vec<double, 2>, sycl::vec<double, 2>>' is deprecated: fast_distance for double precision types is non-standard and has been deprecated}}
454+
std::ignore =
455+
sycl::fast_distance(sycl::vec<double, 2>{0.0}, sycl::vec<double, 2>{1.0});
456+
451457
return 0;
452458
}

0 commit comments

Comments
 (0)