2424#ifdef ALPAKA_ACC_GPU_CUDA_ENABLED
2525
2626#include < alpaka/core/Common.hpp>
27+ #include < alpaka/core/Unused.hpp>
2728
2829#if !BOOST_LANG_CUDA
2930 #error If ALPAKA_ACC_GPU_CUDA_ENABLED is set, the compiler has to support CUDA!
3031#endif
3132
3233#include < alpaka/math/abs/Traits.hpp>
3334
34- // #include <boost/core/ignore_unused.hpp>
35-
3635#include < cuda_runtime.h>
3736#include < type_traits>
3837
@@ -42,7 +41,7 @@ namespace alpaka
4241 namespace math
4342 {
4443 // #############################################################################
45- // ! The standard library abs.
44+ // ! The CUDA built in abs.
4645 class AbsCudaBuiltIn
4746 {
4847 public:
@@ -62,14 +61,44 @@ namespace alpaka
6261 std::is_floating_point<TArg>::value>::type>
6362 {
6463 ALPAKA_FN_ACC_CUDA_ONLY static auto abs (
65- AbsCudaBuiltIn const & /* abs */ ,
64+ AbsCudaBuiltIn const & abs_ctx ,
6665 TArg const & arg)
6766 -> decltype(::abs(arg))
6867 {
69- // boost ::ignore_unused(abs );
68+ alpaka ::ignore_unused (abs_ctx );
7069 return ::abs (arg);
7170 }
7271 };
72+ // ! The CUDA built in abs double specialization.
73+ template <>
74+ struct Abs <
75+ AbsCudaBuiltIn,
76+ double >
77+ {
78+ __device__ static auto abs (
79+ AbsCudaBuiltIn const & abs_ctx,
80+ double const & arg)
81+ -> decltype(::fabs(arg))
82+ {
83+ alpaka::ignore_unused (abs_ctx);
84+ return ::fabs (arg);
85+ }
86+ };
87+ // ! The CUDA built in abs float specialization.
88+ template <>
89+ struct Abs <
90+ AbsCudaBuiltIn,
91+ float >
92+ {
93+ __device__ static auto abs (
94+ AbsCudaBuiltIn const & abs_ctx,
95+ float const & arg)
96+ -> float
97+ {
98+ alpaka::ignore_unused (abs_ctx);
99+ return ::fabsf (arg);
100+ }
101+ };
73102 }
74103 }
75104}
0 commit comments