Skip to content

Commit

Permalink
Change abs_diff return type
Browse files Browse the repository at this point in the history
Following KhronosGroup/SYCL-Docs#458 the return
type of abs_diff was changed to be the same as the input types. This
commit makes the corresponding changes to the CTS tests for it.

Signed-off-by: Larsen, Steffen <[email protected]>
  • Loading branch information
steffenlarsen committed Nov 23, 2023
1 parent 4c0163e commit f157d0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tests/math_builtin_api/modules/sycl_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def create_integer_signatures():
f_abs = funsig("sycl", "geninteger", "abs", ["geninteger"])
sig_list.append(f_abs)

f_abs_diff = funsig("sycl", "ugeninteger", "abs_diff", ["geninteger", "geninteger"], "0", "", [], [["geninteger", "ugeninteger", "base_type_but_same_sizeof"]])
f_abs_diff = funsig("sycl", "geninteger", "abs_diff", ["geninteger", "geninteger"])
sig_list.append(f_abs_diff)

f_add_sat = funsig("sycl", "geninteger", "add_sat", ["geninteger", "geninteger"])
Expand Down
20 changes: 9 additions & 11 deletions util/math_reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,23 +305,21 @@ sycl_cts::resultRef<sycl::marray<T, N>> abs(sycl::marray<T, N> a) {

/* absolute difference */
template <typename T>
auto abs_diff(T a, T b) {
using R = typename std::make_unsigned<T>::type;
R h = (a > b) ? a : b;
R l = (a <= b) ? a : b;
T abs_diff(T a, T b) {
T h = (a > b) ? a : b;
T l = (a <= b) ? a : b;
return h - l;
}
template <typename T, int N, typename R = typename std::make_unsigned<T>::type>
sycl::vec<R, N> abs_diff(sycl::vec<T, N> a, sycl::vec<T, N> b) {
return sycl_cts::math::run_func_on_vector<R, T, N>(
template <typename T, int N>
sycl::vec<T, N> abs_diff(sycl::vec<T, N> a, sycl::vec<T, N> b) {
return sycl_cts::math::run_func_on_vector<T, T, N>(
[](T x, T y) { return abs_diff(x, y); }, a, b);
}
// FIXME: hipSYCL does not support marray
#ifndef SYCL_CTS_COMPILING_WITH_HIPSYCL
template <typename T, size_t N,
typename R = typename std::make_unsigned<T>::type>
sycl::marray<R, N> abs_diff(sycl::marray<T, N> a, sycl::marray<T, N> b) {
return sycl_cts::math::run_func_on_marray<R, T, N>(
template <typename T, size_t N>
sycl::marray<T, N> abs_diff(sycl::marray<T, N> a, sycl::marray<T, N> b) {
return sycl_cts::math::run_func_on_marray<T, T, N>(
[](T x, T y) { return abs_diff(x, y); }, a, b);
}
#endif
Expand Down

0 comments on commit f157d0b

Please sign in to comment.