19#if defined(ALPAKA_ACC_GPU_CUDA_ENABLED) || defined(ALPAKA_ACC_GPU_HIP_ENABLED)
265# if !defined(ALPAKA_HOST_ONLY)
267# if defined(ALPAKA_ACC_GPU_CUDA_ENABLED) && !ALPAKA_LANG_CUDA
268# error If ALPAKA_ACC_GPU_CUDA_ENABLED is set, the compiler has to support CUDA!
271# if defined(ALPAKA_ACC_GPU_HIP_ENABLED) && !ALPAKA_LANG_HIP
272# error If ALPAKA_ACC_GPU_HIP_ENABLED is set, the compiler has to support HIP!
275# if defined(ALPAKA_ACC_GPU_CUDA_ENABLED) && defined(__CUDA_ARCH__)
276# include <cuda_runtime.h>
279# if defined(ALPAKA_ACC_GPU_HIP_ENABLED) && defined(__HIP_DEVICE_COMPILE__)
280# include <hip/math_functions.h>
286 template<
typename TArg>
302 static_assert(!
sizeof(TArg),
"Unsupported data type");
309 template<
typename TArg>
319 static_assert(!
sizeof(TArg),
"Unsupported data type");
326 template<
typename TArg>
332 return ::acoshf(
arg);
336 static_assert(!
sizeof(TArg),
"Unsupported data type");
343 template<
typename TArgument>
347 template<
typename TCtx>
348 __host__ __device__
auto operator()(TCtx
const& ctx, TArgument
const& argument)
351 return atan2(ctx, TArgument{0.0}, argument);
356 template<
typename TArg>
366 static_assert(!
sizeof(TArg),
"Unsupported data type");
373 template<
typename TArg>
379 return ::asinhf(
arg);
383 static_assert(!
sizeof(TArg),
"Unsupported data type");
390 template<
typename TArg>
400 static_assert(!
sizeof(TArg),
"Unsupported data type");
407 template<
typename TArg>
413 return ::atanhf(
arg);
417 static_assert(!
sizeof(TArg),
"Unsupported data type");
424 template<
typename Ty,
typename Tx>
429 std::enable_if_t<std::is_floating_point_v<Ty> && std::is_floating_point_v<Tx>>>
437 return ::atan2f(y, x);
439 return ::atan2(y, x);
441 static_assert(!
sizeof(Ty),
"Unsupported data type");
448 template<
typename TArg>
458 static_assert(!
sizeof(TArg),
"Unsupported data type");
465 template<
typename TArg>
475 static_assert(!
sizeof(TArg),
"Unsupported data type");
482 template<
typename TArg>
492 template<
typename TMag,
typename TSgn>
497 std::enable_if_t<std::is_floating_point_v<TMag> && std::is_floating_point_v<TSgn>>>
505 return ::copysignf(mag, sgn);
507 return ::copysign(mag, sgn);
509 static_assert(!
sizeof(TMag),
"Unsupported data type");
516 template<
typename TArg>
526 static_assert(!
sizeof(TArg),
"Unsupported data type");
533 template<
typename TArg>
543 static_assert(!
sizeof(TArg),
"Unsupported data type");
550 template<
typename TArg>
560 static_assert(!
sizeof(TArg),
"Unsupported data type");
567 template<
typename TArg>
577 static_assert(!
sizeof(TArg),
"Unsupported data type");
584 template<
typename TArg>
590 return ::floorf(
arg);
594 static_assert(!
sizeof(TArg),
"Unsupported data type");
601 template<
typename Tx,
typename Ty,
typename Tz>
608 std::is_floating_point_v<Tx> && std::is_floating_point_v<Ty> && std::is_floating_point_v<Tz>>>
617 return ::fmaf(x, y, z);
619 return ::fma(x, y, z);
621 static_assert(!
sizeof(Tx),
"Unsupported data type");
623 using Ret [[maybe_unused]] = std::conditional_t<
632 template<
typename Tx,
typename Ty>
637 std::enable_if_t<std::is_floating_point_v<Tx> && std::is_floating_point_v<Ty>>>
645 return ::fmodf(x, y);
649 static_assert(!
sizeof(Tx),
"Unsupported data type");
651 using Ret [[maybe_unused]]
658 template<
typename TArg>
663 return ::isfinite(
arg);
668 template<
typename TArg>
678 template<
typename TArg>
688 template<
typename TArg>
698 static_assert(!
sizeof(TArg),
"Unsupported data type");
705 template<
typename TArg>
715 static_assert(!
sizeof(TArg),
"Unsupported data type");
722 template<
typename TArg>
728 return ::log10f(
arg);
732 static_assert(!
sizeof(TArg),
"Unsupported data type");
739 template<
typename Tx,
typename Ty>
744 std::enable_if_t<std::is_arithmetic_v<Tx> && std::is_arithmetic_v<Ty>>>
751 if constexpr(std::is_integral_v<Tx> && std::is_integral_v<Ty>)
754 return ::fmaxf(x, y);
761 static_assert(!
sizeof(Tx),
"Unsupported data type");
763 using Ret [[maybe_unused]] = std::conditional_t<
764 std::is_integral_v<Tx> && std::is_integral_v<Ty>,
765 decltype(
::max(x, y)),
772 template<
typename Tx,
typename Ty>
777 std::enable_if_t<std::is_arithmetic_v<Tx> && std::is_arithmetic_v<Ty>>>
784 if constexpr(std::is_integral_v<Tx> && std::is_integral_v<Ty>)
787 return ::fminf(x, y);
794 static_assert(!
sizeof(Tx),
"Unsupported data type");
796 using Ret [[maybe_unused]] = std::conditional_t<
797 std::is_integral_v<Tx> && std::is_integral_v<Ty>,
798 decltype(
::min(x, y)),
805 template<
typename TBase,
typename TExp>
810 std::enable_if_t<std::is_floating_point_v<TBase> && std::is_floating_point_v<TExp>>>
818 return ::powf(base,
exp);
820 return ::pow(
static_cast<double>(base),
static_cast<double>(
exp));
822 static_assert(!
sizeof(TBase),
"Unsupported data type");
824 using Ret [[maybe_unused]]
831 template<
typename Tx,
typename Ty>
836 std::enable_if_t<std::is_floating_point_v<Tx> && std::is_floating_point_v<Ty>>>
844 return ::remainderf(x, y);
846 return ::remainder(x, y);
848 static_assert(!
sizeof(Tx),
"Unsupported data type");
850 using Ret [[maybe_unused]]
857 template<
typename TArg>
863 return ::roundf(
arg);
867 static_assert(!
sizeof(TArg),
"Unsupported data type");
874 template<
typename TArg>
880 return ::lroundf(
arg);
882 return ::lround(
arg);
884 static_assert(!
sizeof(TArg),
"Unsupported data type");
891 template<
typename TArg>
897 return ::llroundf(
arg);
899 return ::llround(
arg);
901 static_assert(!
sizeof(TArg),
"Unsupported data type");
904 using Ret [[maybe_unused]] =
long long;
910 template<
typename TArg>
916 return ::rsqrtf(
arg);
920 static_assert(!
sizeof(TArg),
"Unsupported data type");
927 template<
typename TArg>
937 static_assert(!
sizeof(TArg),
"Unsupported data type");
944 template<
typename TArg>
954 static_assert(!
sizeof(TArg),
"Unsupported data type");
961 template<
typename TArg>
968 TArg& result_cos) ->
void
971 ::sincosf(
arg, &result_sin, &result_cos);
975 static_assert(!
sizeof(TArg),
"Unsupported data type");
980 template<
typename TArg>
990 static_assert(!
sizeof(TArg),
"Unsupported data type");
997 template<
typename TArg>
1007 static_assert(!
sizeof(TArg),
"Unsupported data type");
1014 template<
typename TArg>
1020 return ::tanhf(
arg);
1024 static_assert(!
sizeof(TArg),
"Unsupported data type");
1031 template<
typename TArg>
1037 return ::truncf(
arg);
1039 return ::trunc(
arg);
1041 static_assert(!
sizeof(TArg),
"Unsupported data type");
#define ALPAKA_UNREACHABLE(...)
Before CUDA 11.5 nvcc is unable to correctly identify return statements in 'if constexpr' branches....
Implementation of a complex number useable on host and device.
The CUDA built in remainder.
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto max(T const &max_ctx, Tx const &x, Ty const &y)
Returns the larger of two arguments. NaNs are treated as missing data (between a NaN and a numeric va...
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto exp(T const &exp_ctx, TArg const &arg)
Computes the e (Euler's number, 2.7182818) raised to the given power arg.
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto sincos(T const &sincos_ctx, TArg const &arg, TArg &result_sin, TArg &result_cos) -> void
Computes the sine and cosine (measured in radians).
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto min(T const &min_ctx, Tx const &x, Ty const &y)
Returns the smaller of two arguments. NaNs are treated as missing data (between a NaN and a numeric v...
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto atan2(T const &atan2_ctx, Ty const &y, Tx const &x)
Computes the arc tangent of y/x using the signs of arguments to determine the correct quadrant.
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto arg(T const &arg_ctx, TArgument const &argument)
Computes the complex argument of the value.
constexpr auto is_decayed_v
Provides a decaying wrapper around std::is_same. Example: is_decayed_v<volatile float,...
Tag used in class inheritance hierarchies that describes that a specific interface (TInterface) is im...
__host__ __device__ auto operator()(RemainderUniformCudaHipBuiltIn const &, Tx const &x, Ty const &y)