From 3341296071c94d3b101e275b5c2a172ce2b9ac5d Mon Sep 17 00:00:00 2001 From: Nathan Ellingwood Date: Tue, 13 Apr 2021 17:46:19 -0600 Subject: [PATCH] Kokkos_ArithTraits.hpp: Fix isInf and isNan with complex types Detected during release 3.4.0 testing with Trilinos --- src/Kokkos_ArithTraits.hpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Kokkos_ArithTraits.hpp b/src/Kokkos_ArithTraits.hpp index c8a20f4e96..f96ffc49c3 100644 --- a/src/Kokkos_ArithTraits.hpp +++ b/src/Kokkos_ArithTraits.hpp @@ -856,7 +856,7 @@ class ArithTraits { static KOKKOS_FORCEINLINE_FUNCTION float infinity() { return HUGE_VALF; } static KOKKOS_FORCEINLINE_FUNCTION bool isInf (const float x) { - #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST +#ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST using std::isinf; #elif KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_SYCL using sycl::isinf @@ -864,7 +864,7 @@ class ArithTraits { return isinf (x); } static KOKKOS_FORCEINLINE_FUNCTION bool isNan (const float x) { - #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST +#ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST using std::isnan; #elif KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_SYCL using sycl::isnan @@ -1034,6 +1034,7 @@ class ArithTraits > { return std::complex (ArithTraits::infinity (), ArithTraits::infinity ()); } +#ifdef KOKKOS_ENABLE_SYCL template static bool isInf(const std::complex& x) { #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST @@ -1043,13 +1044,20 @@ class ArithTraits > { #endif return isinf (real (x)) || isinf (imag (x)); } -#ifdef KOKKOS_ENABLE_SYCL template <> static bool isInf(const std::complex& x) { Kokkos::abort("isInf not available for std::complex!\n"); return true; } +#else + static bool isInf(const std::complex& x) { +#ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST + using std::isinf; +#endif + return isinf (real (x)) || isinf (imag (x)); + } #endif +#ifdef KOKKOS_ENABLE_SYCL template static bool isNan(const std::complex& x) { #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST @@ -1059,12 +1067,18 @@ class ArithTraits > { #endif return isnan (real (x)) || isnan (imag (x)); } -#ifdef KOKKOS_ENABLE_SYCL template <> static bool isNan(const std::complex& x) { Kokkos::abort("isNan not available for std::complex!\n"); return true; } +#else + static bool isNan(const std::complex& x) { +#ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST + using std::isnan; +#endif + return isnan (real (x)) || isnan (imag (x)); + } #endif static mag_type abs (const std::complex& x) { return std::abs (x);