HIP: Heterogenous-computing Interface for Portability
math_functions.h
1 /*
2 Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved.
3 
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
21 */
22 
23 #ifndef HIP_INCLUDE_HIP_HCC_DETAIL_MATH_FUNCTIONS_H
24 #define HIP_INCLUDE_HIP_HCC_DETAIL_MATH_FUNCTIONS_H
25 
26 #include <hip/hip_runtime.h>
27 #include <hip/hip_vector_types.h>
28 #include <hip/hcc_detail/device_functions.h>
29 
30 __device__ float acosf(float x);
31 __device__ float acoshf(float x);
32 __device__ float asinf(float x);
33 __device__ float asinhf(float x);
34 __device__ float atan2f(float y, float x);
35 __device__ float atanf(float x);
36 __device__ float atanhf(float x);
37 __device__ float cbrtf(float x);
38 __device__ float ceilf(float x);
39 __device__ float copysignf(float x, float y);
40 __device__ float cosf(float x);
41 __device__ float coshf(float x);
42 __device__ float cospif(float x);
43 //__device__ float cyl_bessel_i0f(float x);
44 //__device__ float cyl_bessel_i1f(float x);
45 __device__ float erfcf(float x);
46 __device__ float erfcinvf(float y);
47 __device__ float erfcxf(float x);
48 __device__ float erff(float x);
49 __device__ float erfinvf(float y);
50 __device__ float exp10f(float x);
51 __device__ float exp2f(float x);
52 __device__ float expf(float x);
53 __device__ float expm1f(float x);
54 __device__ int abs(int x);
55 __device__ float fabsf(float x);
56 __device__ float fdimf(float x, float y);
57 __device__ float fdividef(float x, float y);
58 __device__ float floorf(float x);
59 __device__ float fmaf(float x, float y, float z);
60 __device__ float fmaxf(float x, float y);
61 __device__ float fminf(float x, float y);
62 __device__ float fmodf(float x, float y);
63 //__device__ float frexpf(float x, int* nptr);
64 __device__ float hypotf(float x, float y);
65 __device__ float ilogbf(float x);
66 __device__ int isfinite(float a);
67 __device__ unsigned isinf(float a);
68 __device__ unsigned isnan(float a);
69 __device__ float j0f(float x);
70 __device__ float j1f(float x);
71 __device__ float jnf(int n, float x);
72 __device__ float ldexpf(float x, int exp);
73 __device__ float lgammaf(float x);
74 __device__ long long int llrintf(float x);
75 __device__ long long int llroundf(float x);
76 __device__ float log10f(float x);
77 __device__ float log1pf(float x);
78 __device__ float logbf(float x);
79 __device__ long int lrintf(float x);
80 __device__ long int lroundf(float x);
81 //__device__ float modff(float x, float *iptr);
82 __device__ float nanf(const char* tagp);
83 __device__ float nearbyintf(float x);
84 //__device__ float nextafterf(float x, float y);
85 __device__ float norm3df(float a, float b, float c);
86 __device__ float norm4df(float a, float b, float c, float d);
87 __device__ float normcdff(float y);
88 __device__ float normcdfinvf(float y);
89 __device__ float normf(int dim, const float *a);
90 __device__ float powf(float x, float y);
91 __device__ float rcbrtf(float x);
92 __device__ float remainderf(float x, float y);
93 __device__ float remquof(float x, float y, int *quo);
94 __device__ float rhypotf(float x, float y);
95 __device__ float rintf(float x);
96 __device__ float rnorm3df(float a, float b, float c);
97 __device__ float rnorm4df(float a, float b, float c, float d);
98 __device__ float rnormf(int dim, const float* a);
99 __device__ float roundf(float x);
100 __device__ float rsqrtf(float x);
101 __device__ float scalblnf(float x, long int n);
102 __device__ float scalbnf(float x, int n);
103 __device__ int signbit(float a);
104 __device__ void sincosf(float x, float *sptr, float *cptr);
105 __device__ void sincospif(float x, float *sptr, float *cptr);
106 __device__ float sinf(float x);
107 __device__ float sinhf(float x);
108 __device__ float sinpif(float x);
109 __device__ float sqrtf(float x);
110 __device__ float tanf(float x);
111 __device__ float tanhf(float x);
112 __device__ float tgammaf(float x);
113 __device__ float truncf(float x);
114 __device__ float y0f(float x);
115 __device__ float y1f(float x);
116 __device__ float ynf(int n, float x);
117 
118 __device__ double acos(double x);
119 __device__ double acosh(double x);
120 __device__ double asin(double x);
121 __device__ double asinh(double x);
122 __device__ double atan(double x);
123 __device__ double atan2(double y, double x);
124 __device__ double atanh(double x);
125 __device__ double cbrt(double x);
126 __device__ double ceil(double x);
127 __device__ double copysign(double x, double y);
128 __device__ double cos(double x);
129 __device__ double cosh(double x);
130 __device__ double cospi(double x);
131 //__device__ double cyl_bessel_i0(double x);
132 //__device__ double cyl_bessel_i1(double x);
133 __device__ double erf(double x);
134 __device__ double erfc(double x);
135 __device__ double erfcinv(double y);
136 __device__ double erfcx(double x);
137 __device__ double erfinv(double x);
138 __device__ double exp(double x);
139 __device__ double exp10(double x);
140 __device__ double exp2(double x);
141 __device__ double expm1(double x);
142 __device__ double fabs(double x);
143 __device__ double fdim(double x, double y);
144 __device__ double floor(double x);
145 __device__ double fma(double x, double y, double z);
146 __device__ double fmax(double x, double y);
147 __device__ double fmin(double x, double y);
148 __device__ double fmod(double x, double y);
149 //__device__ double frexp(double x, int *nptr);
150 __device__ double hypot(double x, double y);
151 __device__ double ilogb(double x);
152 __device__ int isfinite(double x);
153 __device__ unsigned isinf(double x);
154 __device__ unsigned isnan(double x);
155 __device__ double j0(double x);
156 __device__ double j1(double x);
157 __device__ double jn(int n, double x);
158 __device__ double ldexp(double x, int exp);
159 __device__ double lgamma(double x);
160 __device__ long long llrint(double x);
161 __device__ long long llround(double x);
162 __device__ double log(double x);
163 __device__ double log10(double x);
164 __device__ double log1p(double x);
165 __device__ double log2(double x);
166 __device__ double logb(double x);
167 __device__ long int lrint(double x);
168 __device__ long int lround(double x);
169 //__device__ double modf(double x, double *iptr);
170 __device__ double nan(const char* tagp);
171 __device__ double nearbyint(double x);
172 __device__ double nextafter(double x, double y);
173 __device__ double norm(int dim, const double* t);
174 __device__ double norm3d(double a, double b, double c);
175 __device__ double norm4d(double a, double b, double c, double d);
176 __device__ double normcdf(double y);
177 __device__ double normcdfinv(double y);
178 __device__ double pow(double x, double y);
179 __device__ double rcbrt(double x);
180 __device__ double remainder(double x, double y);
181 //__device__ double remquo(double x, double y, int *quo);
182 __device__ double rhypot(double x, double y);
183 __device__ double rint(double x);
184 __device__ double rnorm(int dim, const double* t);
185 __device__ double rnorm3d(double a, double b, double c);
186 __device__ double rnorm4d(double a, double b, double c, double d);
187 __device__ double round(double x);
188 __device__ double rsqrt(double x);
189 __device__ double scalbln(double x, long int n);
190 __device__ double scalbn(double x, int n);
191 __device__ int signbit(double a);
192 __device__ double sin(double a);
193 __device__ void sincos(double x, double *sptr, double *cptr);
194 __device__ void sincospi(double x, double *sptr, double *cptr);
195 __device__ double sinh(double x);
196 __device__ double sinpi(double x);
197 __device__ double sqrt(double x);
198 __device__ double tan(double x);
199 __device__ double tanh(double x);
200 __device__ double tgamma(double x);
201 __device__ double trunc(double x);
202 __device__ double y0(double x);
203 __device__ double y1(double y);
204 __device__ double yn(int n, double x);
205 
206 // ENDPARSER
207 
208 #ifdef HIP_FAST_MATH
209 // Single Precision Precise Math when enabled
210 
211 __device__ inline float cosf(float x) {
212  return __hip_fast_cosf(x);
213 }
214 
215 __device__ inline float exp10f(float x) {
216  return __hip_fast_exp10f(x);
217 }
218 
219 __device__ inline float expf(float x) {
220  return __hip_fast_expf(x);
221 }
222 
223 __device__ inline float log10f(float x) {
224  return __hip_fast_log10f(x);
225 }
226 
227 __device__ inline float log2f(float x) {
228  return __hip_fast_log2f(x);
229 }
230 
231 __device__ inline float logf(float x) {
232  return __hip_fast_logf(x);
233 }
234 
235 __device__ inline float powf(float base, float exponent) {
236  return __hip_fast_powf(base, exponent);
237 }
238 
239 __device__ inline void sincosf(float x, float *s, float *c) {
240  return __hip_fast_sincosf(x, s, c);
241 }
242 
243 __device__ inline float sinf(float x) {
244  return __hip_fast_sinf(x);
245 }
246 
247 __device__ inline float tanf(float x) {
248  return __hip_fast_tanf(x);
249 }
250 
251 #else
252 
253 __device__ float sinf(float);
254 __device__ float cosf(float);
255 __device__ float tanf(float);
256 __device__ void sincosf(float, float*, float*);
257 __device__ float logf(float);
258 __device__ float log2f(float);
259 __device__ float log10f(float);
260 __device__ float expf(float);
261 __device__ float exp10f(float);
262 __device__ float powf(float, float);
263 
264 #endif
265 
266 
267 #endif