From 8a9cb2c848e9ec5a0bbe26d7212eab29de8a4153 Mon Sep 17 00:00:00 2001 From: Philip Mueller Date: Wed, 22 Nov 2023 08:30:55 +0100 Subject: [PATCH] Modified how the function hijacking for `typeless_nan` behaves. The same is also not used for `pi`. --- dace/runtime/include/dace/math.h | 8 ++++---- dace/runtime/include/dace/nan.h | 20 +++++++++----------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/dace/runtime/include/dace/math.h b/dace/runtime/include/dace/math.h index 09103107cd..e743f1410f 100644 --- a/dace/runtime/include/dace/math.h +++ b/dace/runtime/include/dace/math.h @@ -2,16 +2,16 @@ #ifndef __DACE_MATH_H #define __DACE_MATH_H -#include "pi.h" -#include "nan.h" -#include "types.h" - #include #include #include #include #include +#include "pi.h" +#include "nan.h" +#include "types.h" + #ifdef __CUDACC__ #include #endif diff --git a/dace/runtime/include/dace/nan.h b/dace/runtime/include/dace/nan.h index 33efe9ff91..d3c85c8248 100644 --- a/dace/runtime/include/dace/nan.h +++ b/dace/runtime/include/dace/nan.h @@ -27,11 +27,11 @@ namespace dace } typeless_nan operator+() const { - *this; + return typeless_nan{}; } typeless_nan operator-() const { - *this; + return typeless_nan{}; } }; @@ -94,21 +94,19 @@ namespace dace inline typeless_nan operator%(const typeless_nan&, const typeless_nan&) { return typeless_nan{}; } + } +} + //These functions allows to perfrom operations with `typeless_nan` instances. -# define FADAPT(F) typeless_nan DACE_CONSTEXPR F (const typeless_nan&) { return typeless_nan{}; } -# define FADAPT2(F) typeless_nan DACE_CONSTEXPR F (const typeless_nan&, const typeless_nan&) { return typeless_nan{}; } -# define FADAPT3(F) typeless_nan DACE_CONSTEXPR F (const typeless_nan&, const typeless_nan&, const typeless_nan&) { return typeless_nan{}; } -# define FADAPT4(F) typeless_nan DACE_CONSTEXPR F (const typeless_nan&, const typeless_nan&, const typeless_nan&, const typeless_nan&) { return typeless_nan{}; } +# define FADAPT(F) DACE_CONSTEXPR ::dace::math::typeless_nan F (::dace::math::typeless_nan) { return ::dace::math::typeless_nan{}; } +# define FADAPT2(F) template DACE_CONSTEXPR dace::math::typeless_nan F (T1&&, dace::math::typeless_nan) { return ::dace::math::typeless_nan{}; }; \ + template DACE_CONSTEXPR dace::math::typeless_nan F (dace::math::typeless_nan, T2&&) { return ::dace::math::typeless_nan{}; }; \ + DACE_CONSTEXPR ::dace::math::typeless_nan F (dace::math::typeless_nan, dace::math::typeless_nan) { return ::dace::math::typeless_nan{}; } FADAPT(tanh); FADAPT(cos); FADAPT(sin); FADAPT(sqrt); FADAPT(tan); FADAPT(acos); FADAPT(asin); FADAPT(atan); FADAPT(log); FADAPT(exp); FADAPT(floor); FADAPT(ceil); FADAPT(round); FADAPT(abs); FADAPT2(max); FADAPT2(min); -# undef FADAPT4 -# undef FADAPT3 # undef FADAPT2 # undef FADAPT - } -} - #endif // __DACE_NAN_H