arch/GPU/MathFunctions.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_MATH_FUNCTIONS_GPU_H
11 #define EIGEN_MATH_FUNCTIONS_GPU_H
12 
13 // IWYU pragma: private
14 #include "../../InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
18 namespace internal {
19 
20 // Make sure this is only available when targeting a GPU: we don't want to
21 // introduce conflicts between these packet_traits definitions and the ones
22 // we'll use on the host side (SSE, AVX, ...)
23 #if defined(EIGEN_GPUCC) && defined(EIGEN_USE_GPU)
24 template <>
25 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 plog<float4>(const float4& a) {
26  return make_float4(logf(a.x), logf(a.y), logf(a.z), logf(a.w));
27 }
28 
29 template <>
30 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 plog<double2>(const double2& a) {
32  return make_double2(log(a.x), log(a.y));
33 }
34 
35 template <>
36 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 plog1p<float4>(const float4& a) {
37  return make_float4(log1pf(a.x), log1pf(a.y), log1pf(a.z), log1pf(a.w));
38 }
39 
40 template <>
41 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 plog1p<double2>(const double2& a) {
42  return make_double2(log1p(a.x), log1p(a.y));
43 }
44 
45 template <>
46 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pexp<float4>(const float4& a) {
47  return make_float4(expf(a.x), expf(a.y), expf(a.z), expf(a.w));
48 }
49 
50 template <>
51 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pexp<double2>(const double2& a) {
53  return make_double2(exp(a.x), exp(a.y));
54 }
55 
56 template <>
57 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pexp2<float4>(const float4& a) {
58  return make_float4(exp2f(a.x), exp2f(a.y), exp2f(a.z), exp2f(a.w));
59 }
60 
61 template <>
62 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pexp2<double2>(const double2& a) {
64  return make_double2(exp2(a.x), exp2(a.y));
65 }
66 
67 template <>
68 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pexpm1<float4>(const float4& a) {
69  return make_float4(expm1f(a.x), expm1f(a.y), expm1f(a.z), expm1f(a.w));
70 }
71 
72 template <>
73 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pexpm1<double2>(const double2& a) {
74  return make_double2(expm1(a.x), expm1(a.y));
75 }
76 
77 template <>
78 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 psqrt<float4>(const float4& a) {
79  return make_float4(sqrtf(a.x), sqrtf(a.y), sqrtf(a.z), sqrtf(a.w));
80 }
81 
82 template <>
83 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 psqrt<double2>(const double2& a) {
85  return make_double2(sqrt(a.x), sqrt(a.y));
86 }
87 
88 template <>
89 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 prsqrt<float4>(const float4& a) {
90  return make_float4(rsqrtf(a.x), rsqrtf(a.y), rsqrtf(a.z), rsqrtf(a.w));
91 }
92 
93 template <>
94 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 prsqrt<double2>(const double2& a) {
95  return make_double2(rsqrt(a.x), rsqrt(a.y));
96 }
97 
98 #endif
99 
100 } // end namespace internal
101 
102 } // end namespace Eigen
103 
104 #endif // EIGEN_MATH_FUNCTIONS_GPU_H
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
const Scalar * a
Definition: level2_cplx_impl.h:32
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 exp(const bfloat16 &a)
Definition: BFloat16.h:615
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 expm1(const bfloat16 &a)
Definition: BFloat16.h:617
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log(const bfloat16 &a)
Definition: BFloat16.h:618
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 exp2(const bfloat16 &a)
Definition: BFloat16.h:616
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log1p(const bfloat16 &a)
Definition: BFloat16.h:619
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T rsqrt(const T &x)
Definition: MathFunctions.h:1327
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
Definition: Eigen_Colamd.h:49