From 5e452ba204e322a21ab4321ac32de4e0a04bad0d Mon Sep 17 00:00:00 2001 From: HPS-1 <65581261+HPS-1@users.noreply.github.com> Date: Fri, 26 Jan 2024 19:27:55 -0500 Subject: [PATCH] [SYCL] Modify detail::is_complex to handle cv qualifiers correctly (#12491) Modify detail::is_complex to handle cv qualifiers correctly, by replacing T with std::remove_cv_t\ to strip off the cv qualifiers. Its test cases have also been updated to check const and/or volatile qualifers now. detail::is_plus and detail::is_multiplies are also updated similarly to strip off const qualifers (as suggested by @steffenlarsen, technically adding/removing volatile changes these two types of operations, so volatile qualifers are not stripped off for them). --------- Signed-off-by: Hu, Peisen --- sycl/include/sycl/group_algorithm.hpp | 19 ++++++++++++------- sycl/include/sycl/stl_wrappers/complex | 6 +++--- .../Complex/sycl_complex_include_order.cpp | 5 +++++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/sycl/include/sycl/group_algorithm.hpp b/sycl/include/sycl/group_algorithm.hpp index d22e3196e980..6f7f14feb6e3 100644 --- a/sycl/include/sycl/group_algorithm.hpp +++ b/sycl/include/sycl/group_algorithm.hpp @@ -116,14 +116,19 @@ template struct is_native_op { // ---- is_plus template using is_plus = std::integral_constant< - bool, std::is_same_v> || - std::is_same_v>>; + bool, + std::is_same_v>> || + std::is_same_v>> || + std::is_same_v>>; // ---- is_multiplies template using is_multiplies = std::integral_constant< - bool, std::is_same_v> || - std::is_same_v>>; + bool, + std::is_same_v>> || + std::is_same_v>> || + std::is_same_v>>; // ---- is_complex // Use SFINAE so that the "true" branch could be implemented in @@ -134,9 +139,9 @@ struct is_complex : public std::false_type {}; // ---- is_arithmetic_or_complex template -using is_arithmetic_or_complex = std::integral_constant< - bool, sycl::detail::is_complex>::value || - sycl::detail::is_arithmetic::value>; +using is_arithmetic_or_complex = + std::integral_constant::value || + sycl::detail::is_arithmetic::value>; template struct is_vector_arithmetic_or_complex diff --git a/sycl/include/sycl/stl_wrappers/complex b/sycl/include/sycl/stl_wrappers/complex index 6ed159eca7c5..281dac2aabde 100644 --- a/sycl/include/sycl/stl_wrappers/complex +++ b/sycl/include/sycl/stl_wrappers/complex @@ -93,9 +93,9 @@ struct isComplex> || // NOTE: std::complex not yet supported by group algorithms. template -struct is_complex> || - std::is_same_v> || - std::is_same_v>>> +struct is_complex, std::complex> || + std::is_same_v, std::complex> || + std::is_same_v, std::complex>>> : public std::true_type {}; #ifdef __SYCL_DEVICE_ONLY__ diff --git a/sycl/test-e2e/Complex/sycl_complex_include_order.cpp b/sycl/test-e2e/Complex/sycl_complex_include_order.cpp index 69e6b0685c39..245d222c6520 100644 --- a/sycl/test-e2e/Complex/sycl_complex_include_order.cpp +++ b/sycl/test-e2e/Complex/sycl_complex_include_order.cpp @@ -31,6 +31,11 @@ int main() { queue q; auto test = []() { static_assert(sycl::detail::is_complex>::value); + static_assert(sycl::detail::is_complex>::value); + static_assert( + sycl::detail::is_complex>::value); + static_assert( + sycl::detail::is_complex>::value); static_assert(sycl::detail::isComplex>::value); #ifdef __SYCL_DEVICE_ONLY__ static_assert(