Skip to content

Commit

Permalink
Merge pull request #936 from ndellingwood/fix-cplx-arithtraits
Browse files Browse the repository at this point in the history
Kokkos_ArithTraits.hpp: Fix isInf and isNan with complex types
  • Loading branch information
ndellingwood authored Apr 14, 2021
2 parents 55f492b + 3341296 commit 5016b18
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/Kokkos_ArithTraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -856,15 +856,15 @@ class ArithTraits<float> {
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
#endif
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
Expand Down Expand Up @@ -1034,6 +1034,7 @@ class ArithTraits<std::complex<RealFloatType> > {
return std::complex<RealFloatType> (ArithTraits<mag_type>::infinity (), ArithTraits<mag_type>::infinity ());
}

#ifdef KOKKOS_ENABLE_SYCL
template <typename Dummy = RealFloatType>
static bool isInf(const std::complex<Dummy>& x) {
#ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
Expand All @@ -1043,13 +1044,20 @@ class ArithTraits<std::complex<RealFloatType> > {
#endif
return isinf (real (x)) || isinf (imag (x));
}
#ifdef KOKKOS_ENABLE_SYCL
template <>
static bool isInf<long double>(const std::complex<long double>& x) {
Kokkos::abort("isInf not available for std::complex<long double>!\n");
return true;
}
#else
static bool isInf(const std::complex<RealFloatType>& 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 <typename Dummy = RealFloatType>
static bool isNan(const std::complex<Dummy>& x) {
#ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
Expand All @@ -1059,12 +1067,18 @@ class ArithTraits<std::complex<RealFloatType> > {
#endif
return isnan (real (x)) || isnan (imag (x));
}
#ifdef KOKKOS_ENABLE_SYCL
template <>
static bool isNan<long double>(const std::complex<long double>& x) {
Kokkos::abort("isNan not available for std::complex<long double>!\n");
return true;
}
#else
static bool isNan(const std::complex<RealFloatType>& 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<RealFloatType>& x) {
return std::abs (x);
Expand Down

0 comments on commit 5016b18

Please sign in to comment.