20namespace alpaka::math::internal
22#if ALPAKA_LANG_CUDA || ALPAKA_LANG_HIP
24 template<
typename T_Arg>
25 requires std::signed_integral<T_Arg> || std::floating_point<T_Arg>
26 struct Abs::Op<CudaHipMath, T_Arg>
28 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
41 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
47 template<std::
floating_po
int T_Arg>
48 struct Sin::Op<CudaHipMath, T_Arg>
50 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
57 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
63 template<std::
floating_po
int T_Arg>
64 struct Acosh::Op<CudaHipMath, T_Arg>
66 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
73 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
79 template<std::
floating_po
int T_Arg>
80 struct Asinh::Op<CudaHipMath, T_Arg>
82 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
89 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
95 template<std::
floating_po
int T_Arg>
96 struct Sinh::Op<CudaHipMath, T_Arg>
98 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
105 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
111 template<std::
floating_po
int T_Arg>
112 struct Atan::Op<CudaHipMath, T_Arg>
114 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
121 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
127 template<std::
floating_po
int T_Arg>
128 struct Atanh::Op<CudaHipMath, T_Arg>
130 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
133 return ::atanhf(arg);
137 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
143 template<std::
floating_po
int T_Arg>
144 struct Tanh::Op<CudaHipMath, T_Arg>
146 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
153 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
159 template<
typename T_Arg>
160 requires(std::is_arithmetic_v<T_Arg>)
161 struct Cbrt::Op<CudaHipMath, T_Arg>
163 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
170 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
176 template<std::
floating_po
int T_Arg>
177 struct Ceil::Op<CudaHipMath, T_Arg>
179 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
186 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
192 template<std::
floating_po
int T_Arg>
193 struct Round::Op<CudaHipMath, T_Arg>
195 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
198 return ::roundf(arg);
202 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
208 template<std::
floating_po
int T_Arg>
209 struct Lround::Op<CudaHipMath, T_Arg>
211 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
214 return ::lroundf(arg);
216 return ::lround(arg);
218 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
224 template<std::
floating_po
int T_Arg>
225 struct Llround::Op<CudaHipMath, T_Arg>
227 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
230 return ::llroundf(arg);
232 return ::llround(arg);
234 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
240 template<std::
floating_po
int T_Arg>
241 struct SinCos::Op<CudaHipMath, T_Arg>
243 constexpr auto operator()(CudaHipMath, T_Arg
const& arg, T_Arg& result_sin, T_Arg& result_cos)
const
246 ::sincosf(arg, &result_sin, &result_cos);
248 ::sincos(arg, &result_sin, &result_cos);
250 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
254 template<std::
floating_po
int T_Arg>
255 struct Exp::Op<CudaHipMath, T_Arg>
257 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
264 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
270 template<
typename T_Arg>
271 requires(std::is_arithmetic_v<T_Arg>)
272 struct Sqrt::Op<CudaHipMath, T_Arg>
274 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
281 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
287 template<
typename T_Arg>
288 requires(std::is_arithmetic_v<T_Arg>)
289 struct Rsqrt::Op<CudaHipMath, T_Arg>
291 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
294 return ::rsqrtf(arg);
298 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
304 template<std::
floating_po
int T_Arg>
305 struct Trunc::Op<CudaHipMath, T_Arg>
307 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
310 return ::truncf(arg);
314 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
320 template<std::
floating_po
int T_Arg>
321 struct Cos::Op<CudaHipMath, T_Arg>
323 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
330 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
336 template<std::
floating_po
int T_Arg>
337 struct Cosh::Op<CudaHipMath, T_Arg>
339 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
346 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
352 template<std::
floating_po
int T_Arg>
353 struct Erf::Op<CudaHipMath, T_Arg>
355 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
362 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
368 template<std::
floating_po
int T_Arg>
369 struct Floor::Op<CudaHipMath, T_Arg>
371 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
374 return ::floorf(arg);
378 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
384 template<std::
floating_po
int T_Arg>
385 struct Log::Op<CudaHipMath, T_Arg>
387 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
394 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
400 template<std::
floating_po
int T_Arg>
401 struct Log2::Op<CudaHipMath, T_Arg>
403 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
410 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
416 template<std::
floating_po
int T_Arg>
417 struct Log10::Op<CudaHipMath, T_Arg>
419 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
422 return ::log10f(arg);
426 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
432 template<std::
floating_po
int T_Arg>
433 struct Tan::Op<CudaHipMath, T_Arg>
435 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
442 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
448 template<std::
floating_po
int T_Y, std::
floating_po
int T_X>
449 struct Atan2::Op<CudaHipMath, T_Y, T_X>
451 constexpr auto operator()(CudaHipMath, T_Y
const& y, T_X
const& x)
const
454 return ::atan2f(y, x);
456 return ::atan2(y, x);
458 static_assert(!
sizeof(T_Y),
"Unsupported data type");
464 template<std::
floating_po
int T_Arg>
465 struct Arg::Op<CudaHipMath, T_Arg>
467 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
474 template<std::
floating_po
int T_Arg>
475 struct Asin::Op<CudaHipMath, T_Arg>
477 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
484 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
490 template<std::
floating_po
int T_Arg>
491 struct Acos::Op<CudaHipMath, T_Arg>
493 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
500 static_assert(!
sizeof(T_Arg),
"Unsupported data type");
507 template<std::
floating_po
int T_Arg>
508 struct Isnan::Op<CudaHipMath, T_Arg>
510 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
512 return ieeeIsnan(arg);
516 template<std::
floating_po
int T_Arg>
517 struct Isinf::Op<CudaHipMath, T_Arg>
519 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
521 return ieeeIsinf(arg);
525 template<std::
floating_po
int T_Arg>
526 struct Isfinite::Op<CudaHipMath, T_Arg>
528 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
530 return ieeeIsfinite(arg);
534 template<std::
floating_po
int T_Arg>
535 struct Conj::Op<CudaHipMath, T_Arg>
537 constexpr auto operator()(CudaHipMath, T_Arg
const& arg)
const
539 return Complex<T_Arg>{
arg, T_Arg{0.0}};
543 template<std::
floating_po
int T_Mag, std::
floating_po
int T_Sgn>
544 struct Copysign::Op<CudaHipMath, T_Mag, T_Sgn>
546 constexpr auto operator()(CudaHipMath, T_Mag
const& mag, T_Sgn
const& sgn)
const
549 return ::copysignf(mag, sgn);
551 return ::copysign(mag, sgn);
553 static_assert(!
sizeof(T_Mag),
"Unsupported data type");
559 template<std::
floating_po
int T_A, std::
floating_po
int T_B>
560 struct Min::Op<CudaHipMath, T_A, T_B>
562 constexpr auto operator()(CudaHipMath, T_A
const& a, T_B
const& b)
const
564 if constexpr(std::is_integral_v<T_A> && std::is_integral_v<T_B>)
567 return ::fminf(a, b);
574 static_assert(!
sizeof(T_A),
"Unsupported data type");
576 using Ret [[maybe_unused]] = std::conditional_t<
577 std::is_integral_v<T_A> && std::is_integral_v<T_B>,
578 decltype(
::min(a, b)),
584 template<
typename T_A,
typename T_B>
585 requires(std::is_arithmetic_v<T_A> && std::is_arithmetic_v<T_B>)
586 struct Max::Op<CudaHipMath, T_A, T_B>
588 constexpr auto operator()(CudaHipMath, T_A
const& a, T_B
const& b)
const
590 if constexpr(std::is_integral_v<T_A> && std::is_integral_v<T_B>)
593 return ::fmaxf(a, b);
600 static_assert(!
sizeof(T_A),
"Unsupported data type");
602 using Ret [[maybe_unused]] = std::conditional_t<
603 std::is_integral_v<T_A> && std::is_integral_v<T_B>,
604 decltype(
::max(a, b)),
610 template<std::
floating_po
int T_Base, std::
floating_po
int T_Exp>
611 struct Pow::Op<CudaHipMath, T_Base, T_Exp>
613 constexpr auto operator()(CudaHipMath, T_Base
const& base, T_Exp
const& exp)
const
616 return ::powf(base, exp);
618 return ::pow(
static_cast<double>(base),
static_cast<double>(exp));
620 static_assert(!
sizeof(T_Base),
"Unsupported data type");
622 using Ret [[maybe_unused]]
628 template<std::
floating_po
int T_X, std::
floating_po
int T_Y>
629 struct Fmod::Op<CudaHipMath, T_X, T_Y>
631 constexpr auto operator()(CudaHipMath, T_X
const& x, T_Y
const& y)
const
634 return ::fmodf(x, y);
638 static_assert(!
sizeof(T_X),
"Unsupported data type");
640 using Ret [[maybe_unused]]
646 template<std::
floating_po
int T_X, std::
floating_po
int T_Y>
647 struct Remainder::Op<CudaHipMath, T_X, T_Y>
649 constexpr auto operator()(CudaHipMath, T_X
const& x, T_Y
const& y)
const
652 return ::remainderf(x, y);
654 return ::remainder(x, y);
656 static_assert(!
sizeof(T_X),
"Unsupported data type");
658 using Ret [[maybe_unused]]
664 template<std::
floating_po
int T_X, std::
floating_po
int T_Y, std::
floating_po
int T_Z>
665 struct Fma::Op<CudaHipMath, T_X, T_Y, T_Z>
667 constexpr auto operator()(CudaHipMath, T_X
const& x, T_Y
const& y, T_Z
const& z)
const
670 return ::fmaf(x, y, z);
672 return ::fma(x, y, z);
674 static_assert(!
sizeof(T_X),
"Unsupported data type");
676 using Ret [[maybe_unused]] = std::conditional_t<
#define ALPAKA_UNREACHABLE(...)
Before CUDA 11.5 nvcc is unable to correctly identify return statements in 'if constexpr' branches....
constexpr auto atan2(auto const &y, auto const &x)
constexpr auto arg(auto const &arg)
constexpr auto sincos(auto const &arg, auto &result_sin, auto &result_cos)
constexpr auto min(auto const &a, auto const &b)
constexpr auto max(auto const &a, auto const &b)
constexpr auto is_decayed_v
Provides a decaying wrapper around std::is_same. Example: is_decayed_v<volatile float,...