Skip to content

Commit

Permalink
Modified how the function hijacking for typeless_nan behaves.
Browse files Browse the repository at this point in the history
The same is also not used for `pi`.
  • Loading branch information
philip-paul-mueller committed Nov 22, 2023
1 parent a07eede commit 8a9cb2c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
8 changes: 4 additions & 4 deletions dace/runtime/include/dace/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
#ifndef __DACE_MATH_H
#define __DACE_MATH_H

#include "pi.h"
#include "nan.h"
#include "types.h"

#include <complex>
#include <numeric>
#include <cmath>
#include <cfloat>
#include <type_traits>

#include "pi.h"
#include "nan.h"
#include "types.h"

#ifdef __CUDACC__
#include <thrust/complex.h>
#endif
Expand Down
20 changes: 9 additions & 11 deletions dace/runtime/include/dace/nan.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ namespace dace
}
typeless_nan operator+() const
{
*this;
return typeless_nan{};
}
typeless_nan operator-() const
{
*this;
return typeless_nan{};
}
};

Expand Down Expand Up @@ -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<typename T1> DACE_CONSTEXPR dace::math::typeless_nan F (T1&&, dace::math::typeless_nan) { return ::dace::math::typeless_nan{}; }; \
template<typename T2> 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

0 comments on commit 8a9cb2c

Please sign in to comment.