@@ -90,6 +90,34 @@ namespace math {
9090 return detail::unqualified_##NAME (x); \
9191 }
9292
93+ #ifdef METAPHYSICL_KOKKOS_COMPILATION
94+ #define METAPHYSICL_MATH_UNARY_ALIAS (ALIAS, NAME ) \
95+ namespace detail { \
96+ template <class X > METAPHYSICL_INLINE auto unqualified_##ALIAS (const X &x) { \
97+ if constexpr (std::is_arithmetic_v<X>) \
98+ return Kokkos::NAME (x); \
99+ else \
100+ return NAME (x); \
101+ } \
102+ } \
103+ template <class X > METAPHYSICL_INLINE auto ALIAS (const X &x) { \
104+ return detail::unqualified_##ALIAS (x); \
105+ }
106+ #else
107+ #define METAPHYSICL_MATH_UNARY_ALIAS (ALIAS, NAME ) \
108+ namespace detail { \
109+ template <class X > METAPHYSICL_INLINE auto unqualified_##ALIAS (const X &x) { \
110+ if constexpr (std::is_arithmetic_v<X>) \
111+ return std::NAME (x); \
112+ else \
113+ return NAME (x); \
114+ } \
115+ } \
116+ template <class X > METAPHYSICL_INLINE auto ALIAS (const X &x) { \
117+ return detail::unqualified_##ALIAS (x); \
118+ }
119+ #endif
120+
93121// Macro to call when there is a backing math function in c
94122#define METAPHYSICL_MATH_BINARY (NAME ) \
95123 METAPHYSICL_MATH_DETAIL_UNQUALIFIED_BINARY (NAME ) \
@@ -129,7 +157,11 @@ METAPHYSICL_MATH_UNARY(erf)
129157METAPHYSICL_MATH_UNARY (erfc)
130158METAPHYSICL_MATH_UNARY (trunc)
131159METAPHYSICL_MATH_UNARY (round)
160+ #if defined (METAPHYSICL_KOKKOS_COMPILATION) && defined(KOKKOS_ENABLE_SYCL)
161+ METAPHYSICL_MATH_UNARY_ALIAS (nearbyint, rint)
162+ #else
132163METAPHYSICL_MATH_UNARY (nearbyint)
164+ #endif
133165METAPHYSICL_MATH_UNARY_STD (rint)
134166METAPHYSICL_MATH_UNARY (real)
135167METAPHYSICL_MATH_UNARY (imag)
0 commit comments