From f157d0bc686c030d6e0b3163e85b2d185741b471 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Thu, 16 Nov 2023 02:56:22 -0800 Subject: [PATCH] Change abs_diff return type Following https://github.com/KhronosGroup/SYCL-Docs/pull/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 --- .../modules/sycl_functions.py | 2 +- util/math_reference.h | 20 +++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/tests/math_builtin_api/modules/sycl_functions.py b/tests/math_builtin_api/modules/sycl_functions.py index 897751a19..fcc40e563 100644 --- a/tests/math_builtin_api/modules/sycl_functions.py +++ b/tests/math_builtin_api/modules/sycl_functions.py @@ -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"]) diff --git a/util/math_reference.h b/util/math_reference.h index d48f6e2b5..593d93df6 100644 --- a/util/math_reference.h +++ b/util/math_reference.h @@ -305,23 +305,21 @@ sycl_cts::resultRef> abs(sycl::marray a) { /* absolute difference */ template -auto abs_diff(T a, T b) { - using R = typename std::make_unsigned::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 ::type> -sycl::vec abs_diff(sycl::vec a, sycl::vec b) { - return sycl_cts::math::run_func_on_vector( +template +sycl::vec abs_diff(sycl::vec a, sycl::vec b) { + return sycl_cts::math::run_func_on_vector( [](T x, T y) { return abs_diff(x, y); }, a, b); } // FIXME: hipSYCL does not support marray #ifndef SYCL_CTS_COMPILING_WITH_HIPSYCL -template ::type> -sycl::marray abs_diff(sycl::marray a, sycl::marray b) { - return sycl_cts::math::run_func_on_marray( +template +sycl::marray abs_diff(sycl::marray a, sycl::marray b) { + return sycl_cts::math::run_func_on_marray( [](T x, T y) { return abs_diff(x, y); }, a, b); } #endif