alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
math.hpp File Reference
#include "alpaka/Simd.hpp"
#include "alpaka/math/internal/math.hpp"
#include "alpaka/simd/concepts.hpp"
#include <concepts>
#include <type_traits>

Go to the source code of this file.

Namespaces

namespace  alpaka
 main alpaka namespace.
namespace  alpaka::math

Macros

#define ALPAKA_SIMD_MATH_UNARY_OP(className, funcName)
 Specialize unary math function for SIMD types.

Macro Definition Documentation

◆ ALPAKA_SIMD_MATH_UNARY_OP

#define ALPAKA_SIMD_MATH_UNARY_OP ( className,
funcName )
Value:
template<typename T_MathImpl, alpaka::concepts::Simd T_Arg> \
struct className::Op<T_MathImpl, T_Arg> \
{ \
constexpr auto operator()(T_MathImpl mathImpl, T_Arg const& arg) const -> T_Arg \
{ \
using std::funcName; \
if constexpr(requires { funcName(arg.asNativeType()); }) \
{ \
return T_Arg{funcName(arg.asNativeType())}; \
} \
else \
{ \
T_Arg ret{}; \
for(uint32_t i = 0u; i < T_Arg::width(); i++) \
ret[i] = className::Op<T_MathImpl, ALPAKA_TYPEOF(arg[i])>{}(mathImpl, arg[i]); \
return ret; \
} \
} \
}
#define ALPAKA_TYPEOF(...)
Get the type of instance.
Definition common.hpp:153
constexpr auto arg(auto const &arg)
Definition math.hpp:146

Specialize unary math function for SIMD types.

The implementation evaluates if the STL defines a math function for the native type used in the SIMD pack, if there is no STL math specialization available the alpaka math function will be called for each SIMD lane.

Parameters
classNameclass name of the math trait within alpaka
funcNamemath function name within STL
Returns
SIMD pack with result of the math function for each lane

Definition at line 36 of file math.hpp.