HCC
HCC is a single-source, C/C++ compiler for heterogeneous computing. It's optimized with HSA (http://www.hsafoundation.com/).
kalmar_math.h
1 //===----------------------------------------------------------------------===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 
8 #pragma once
9 
10 #include <cmath>
11 #include <stdexcept>
12 
13 extern "C" __fp16 __hc_acos_half(__fp16 x) restrict(amp);
14 extern "C" float __hc_acos(float x) restrict(amp);
15 extern "C" double __hc_acos_double(double x) restrict(amp);
16 
17 extern "C" __fp16 __hc_acosh_half(__fp16 x) restrict(amp);
18 extern "C" float __hc_acosh(float x) restrict(amp);
19 extern "C" double __hc_acosh_double(double x) restrict(amp);
20 
21 extern "C" __fp16 __hc_asin_half(__fp16 x) restrict(amp);
22 extern "C" float __hc_asin(float x) restrict(amp);
23 extern "C" double __hc_asin_double(double x) restrict(amp);
24 
25 extern "C" __fp16 __hc_asinh_half(__fp16 x) restrict(amp);
26 extern "C" float __hc_asinh(float x) restrict(amp);
27 extern "C" double __hc_asinh_double(double x) restrict(amp);
28 
29 extern "C" __fp16 __hc_atan_half(__fp16 x) restrict(amp);
30 extern "C" float __hc_atan(float x) restrict(amp);
31 extern "C" double __hc_atan_double(double x) restrict(amp);
32 
33 extern "C" __fp16 __hc_atanh_half(__fp16 x) restrict(amp);
34 extern "C" float __hc_atanh(float x) restrict(amp);
35 extern "C" double __hc_atanh_double(double x) restrict(amp);
36 
37 extern "C" __fp16 __hc_atan2_half(__fp16 y, __fp16 x) restrict(amp);
38 extern "C" float __hc_atan2(float y, float x) restrict(amp);
39 extern "C" double __hc_atan2_double(double y, double x) restrict(amp);
40 
41 extern "C" __fp16 __hc_cbrt_half(__fp16 x) restrict(amp);
42 extern "C" float __hc_cbrt(float x) restrict(amp);
43 extern "C" double __hc_cbrt_double(double x) restrict(amp);
44 
45 extern "C" __fp16 __hc_ceil_half(__fp16 x) restrict(amp);
46 extern "C" float __hc_ceil(float x) restrict(amp);
47 extern "C" double __hc_ceil_double(double x) restrict(amp);
48 
49 extern "C" __fp16 __hc_copysign_half(__fp16 x, __fp16 y) restrict(amp);
50 extern "C" float __hc_copysign(float x, float y) restrict(amp);
51 extern "C" double __hc_copysign_double(double x, double y) restrict(amp);
52 
53 extern "C" __fp16 __hc_cos_half(__fp16 x) restrict(amp);
54 extern "C" __fp16 __hc_cos_native_half(__fp16 x) restrict(amp);
55 extern "C" float __hc_cos(float x) restrict(amp);
56 extern "C" float __hc_cos_native(float x) restrict(amp);
57 extern "C" double __hc_cos_double(double x) restrict(amp);
58 
59 extern "C" __fp16 __hc_cosh_half(__fp16 x) restrict(amp);
60 extern "C" float __hc_cosh(float x) restrict(amp);
61 extern "C" double __hc_cosh_double(double x) restrict(amp);
62 
63 extern "C" __fp16 __hc_cospi_half(__fp16 x) restrict(amp);
64 extern "C" float __hc_cospi(float x) restrict(amp);
65 extern "C" double __hc_cospi_double(double x) restrict(amp);
66 
67 extern "C" __fp16 __hc_erf_half(__fp16 x) restrict(amp);
68 extern "C" float __hc_erf(float x) restrict(amp);
69 extern "C" double __hc_erf_double(double x) restrict(amp);
70 
71 extern "C" __fp16 __hc_erfc_half(__fp16 x) restrict(amp);
72 extern "C" float __hc_erfc(float x) restrict(amp);
73 extern "C" double __hc_erfc_double(double x) restrict(amp);
74 
75 extern "C" __fp16 __hc_erfcinv_half(__fp16 x) restrict(amp);
76 extern "C" float __hc_erfcinv(float x) restrict(amp);
77 extern "C" double __hc_erfcinv_double(double x) restrict(amp);
78 
79 extern "C" __fp16 __hc_erfinv_half(__fp16 x) restrict(amp);
80 extern "C" float __hc_erfinv(float x) restrict(amp);
81 extern "C" double __hc_erfinv_double(double x) restrict(amp);
82 
83 extern "C" __fp16 __hc_exp_half(__fp16 x) restrict(amp);
84 extern "C" float __hc_exp(float x) restrict(amp);
85 extern "C" double __hc_exp_double(double x) restrict(amp);
86 
87 extern "C" __fp16 __hc_exp10_half(__fp16 x) restrict(amp);
88 extern "C" float __hc_exp10(float x) restrict(amp);
89 extern "C" double __hc_exp10_double(double x) restrict(amp);
90 
91 extern "C" __fp16 __hc_exp2_native_half(__fp16 x) restrict(amp);
92 extern "C" __fp16 __hc_exp2_half(__fp16 x) restrict(amp);
93 extern "C" float __hc_exp2(float x) restrict(amp);
94 extern "C" float __hc_exp2_native(float x) restrict(amp);
95 extern "C" double __hc_exp2_double(double x) restrict(amp);
96 
97 extern "C" __fp16 __hc_expm1_half(__fp16 x) restrict(amp);
98 extern "C" float __hc_expm1(float x) restrict(amp);
99 extern "C" double __hc_expm1_double(double x) restrict(amp);
100 
101 extern "C" __fp16 __hc_fabs_half(__fp16 x) restrict(amp);
102 extern "C" float __hc_fabs(float x) restrict(amp);
103 extern "C" double __hc_fabs_double(double x) restrict(amp);
104 
105 extern "C" __fp16 __hc_fdim_half(__fp16 x, __fp16 y) restrict(amp);
106 extern "C" float __hc_fdim(float x, float y) restrict(amp);
107 extern "C" double __hc_fdim_double(double x, double y) restrict(amp);
108 
109 extern "C" __fp16 __hc_floor_half(__fp16 x) restrict(amp);
110 extern "C" float __hc_floor(float x) restrict(amp);
111 extern "C" double __hc_floor_double(double x) restrict(amp);
112 
113 extern "C" __fp16 __hc_fma_half(__fp16 x, __fp16 y, __fp16 z) restrict(amp);
114 extern "C" float __hc_fma(float x, float y, float z) restrict(amp);
115 extern "C" double __hc_fma_double(double x, double y, double z) restrict(amp);
116 
117 extern "C" __fp16 __hc_fmax_half(__fp16 x, __fp16 y) restrict(amp);
118 extern "C" float __hc_fmax(float x, float y) restrict(amp);
119 extern "C" double __hc_fmax_double(double x, double y) restrict(amp);
120 
121 extern "C" __fp16 __hc_fmin_half(__fp16 x, __fp16 y) restrict(amp);
122 extern "C" float __hc_fmin(float x, float y) restrict(amp);
123 extern "C" double __hc_fmin_double(double x, double y) restrict(amp);
124 
125 extern "C" __fp16 __hc_fmod_half(__fp16 x, __fp16 y) restrict(amp);
126 extern "C" float __hc_fmod(float x, float y) restrict(amp);
127 extern "C" double __hc_fmod_double(double x, double y) restrict(amp);
128 
129 extern "C" int __hc_fpclassify_half(__fp16 x) restrict(amp);
130 extern "C" int __hc_fpclassify(float x) restrict(amp);
131 extern "C" int __hc_fpclassify_double(double x) restrict(amp);
132 
133 extern "C" __fp16 __hc_frexp_half(__fp16 x, int *exp) restrict(amp);
134 extern "C" float __hc_frexp(float x, int *exp) restrict(amp);
135 extern "C" double __hc_frexp_double(double x, int *exp) restrict(amp);
136 
137 extern "C" __fp16 __hc_hypot_half(__fp16 x, __fp16 y) restrict(amp);
138 extern "C" float __hc_hypot(float x, float y) restrict(amp);
139 extern "C" double __hc_hypot_double(double x, double y) restrict(amp);
140 
141 extern "C" int __hc_ilogb_half(__fp16 x) restrict(amp);
142 extern "C" int __hc_ilogb(float x) restrict(amp);
143 extern "C" int __hc_ilogb_double(double x) restrict(amp);
144 
145 extern "C" int __hc_isfinite_half(__fp16 x) restrict(amp);
146 extern "C" int __hc_isfinite(float x) restrict(amp);
147 extern "C" int __hc_isfinite_double(double x) restrict(amp);
148 
149 extern "C" int __hc_isinf_half(__fp16 x) restrict(amp);
150 extern "C" int __hc_isinf(float x) restrict(amp);
151 extern "C" int __hc_isinf_double(double x) restrict(amp);
152 
153 extern "C" int __hc_isnan_half(__fp16 x) restrict(amp);
154 extern "C" int __hc_isnan(float x) restrict(amp);
155 extern "C" int __hc_isnan_double(double x) restrict(amp);
156 
157 extern "C" int __hc_isnormal_half(__fp16 x) restrict(amp);
158 extern "C" int __hc_isnormal(float x) restrict(amp);
159 extern "C" int __hc_isnormal_double(double x) restrict(amp);
160 
161 extern "C" __fp16 __hc_ldexp_half(__fp16 x, std::int16_t exp) [[hc]];
162 extern "C" float __hc_ldexp(float x, int exp) restrict(amp);
163 extern "C" double __hc_ldexp_double(double x, int exp) restrict(amp);
164 
165 extern "C" __fp16 __hc_lgamma_half(__fp16 x) restrict(amp);
166 extern "C" float __hc_lgamma(float x) restrict(amp);
167 extern "C" double __hc_lgamma_double(double x) restrict(amp);
168 
169 extern "C" __fp16 __hc_log_half(__fp16 x) restrict(amp);
170 extern "C" float __hc_log(float x) restrict(amp);
171 extern "C" float __hc_log_native(float x) restrict(amp);
172 extern "C" double __hc_log_double(double x) restrict(amp);
173 
174 extern "C" __fp16 __hc_log10_half(__fp16 x) restrict(amp);
175 extern "C" float __hc_log10(float x) restrict(amp);
176 extern "C" double __hc_log10_double(double x) restrict(amp);
177 
178 extern "C" __fp16 __hc_log2_half(__fp16 x) restrict(amp);
179 extern "C" __fp16 __hc_log2_native_half(__fp16 x) restrict(amp);
180 extern "C" float __hc_log2(float x) restrict(amp);
181 extern "C" float __hc_log2_native(float x) restrict(amp);
182 extern "C" double __hc_log2_double(double x) restrict(amp);
183 
184 extern "C" __fp16 __hc_log1p_half(__fp16 x) restrict(amp);
185 extern "C" float __hc_log1p(float x) restrict(amp);
186 extern "C" double __hc_log1p_double(double x) restrict(amp);
187 
188 extern "C" __fp16 __hc_logb_half(__fp16 x) restrict(amp);
189 extern "C" float __hc_logb(float x) restrict(amp);
190 extern "C" double __hc_logb_double(double x) restrict(amp);
191 
192 extern "C" __fp16 __hc_modf_half(__fp16 x, __fp16 *iptr) restrict(amp);
193 extern "C" float __hc_modf(float x, float *iptr) restrict(amp);
194 extern "C" double __hc_modf_double(double x, double *iptr) restrict(amp);
195 
196 extern "C" __fp16 __hc_nan_half(int tagp) restrict(amp);
197 extern "C" float __hc_nan(int tagp) restrict(amp);
198 extern "C" double __hc_nan_double(unsigned long tagp) restrict(amp);
199 
200 extern "C" __fp16 __hc_nearbyint_half(__fp16 x) restrict(amp);
201 extern "C" float __hc_nearbyint(float x) restrict(amp);
202 extern "C" double __hc_nearbyint_double(double x) restrict(amp);
203 
204 extern "C" __fp16 __hc_nextafter_half(__fp16 x, __fp16 y) restrict(amp);
205 extern "C" float __hc_nextafter(float x, float y) restrict(amp);
206 extern "C" double __hc_nextafter_double(double x, double y) restrict(amp);
207 
208 extern "C" __fp16 __hc_pow_half(__fp16 x, __fp16 y) restrict(amp);
209 extern "C" float __hc_pow(float x, float y) restrict(amp);
210 extern "C" double __hc_pow_double(double x, double y) restrict(amp);
211 
212 extern "C" __fp16 __hc_rcbrt_half(__fp16 x) restrict(amp);
213 extern "C" float __hc_rcbrt(float x) restrict(amp);
214 extern "C" double __hc_rcbrt_double(double x) restrict(amp);
215 
216 // TODO: rcp is implementation only, it does not have a public interface.
217 extern "C" __fp16 __hc_rcp_native_half(__fp16 x) restrict(amp);
218 extern "C" float __hc_rcp_native(float x) restrict(amp);
219 
220 extern "C" __fp16 __hc_remainder_half(__fp16 x, __fp16 y) restrict(amp);
221 extern "C" float __hc_remainder(float x, float y) restrict(amp);
222 extern "C" double __hc_remainder_double(double x, double y) restrict(amp);
223 
224 extern "C" __fp16 __hc_remquo_half(__fp16 x, __fp16 y, int *quo) restrict(amp);
225 extern "C" float __hc_remquo(float x, float y, int *quo) restrict(amp);
226 extern "C" double __hc_remquo_double(double x, double y, int *quo) restrict(amp);
227 
228 extern "C" __fp16 __hc_round_half(__fp16 x) restrict(amp);
229 extern "C" float __hc_round(float x) restrict(amp);
230 extern "C" double __hc_round_double(double x) restrict(amp);
231 
232 extern "C" __fp16 __hc_rsqrt_half(__fp16 x) restrict(amp);
233 extern "C" __fp16 __hc_rsqrt_native_half(__fp16 x) restrict(amp);
234 extern "C" float __hc_rsqrt(float x) restrict(amp);
235 extern "C" float __hc_rsqrt_native(float x) restrict(amp);
236 extern "C" double __hc_rsqrt_double(double x) restrict(amp);
237 
238 extern "C" __fp16 __hc_scalb_half(__fp16 x, __fp16 exp) restrict(amp);
239 extern "C" float __hc_scalb(float x, float exp) restrict(amp);
240 extern "C" double __hc_scalb_double(double x, double exp) restrict(amp);
241 
242 extern "C" __fp16 __hc_scalbn_half(__fp16 x, int exp) restrict(amp);
243 extern "C" float __hc_scalbn(float x, int exp) restrict(amp);
244 extern "C" double __hc_scalbn_double(double x, int exp) restrict(amp);
245 
246 extern "C" __fp16 __hc_sinpi_half(__fp16 x) restrict(amp);
247 extern "C" float __hc_sinpi(float x) restrict(amp);
248 extern "C" double __hc_sinpi_double(double x) restrict(amp);
249 
250 extern "C" int __hc_signbit_half(__fp16 x) restrict(amp);
251 extern "C" int __hc_signbit(float x) restrict(amp);
252 extern "C" int __hc_signbit_double(double x) restrict(amp);
253 
254 extern "C" __fp16 __hc_sin_half(__fp16 x) restrict(amp);
255 extern "C" __fp16 __hc_sin_native_half(__fp16 x) restrict(amp);
256 extern "C" float __hc_sin(float x) restrict(amp);
257 extern "C" float __hc_sin_native(float x) restrict(amp);
258 extern "C" double __hc_sin_double(double x) restrict(amp);
259 
260 extern "C" __fp16 __hc_sincos_half(__fp16 x, __fp16 *c) restrict(amp);
261 extern "C" float __hc_sincos(float x, float *c) restrict(amp);
262 extern "C" double __hc_sincos_double(double x, double *c) restrict(amp);
263 
264 extern "C" __fp16 __hc_sinh_half(__fp16 x) restrict(amp);
265 extern "C" float __hc_sinh(float x) restrict(amp);
266 extern "C" double __hc_sinh_double(double x) restrict(amp);
267 
268 extern "C" __fp16 __hc_sqrt_half(__fp16 x) restrict(amp);
269 extern "C" __fp16 __hc_sqrt_native_half(__fp16 x) restrict(amp);
270 extern "C" float __hc_sqrt(float x) restrict(amp);
271 extern "C" float __hc_sqrt_native(float x) restrict(amp);
272 extern "C" double __hc_sqrt_double(double x) restrict(amp);
273 
274 extern "C" __fp16 __hc_tgamma_half(__fp16 x) restrict(amp);
275 extern "C" float __hc_tgamma(float x) restrict(amp);
276 extern "C" double __hc_tgamma_double(double x) restrict(amp);
277 
278 extern "C" __fp16 __hc_tan_half(__fp16 x) restrict(amp);
279 extern "C" float __hc_tan(float x) restrict(amp);
280 extern "C" double __hc_tan_double(double x) restrict(amp);
281 
282 extern "C" __fp16 __hc_tanh_half(__fp16 x) restrict(amp);
283 extern "C" float __hc_tanh(float x) restrict(amp);
284 extern "C" double __hc_tanh_double(double x) restrict(amp);
285 
286 extern "C" __fp16 __hc_tanpi_half(__fp16 x) restrict(amp);
287 extern "C" float __hc_tanpi(float x) restrict(amp);
288 extern "C" double __hc_tanpi_double(double x) restrict(amp);
289 
290 extern "C" __fp16 __hc_trunc_half(__fp16 x) restrict(amp);
291 extern "C" float __hc_trunc(float x) restrict(amp);
292 extern "C" double __hc_trunc_double(double x) restrict(amp);
293 
294 #define HCC_MATH_LIB_FN inline __attribute__((used, hc))
295 namespace Kalmar
296 {
297  namespace fast_math
298  {
299  using std::acos;
300  using ::acosf;
301  using std::asin;
302  using ::asinf;
303  using std::atan;
304  using ::atanf;
305  using std::atan2;
306  using ::atan2f;
307  using std::ceil;
308  using ::ceilf;
309  using std::cos;
310  using ::cosf;
311  using std::cosh;
312  using ::coshf;
313  using std::exp;
314  using ::exp10;
315  using std::exp2;
316  using ::exp10f;
317  using ::exp2f;
318  using ::expf;
319  using std::fabs;
320  using ::fabsf;
321  using std::floor;
322  using ::floorf;
323  using std::fmax;
324  using ::fmaxf;
325  using std::fmin;
326  using ::fminf;
327  using std::fmod;
328  using ::fmodf;
329  using std::frexp;
330  using ::frexpf;
331  using std::isfinite;
332  using std::isinf;
333  using std::isnan;
334  using std::isnormal;
335  using std::ldexp;
336  using ::ldexpf;
337  using std::log;
338  using ::logf;
339  using std::log10;
340  using ::log10f;
341  using std::log2;
342  using ::log2f;
343  using std::modf;
344  using ::modff;
345  using std::pow;
346  using ::powf;
347  using std::round;
348  using ::roundf;
349  using std::signbit;
350  using std::sin;
351  using ::sinf;
352  using std::sinh;
353  using ::sinhf;
354  using std::sqrt;
355  using ::sqrtf;
356  using std::tan;
357  using ::tanf;
358  using std::tanh;
359  using ::tanhf;
360  using std::trunc;
361  using ::truncf;
362 
363  HCC_MATH_LIB_FN
364  float acosf(float x) { return __hc_acos(x); }
365 
366  HCC_MATH_LIB_FN
367  __fp16 acos(__fp16 x) { return __hc_acos_half(x); }
368 
369  HCC_MATH_LIB_FN
370  float acos(float x) { return fast_math::acosf(x); }
371 
372  HCC_MATH_LIB_FN
373  float asinf(float x) { return __hc_asin(x); }
374 
375  HCC_MATH_LIB_FN
376  __fp16 asin(__fp16 x) { return __hc_asin_half(x); }
377 
378  HCC_MATH_LIB_FN
379  float asin(float x) { return fast_math::asinf(x); }
380 
381  HCC_MATH_LIB_FN
382  float atanf(float x) { return __hc_atan(x); }
383 
384  HCC_MATH_LIB_FN
385  __fp16 atan(__fp16 x) { return __hc_atan_half(x); }
386 
387  HCC_MATH_LIB_FN
388  float atan(float x) { return fast_math::atanf(x); }
389 
390  HCC_MATH_LIB_FN
391  float atan2f(float y, float x) { return __hc_atan2(y, x); }
392 
393  HCC_MATH_LIB_FN
394  __fp16 atan2(__fp16 y, __fp16 x) { return __hc_atan2_half(y, x); }
395 
396  HCC_MATH_LIB_FN
397  float atan2(float y, float x) { return fast_math::atan2f(y, x); }
398 
399  HCC_MATH_LIB_FN
400  float ceilf(float x) { return __hc_ceil(x); }
401 
402  HCC_MATH_LIB_FN
403  __fp16 ceil(__fp16 x) { return __hc_ceil_half(x); }
404 
405  HCC_MATH_LIB_FN
406  float ceil(float x) { return fast_math::ceilf(x); }
407 
408  HCC_MATH_LIB_FN
409  float cosf(float x) { return __hc_cos_native(x); }
410 
411  HCC_MATH_LIB_FN
412  __fp16 cos(__fp16 x) { return __hc_cos_native_half(x); }
413 
414  HCC_MATH_LIB_FN
415  float cos(float x) { return fast_math::cosf(x); }
416 
417  HCC_MATH_LIB_FN
418  float coshf(float x) { return __hc_cosh(x); }
419 
420  HCC_MATH_LIB_FN
421  __fp16 cosh(__fp16 x) { return __hc_cosh_half(x); }
422 
423  HCC_MATH_LIB_FN
424  float cosh(float x) { return fast_math::coshf(x); }
425 
426  HCC_MATH_LIB_FN
427  float expf(float x) { return __hc_exp2_native(M_LOG2E * x); }
428 
429  HCC_MATH_LIB_FN
430  __fp16 exp(__fp16 x) { return __hc_exp2_native_half(M_LOG2E * x); }
431 
432  HCC_MATH_LIB_FN
433  float exp(float x) { return fast_math::expf(x); }
434 
435  HCC_MATH_LIB_FN
436  float exp2f(float x) { return __hc_exp2_native(x); }
437 
438  HCC_MATH_LIB_FN
439  __fp16 exp2(__fp16 x) { return __hc_exp2_native_half(x); }
440 
441  HCC_MATH_LIB_FN
442  float exp2(float x) { return fast_math::exp2f(x); }
443 
444  HCC_MATH_LIB_FN
445  float fabsf(float x) { return __hc_fabs(x); }
446 
447  HCC_MATH_LIB_FN
448  __fp16 fabs(__fp16 x) { return __hc_fabs_half(x); }
449 
450  HCC_MATH_LIB_FN
451  float fabs(float x) { return fast_math::fabsf(x); }
452 
453  HCC_MATH_LIB_FN
454  float floorf(float x) { return __hc_floor(x); }
455 
456  HCC_MATH_LIB_FN
457  __fp16 floor(__fp16 x) { return __hc_floor_half(x); }
458 
459  HCC_MATH_LIB_FN
460  float floor(float x) { return fast_math::floorf(x); }
461 
462  HCC_MATH_LIB_FN
463  float fmaxf(float x, float y) { return __hc_fmax(x, y); }
464 
465  HCC_MATH_LIB_FN
466  __fp16 fmax(__fp16 x, __fp16 y) { return __hc_fmax_half(x, y); }
467 
468  HCC_MATH_LIB_FN
469  float fmax(float x, float y) { return fast_math::fmaxf(x, y); }
470 
471  HCC_MATH_LIB_FN
472  float fminf(float x, float y) { return __hc_fmin(x, y); }
473 
474  HCC_MATH_LIB_FN
475  __fp16 fmin(__fp16 x, __fp16 y) { return __hc_fmin_half(x, y); }
476 
477  HCC_MATH_LIB_FN
478  float fmin(float x, float y) { return fast_math::fminf(x, y); }
479 
480  HCC_MATH_LIB_FN
481  float fmodf(float x, float y) { return __hc_fmod(x, y); }
482 
483  HCC_MATH_LIB_FN
484  __fp16 fmod(__fp16 x, __fp16 y) { return __hc_fmod_half(x, y); }
485 
486  HCC_MATH_LIB_FN
487  float fmod(float x, float y) { return fast_math::fmodf(x, y); }
488 
489  HCC_MATH_LIB_FN
490  float frexpf(float x, int *exp) { return __hc_frexp(x, exp); }
491 
492  HCC_MATH_LIB_FN
493  __fp16 frexp(__fp16 x, int *exp) { return __hc_frexp_half(x, exp); }
494 
495  HCC_MATH_LIB_FN
496  float frexp(float x, int *exp) { return fast_math::frexpf(x, exp); }
497 
498  HCC_MATH_LIB_FN
499  int isfinite(__fp16 x) { return __hc_isfinite_half(x); }
500 
501  HCC_MATH_LIB_FN
502  int isfinite(float x) { return __hc_isfinite(x); }
503 
504  HCC_MATH_LIB_FN
505  int isinf(__fp16 x) { return __hc_isinf_half(x); }
506 
507  HCC_MATH_LIB_FN
508  int isinf(float x) { return __hc_isinf(x); }
509 
510  HCC_MATH_LIB_FN
511  int isnan(__fp16 x) { return __hc_isnan_half(x); }
512 
513  HCC_MATH_LIB_FN
514  int isnan(float x) { return __hc_isnan(x); }
515 
516  HCC_MATH_LIB_FN
517  float ldexpf(float x, int exp) { return __hc_ldexp(x,exp); }
518 
519  HCC_MATH_LIB_FN
520  __fp16 ldexp(__fp16 x, std::uint16_t exp)
521  {
522  return __hc_ldexp_half(x, exp);
523  }
524 
525  HCC_MATH_LIB_FN
526  float ldexp(float x, int exp) { return fast_math::ldexpf(x, exp); }
527 
528  namespace
529  { // TODO: this is temporary, lifted straight out of irif.h.
530  // Namespace is merely for documentation.
531  #define M_LOG2_10_F 0x1.a934f0p+1f
532  // Value of 1 / log2(10)
533  #define M_RLOG2_10_F 0x1.344136p-2f
534  // Value of 1 / M_LOG2E_F = 1 / log2(e)
535  #define M_RLOG2_E_F 0x1.62e430p-1f
536  }
537 
538  HCC_MATH_LIB_FN
539  float logf(float x) { return __hc_log2_native(x) * M_RLOG2_E_F; }
540 
541  HCC_MATH_LIB_FN
542  __fp16 log(__fp16 x)
543  {
544  return __hc_log2_native_half(x) * static_cast<__fp16>(M_RLOG2_E_F);
545  }
546 
547  HCC_MATH_LIB_FN
548  float log(float x) { return fast_math::logf(x); }
549 
550  HCC_MATH_LIB_FN
551  float log10f(float x) { return __hc_log2_native(x) * M_RLOG2_10_F; }
552 
553  HCC_MATH_LIB_FN
554  __fp16 log10(__fp16 x)
555  {
556  return __hc_log2_native_half(x) * static_cast<__fp16>(M_RLOG2_10_F);
557  }
558 
559  HCC_MATH_LIB_FN
560  float log10(float x) { return fast_math::log10f(x); }
561 
562  HCC_MATH_LIB_FN
563  float log2f(float x) { return __hc_log2_native(x); }
564 
565  HCC_MATH_LIB_FN
566  __fp16 log2(__fp16 x) { return __hc_log2_native_half(x); }
567 
568  HCC_MATH_LIB_FN
569  float log2(float x) { return fast_math::log2f(x); }
570 
571  HCC_MATH_LIB_FN
572  float modff(float x, float *iptr) { return __hc_modf(x, iptr); }
573 
574  HCC_MATH_LIB_FN
575  __fp16 modf(__fp16 x, __fp16 *iptr) { return __hc_modf_half(x, iptr); }
576 
577 
578  HCC_MATH_LIB_FN
579  float modf(float x, float *iptr) { return fast_math::modff(x, iptr); }
580 
581  HCC_MATH_LIB_FN
582  float powf(float x, float y) { return __hc_pow(x, y); }
583 
584  HCC_MATH_LIB_FN
585  __fp16 pow(__fp16 x, __fp16 y) { return __hc_pow_half(x, y); }
586 
587  HCC_MATH_LIB_FN
588  float pow(float x, float y) { return fast_math::powf(x, y); }
589 
590  HCC_MATH_LIB_FN
591  float roundf(float x) { return __hc_round(x); }
592 
593  HCC_MATH_LIB_FN
594  __fp16 round(__fp16 x) { return __hc_round_half(x); }
595 
596  HCC_MATH_LIB_FN
597  float round(float x) { return fast_math::roundf(x); }
598 
599  HCC_MATH_LIB_FN
600  float rsqrtf(float x) { return __hc_rsqrt_native(x); }
601 
602  HCC_MATH_LIB_FN
603  __fp16 rsqrt(__fp16 x) { return __hc_rsqrt_native_half(x); }
604 
605  HCC_MATH_LIB_FN
606  float rsqrt(float x) { return fast_math::rsqrtf(x); }
607 
608  HCC_MATH_LIB_FN
609  int signbitf(float x) { return __hc_signbit(x); }
610 
611  HCC_MATH_LIB_FN
612  int signbit(__fp16 x) { return __hc_signbit_half(x); }
613 
614  HCC_MATH_LIB_FN
615  int signbit(float x) { return fast_math::signbitf(x); }
616 
617  HCC_MATH_LIB_FN
618  float sinf(float x) { return __hc_sin_native(x); }
619 
620  HCC_MATH_LIB_FN
621  __fp16 sin(__fp16 x) { return __hc_sin_native_half(x); }
622 
623  HCC_MATH_LIB_FN
624  float sin(float x) { return fast_math::sinf(x); }
625 
626  HCC_MATH_LIB_FN
627  void sincosf(float x, float *s, float *c) { *s = __hc_sincos(x, c); }
628 
629  HCC_MATH_LIB_FN
630  void sincos(__fp16 x, __fp16 *s, __fp16 *c)
631  {
632  *s = __hc_sincos_half(x, c);
633  }
634 
635  HCC_MATH_LIB_FN
636  void sincos(float x, float *s, float *c)
637  {
638  fast_math::sincosf(x, s, c);
639  }
640 
641  HCC_MATH_LIB_FN
642  float sinhf(float x) { return __hc_sinh(x); }
643 
644  HCC_MATH_LIB_FN
645  __fp16 sinh(__fp16 x) { return __hc_sinh_half(x); }
646 
647  HCC_MATH_LIB_FN
648  float sinh(float x) { return fast_math::sinhf(x); }
649 
650  HCC_MATH_LIB_FN
651  float sqrtf(float x) { return __hc_sqrt_native(x); }
652 
653  HCC_MATH_LIB_FN
654  __fp16 sqrt(__fp16 x) { return __hc_sqrt_native_half(x); }
655 
656  HCC_MATH_LIB_FN
657  float sqrt(float x) { return fast_math::sqrtf(x); }
658 
659  HCC_MATH_LIB_FN
660  float tanf(float x) { return __hc_tan(x); }
661 
662  HCC_MATH_LIB_FN
663  __fp16 tan(__fp16 x)
664  {
665  return __hc_sin_native_half(x) *
666  __hc_rcp_native_half(__hc_cos_native_half(x));
667  }
668 
669  HCC_MATH_LIB_FN
670  float tan(float x) { return fast_math::tanf(x); }
671 
672  HCC_MATH_LIB_FN
673  float tanhf(float x) { return __hc_tanh(x); }
674 
675  HCC_MATH_LIB_FN
676  __fp16 tanh(__fp16 x) { return __hc_tanh_half(x); }
677 
678  HCC_MATH_LIB_FN
679  float tanh(float x) { return fast_math::tanhf(x); }
680 
681  HCC_MATH_LIB_FN
682  float truncf(float x) { return __hc_trunc(x); }
683 
684  HCC_MATH_LIB_FN
685  __fp16 trunc(__fp16 x) { return __hc_trunc_half(x); }
686 
687  HCC_MATH_LIB_FN
688  float trunc(float x) { return fast_math::truncf(x); }
689  } // namespace fast_math
690 
691  namespace precise_math
692  {
693  using std::acos;
694  using std::acosh;
695  using ::acoshf;
696  using ::acosf;
697  using std::asin;
698  using std::asinh;
699  using ::asinhf;
700  using ::asinf;
701  using std::atan;
702  using std::atan2;
703  using ::atan2f;
704  using std::atanh;
705  using ::atanhf;
706  using ::atanf;
707  using std::cbrt;
708  using ::cbrtf;
709  using std::ceil;
710  using ::ceilf;
711  using std::copysign;
712  using ::copysignf;
713  using std::cos;
714  using std::cosh;
715  using ::coshf;
716  using ::cosf;
717  using std::erf;
718  using std::erfc;
719  using ::erfcf;
720  using ::erff;
721  using std::exp;
722  using ::exp10;
723  using ::exp10f;
724  using std::exp2;
725  using ::exp2f;
726  using ::expf;
727  using std::expm1;
728  using ::expm1f;
729  using std::fabs;
730  using ::fabsf;
731  using std::fdim;
732  using ::fdimf;
733  using std::floor;
734  using ::floorf;
735  using std::fma;
736  using ::fmaf;
737  using std::fmax;
738  using ::fmaxf;
739  using std::fmin;
740  using ::fminf;
741  using std::fmod;
742  using ::fmodf;
743  using std::frexp;
744  using ::frexpf;
745  using std::hypot;
746  using ::hypotf;
747  using std::ilogb;
748  using ::ilogbf;
749  using std::isfinite;
750  using std::isinf;
751  using std::isnan;
752  using std::isnormal;
753  using std::ldexp;
754  using ::ldexpf;
755  using std::log;
756  using std::log10;
757  using std::log1p;
758  using std::log2;
759  using std::logb;
760  using ::log10f;
761  using ::log1pf;
762  using ::log2f;
763  using ::logbf;
764  using ::logf;
765  using std::modf;
766  using ::modff;
767  using std::nearbyint;
768  using ::nearbyintf;
769  using std::nextafter;
770  using ::nextafterf;
771  using std::pow;
772  using ::powf;
773  using std::remainder;
774  using ::remainderf;
775  using std::remquo;
776  using ::remquof;
777  using std::round;
778  using ::roundf;
779  using std::scalbn;
780  using ::scalbnf;
781  using std::signbit;
782  using std::sin;
783  using std::sinh;
784  using ::sinhf;
785  using ::sinf;
786  using std::sqrt;
787  using ::sqrtf;
788  using std::tan;
789  using std::tanh;
790  using ::tanhf;
791  using ::tanf;
792  using std::tgamma;
793  using ::tgammaf;
794  using std::trunc;
795  using ::truncf;
796 
797  HCC_MATH_LIB_FN
798  float acosf(float x) { return __hc_acos(x); }
799 
800  HCC_MATH_LIB_FN
801  __fp16 acos(__fp16 x) { return __hc_acos_half(x); }
802 
803  HCC_MATH_LIB_FN
804  float acos(float x) { return precise_math::acosf(x); }
805 
806  HCC_MATH_LIB_FN
807  double acos(double x) { return __hc_acos_double(x); }
808 
809  HCC_MATH_LIB_FN
810  float acoshf(float x) { return __hc_acosh(x); }
811 
812  HCC_MATH_LIB_FN
813  __fp16 acosh(__fp16 x) { return __hc_acosh_half(x); }
814 
815  HCC_MATH_LIB_FN
816  float acosh(float x) { return precise_math::acoshf(x); }
817 
818  HCC_MATH_LIB_FN
819  double acosh(double x) { return __hc_acosh_double(x); }
820 
821  HCC_MATH_LIB_FN
822  float asinf(float x) { return __hc_asin(x); }
823 
824  HCC_MATH_LIB_FN
825  __fp16 asin(__fp16 x) { return __hc_asin_half(x); }
826 
827  HCC_MATH_LIB_FN
828  float asin(float x) { return precise_math::asinf(x); }
829 
830  HCC_MATH_LIB_FN
831  double asin(double x) { return __hc_asin_double(x); }
832 
833  HCC_MATH_LIB_FN
834  float asinhf(float x) { return __hc_asinh(x); }
835 
836  HCC_MATH_LIB_FN
837  __fp16 asinh(__fp16 x) { return __hc_asinh_half(x); }
838 
839  HCC_MATH_LIB_FN
840  float asinh(float x) { return precise_math::asinhf(x); }
841 
842  HCC_MATH_LIB_FN
843  double asinh(double x) { return __hc_asinh_double(x); }
844 
845  HCC_MATH_LIB_FN
846  float atanf(float x) { return __hc_atan(x); }
847 
848  HCC_MATH_LIB_FN
849  __fp16 atan(__fp16 x) { return __hc_atan_half(x); }
850 
851  HCC_MATH_LIB_FN
852  float atan(float x) { return precise_math::atanf(x); }
853 
854  HCC_MATH_LIB_FN
855  double atan(double x) { return __hc_atan_double(x); }
856 
857  HCC_MATH_LIB_FN
858  float atanhf(float x) { return __hc_atanh(x); }
859 
860  HCC_MATH_LIB_FN
861  __fp16 atanh(__fp16 x) { return __hc_atanh_half(x); }
862 
863  HCC_MATH_LIB_FN
864  float atanh(float x) { return precise_math::atanhf(x); }
865 
866  HCC_MATH_LIB_FN
867  double atanh(double x) { return __hc_atanh_double(x); }
868 
869  HCC_MATH_LIB_FN
870  float atan2f(float y, float x) { return __hc_atan2(y, x); }
871 
872  HCC_MATH_LIB_FN
873  __fp16 atan2(__fp16 x, __fp16 y) { return __hc_atan2_half(x, y); }
874 
875  HCC_MATH_LIB_FN
876  float atan2(float y, float x) { return precise_math::atan2f(y, x); }
877 
878  HCC_MATH_LIB_FN
879  double atan2(double y, double x) { return __hc_atan2_double(y, x); }
880 
881  HCC_MATH_LIB_FN
882  float cbrtf(float x) { return __hc_cbrt(x); }
883 
884  HCC_MATH_LIB_FN
885  __fp16 cbrt(__fp16 x) { return __hc_cbrt_half(x); }
886 
887  HCC_MATH_LIB_FN
888  float cbrt(float x) { return precise_math::cbrtf(x); }
889 
890  HCC_MATH_LIB_FN
891  double cbrt(double x) { return __hc_cbrt_double(x); }
892 
893  HCC_MATH_LIB_FN
894  float ceilf(float x) { return __hc_ceil(x); }
895 
896  HCC_MATH_LIB_FN
897  __fp16 ceil(__fp16 x) { return __hc_ceil_half(x); }
898 
899  HCC_MATH_LIB_FN
900  float ceil(float x) { return precise_math::ceilf(x); }
901 
902  HCC_MATH_LIB_FN
903  double ceil(double x) { return __hc_ceil_double(x); }
904 
905  HCC_MATH_LIB_FN
906  float copysignf(float x, float y) { return __hc_copysign(x, y); }
907 
908  HCC_MATH_LIB_FN
909  __fp16 copysign(__fp16 x, __fp16 y) { return __hc_copysign_half(x, y); }
910 
911  HCC_MATH_LIB_FN
912  float copysign(float x, float y)
913  {
914  return precise_math::copysignf(x, y);
915  }
916 
917  HCC_MATH_LIB_FN
918  double copysign(double x, double y)
919  {
920  return __hc_copysign_double(x, y);
921  }
922 
923  HCC_MATH_LIB_FN
924  float cosf(float x) { return __hc_cos(x); }
925 
926  HCC_MATH_LIB_FN
927  __fp16 cos(__fp16 x) { return __hc_cos_half(x); }
928 
929  HCC_MATH_LIB_FN
930  float cos(float x) { return precise_math::cosf(x); }
931 
932  HCC_MATH_LIB_FN
933  double cos(double x) { return __hc_cos_double(x); }
934 
935  HCC_MATH_LIB_FN
936  float coshf(float x) { return __hc_cosh(x); }
937 
938  HCC_MATH_LIB_FN
939  __fp16 cosh(__fp16 x) { return __hc_cosh_half(x); }
940 
941  HCC_MATH_LIB_FN
942  float cosh(float x) { return precise_math::coshf(x); }
943 
944  HCC_MATH_LIB_FN
945  double cosh(double x) { return __hc_cosh_double(x); }
946 
947  HCC_MATH_LIB_FN
948  float cospif(float x) { return __hc_cospi(x); }
949 
950  HCC_MATH_LIB_FN
951  __fp16 cospi(__fp16 x) { return __hc_cospi_half(x); }
952 
953  HCC_MATH_LIB_FN
954  float cospi(float x) { return precise_math::cospif(x); }
955 
956  HCC_MATH_LIB_FN
957  double cospi(double x) { return __hc_cospi_double(x); }
958 
959  HCC_MATH_LIB_FN
960  float erff(float x) { return __hc_erf(x); }
961 
962  HCC_MATH_LIB_FN
963  __fp16 erf(__fp16 x) { return __hc_erf_half(x); }
964 
965  HCC_MATH_LIB_FN
966  float erf(float x) { return precise_math::erff(x); }
967 
968  HCC_MATH_LIB_FN
969  double erf(double x) { return __hc_erf_double(x); }
970 
971  HCC_MATH_LIB_FN
972  float erfcf(float x) { return __hc_erfc(x); }
973 
974  HCC_MATH_LIB_FN
975  __fp16 erfc(__fp16 x) { return __hc_erfc_half(x); }
976 
977  HCC_MATH_LIB_FN
978  float erfc(float x) { return precise_math::erfcf(x); }
979 
980  HCC_MATH_LIB_FN
981  double erfc(double x) { return __hc_erfc_double(x); }
982 
983  HCC_MATH_LIB_FN
984  float erfcinvf(float x) { return __hc_erfcinv(x); }
985 
986  HCC_MATH_LIB_FN
987  __fp16 erfcinv(__fp16 x) { return __hc_erfcinv_half(x); }
988 
989  HCC_MATH_LIB_FN
990  float erfcinv(float x) { return precise_math::erfcinvf(x); }
991 
992  HCC_MATH_LIB_FN
993  double erfcinv(double x) { return __hc_erfcinv_double(x); }
994 
995  HCC_MATH_LIB_FN
996  float erfinvf(float x) { return __hc_erfinv(x); }
997 
998  HCC_MATH_LIB_FN
999  __fp16 erfinv(__fp16 x) { return __hc_erfinv_half(x); }
1000 
1001  HCC_MATH_LIB_FN
1002  float erfinv(float x) { return precise_math::erfinvf(x); }
1003 
1004  HCC_MATH_LIB_FN
1005  double erfinv(double x) { return __hc_erfinv_double(x); }
1006 
1007  HCC_MATH_LIB_FN
1008  float expf(float x) { return __hc_exp(x); }
1009 
1010  HCC_MATH_LIB_FN
1011  __fp16 exp(__fp16 x) { return __hc_exp_half(x); }
1012 
1013  HCC_MATH_LIB_FN
1014  float exp(float x) { return precise_math::expf(x); }
1015 
1016  HCC_MATH_LIB_FN
1017  double exp(double x) { return __hc_exp_double(x); }
1018 
1019  HCC_MATH_LIB_FN
1020  float exp2f(float x) { return __hc_exp2(x); }
1021 
1022  HCC_MATH_LIB_FN
1023  __fp16 exp2(__fp16 x) { return __hc_exp2_half(x); }
1024 
1025  HCC_MATH_LIB_FN
1026  float exp2(float x) { return precise_math::exp2f(x); }
1027 
1028  HCC_MATH_LIB_FN
1029  double exp2(double x) { return __hc_exp2_double(x); }
1030 
1031  HCC_MATH_LIB_FN
1032  float exp10f(float x) { return __hc_exp10(x); }
1033 
1034  HCC_MATH_LIB_FN
1035  __fp16 exp10(__fp16 x) { return __hc_exp10_half(x); }
1036 
1037  HCC_MATH_LIB_FN
1038  float exp10(float x) { return precise_math::exp10f(x); }
1039 
1040  HCC_MATH_LIB_FN
1041  double exp10(double x) { return __hc_exp10_double(x); }
1042 
1043  HCC_MATH_LIB_FN
1044  float expm1f(float x) { return __hc_expm1(x); }
1045 
1046  HCC_MATH_LIB_FN
1047  __fp16 expm1(__fp16 x) { return __hc_expm1_half(x); }
1048 
1049  HCC_MATH_LIB_FN
1050  float expm1(float x) { return precise_math::expm1f(x); }
1051 
1052  HCC_MATH_LIB_FN
1053  double expm1(double x) { return __hc_expm1_double(x); }
1054 
1055  HCC_MATH_LIB_FN
1056  float fabsf(float x) { return __hc_fabs(x); }
1057 
1058  HCC_MATH_LIB_FN
1059  __fp16 fabs(__fp16 x) { return __hc_fabs_half(x); }
1060 
1061  HCC_MATH_LIB_FN
1062  float fabs(float x) { return precise_math::fabsf(x); }
1063 
1064  HCC_MATH_LIB_FN
1065  double fabs(double x) { return __hc_fabs_double(x); }
1066 
1067  HCC_MATH_LIB_FN
1068  float fdimf(float x, float y) { return __hc_fdim(x, y); }
1069 
1070  HCC_MATH_LIB_FN
1071  __fp16 fdim(__fp16 x, __fp16 y) { return __hc_fdim_half(x, y); }
1072 
1073  HCC_MATH_LIB_FN
1074  float fdim(float x, float y) { return precise_math::fdimf(x, y); }
1075 
1076  HCC_MATH_LIB_FN
1077  double fdim(double x, double y) { return __hc_fdim_double(x, y); }
1078 
1079  HCC_MATH_LIB_FN
1080  float floorf(float x) { return __hc_floor(x); }
1081 
1082  HCC_MATH_LIB_FN
1083  __fp16 floor(__fp16 x) { return __hc_floor_half(x); }
1084 
1085  HCC_MATH_LIB_FN
1086  float floor(float x) { return precise_math::floorf(x); }
1087 
1088  HCC_MATH_LIB_FN
1089  double floor(double x) { return __hc_floor_double(x); }
1090 
1091  HCC_MATH_LIB_FN
1092  float fmaf(float x, float y, float z) { return __hc_fma(x, y, z); }
1093 
1094  HCC_MATH_LIB_FN
1095  __fp16 fma(__fp16 x, __fp16 y, __fp16 z)
1096  {
1097  return __hc_fma_half(x, y, z);
1098  }
1099 
1100  HCC_MATH_LIB_FN
1101  float fma(float x, float y, float z)
1102  {
1103  return precise_math::fmaf(x, y, z);
1104  }
1105 
1106  HCC_MATH_LIB_FN
1107  double fma(double x, double y, double z)
1108  {
1109  return __hc_fma_double(x, y, z);
1110  }
1111 
1112  HCC_MATH_LIB_FN
1113  float fmaxf(float x, float y) { return __hc_fmax(x, y); }
1114 
1115  HCC_MATH_LIB_FN
1116  __fp16 fmax(__fp16 x, __fp16 y) { return __hc_fmax_half(x, y); }
1117 
1118  HCC_MATH_LIB_FN
1119  float fmax(float x, float y) { return precise_math::fmaxf(x, y); }
1120 
1121  HCC_MATH_LIB_FN
1122  double fmax(double x, double y) { return __hc_fmax_double(x, y); }
1123 
1124  HCC_MATH_LIB_FN
1125  float fminf(float x, float y) { return __hc_fmin(x, y); }
1126 
1127  HCC_MATH_LIB_FN
1128  __fp16 fmin(__fp16 x, __fp16 y) { return __hc_fmin_half(x, y); }
1129 
1130  HCC_MATH_LIB_FN
1131  float fmin(float x, float y) { return precise_math::fminf(x, y); }
1132 
1133  HCC_MATH_LIB_FN
1134  double fmin(double x, double y) { return __hc_fmin_double(x, y); }
1135 
1136  HCC_MATH_LIB_FN
1137  float fmodf(float x, float y) { return __hc_fmod(x, y); }
1138 
1139  HCC_MATH_LIB_FN
1140  __fp16 fmod(__fp16 x, __fp16 y) { return __hc_fmod_half(x, y); }
1141 
1142  HCC_MATH_LIB_FN
1143  float fmod(float x, float y) { return precise_math::fmodf(x, y); }
1144 
1145  HCC_MATH_LIB_FN
1146  double fmod(double x, double y) { return __hc_fmod_double(x, y); }
1147 
1148  HCC_MATH_LIB_FN
1149  int fpclassify(__fp16 x) { return __hc_fpclassify_half(x); }
1150 
1151  HCC_MATH_LIB_FN
1152  int fpclassify(float x) { return __hc_fpclassify(x); }
1153 
1154  HCC_MATH_LIB_FN
1155  int fpclassify(double x) { return __hc_fpclassify_double(x); }
1156 
1157  HCC_MATH_LIB_FN
1158  float frexpf(float x, int *exp) { return __hc_frexp(x, exp); }
1159 
1160  HCC_MATH_LIB_FN
1161  __fp16 frexp(__fp16 x, int* exp) { return __hc_frexp_half(x, exp); }
1162 
1163  HCC_MATH_LIB_FN
1164  float frexp(float x, int *exp) { return precise_math::frexpf(x, exp); }
1165 
1166  HCC_MATH_LIB_FN
1167  double frexp(double x, int *exp) { return __hc_frexp_double(x, exp); }
1168 
1169  HCC_MATH_LIB_FN
1170  float hypotf(float x, float y) { return __hc_hypot(x, y); }
1171 
1172  HCC_MATH_LIB_FN
1173  __fp16 hypot(__fp16 x, __fp16 y) { return __hc_hypot_half(x, y); }
1174 
1175  HCC_MATH_LIB_FN
1176  float hypot(float x, float y) { return precise_math::hypotf(x, y); }
1177 
1178  HCC_MATH_LIB_FN
1179  double hypot(double x, double y) { return __hc_hypot_double(x, y); }
1180 
1181  HCC_MATH_LIB_FN
1182  int ilogbf(float x) { return __hc_ilogb(x); }
1183 
1184  HCC_MATH_LIB_FN
1185  int ilogb(__fp16 x) { return __hc_ilogb_half(x); }
1186 
1187  HCC_MATH_LIB_FN
1188  int ilogb(float x) { return precise_math::ilogbf(x); }
1189 
1190  HCC_MATH_LIB_FN
1191  int ilogb(double x) { return __hc_ilogb_double(x); }
1192 
1193  HCC_MATH_LIB_FN
1194  int isfinite(__fp16 x) { return __hc_isfinite_half(x); }
1195 
1196  HCC_MATH_LIB_FN
1197  int isfinite(float x) { return __hc_isfinite(x); }
1198 
1199  HCC_MATH_LIB_FN
1200  int isfinite(double x) { return __hc_isfinite_double(x); }
1201 
1202  HCC_MATH_LIB_FN
1203  int isinf(__fp16 x) { return __hc_isinf_half(x); }
1204 
1205  HCC_MATH_LIB_FN
1206  int isinf(float x) { return __hc_isinf(x); }
1207 
1208  HCC_MATH_LIB_FN
1209  int isinf(double x) { return __hc_isinf_double(x); }
1210 
1211  HCC_MATH_LIB_FN
1212  int isnan(__fp16 x) { return __hc_isnan_half(x); }
1213 
1214  HCC_MATH_LIB_FN
1215  int isnan(float x) { return __hc_isnan(x); }
1216 
1217  HCC_MATH_LIB_FN
1218  int isnan(double x) { return __hc_isnan_double(x); }
1219 
1220  HCC_MATH_LIB_FN
1221  int isnormal(__fp16 x) { return __hc_isnormal_half(x); }
1222 
1223  HCC_MATH_LIB_FN
1224  int isnormal(float x) { return __hc_isnormal(x); }
1225 
1226  HCC_MATH_LIB_FN
1227  int isnormal(double x) { return __hc_isnormal_double(x); }
1228 
1229  HCC_MATH_LIB_FN
1230  float ldexpf(float x, int exp) { return __hc_ldexp(x, exp); }
1231 
1232  HCC_MATH_LIB_FN
1233  __fp16 ldexp(__fp16 x, std::int16_t e) { return __hc_ldexp_half(x, e); }
1234 
1235  HCC_MATH_LIB_FN
1236  float ldexp(float x, int exp) { return precise_math::ldexpf(x, exp); }
1237 
1238  HCC_MATH_LIB_FN
1239  double ldexp(double x, int exp) { return __hc_ldexp_double(x,exp); }
1240 
1241  HCC_MATH_LIB_FN
1242  float lgammaf(float x) { return __hc_lgamma(x); }
1243 
1244  HCC_MATH_LIB_FN
1245  __fp16 lgamma(__fp16 x) { return __hc_lgamma_half(x); }
1246 
1247  HCC_MATH_LIB_FN
1248  float lgamma(float x) { return precise_math::lgammaf(x); }
1249 
1250  HCC_MATH_LIB_FN
1251  double lgamma(double x) { return __hc_lgamma_double(x); }
1252 
1253  HCC_MATH_LIB_FN
1254  float logf(float x) { return __hc_log(x); }
1255 
1256  HCC_MATH_LIB_FN
1257  __fp16 log(__fp16 x) { return __hc_log_half(x); }
1258 
1259  HCC_MATH_LIB_FN
1260  float log(float x) { return precise_math::logf(x); }
1261 
1262  HCC_MATH_LIB_FN
1263  double log(double x) { return __hc_log_double(x); }
1264 
1265  HCC_MATH_LIB_FN
1266  float log10f(float x) { return __hc_log10(x); }
1267 
1268  HCC_MATH_LIB_FN
1269  __fp16 log10(__fp16 x) { return __hc_log10_half(x); }
1270 
1271  HCC_MATH_LIB_FN
1272  float log10(float x) { return precise_math::log10f(x); }
1273 
1274  HCC_MATH_LIB_FN
1275  double log10(double x) { return __hc_log10_double(x); }
1276 
1277  HCC_MATH_LIB_FN
1278  float log2f(float x) { return __hc_log2(x); }
1279 
1280  HCC_MATH_LIB_FN
1281  __fp16 log2(__fp16 x) { return __hc_log2_half(x); }
1282 
1283  HCC_MATH_LIB_FN
1284  float log2(float x) { return precise_math::log2f(x); }
1285 
1286  HCC_MATH_LIB_FN
1287  double log2(double x) { return __hc_log2_double(x); }
1288 
1289  HCC_MATH_LIB_FN
1290  float log1pf(float x) { return __hc_log1p(x); }
1291 
1292  HCC_MATH_LIB_FN
1293  __fp16 log1p(__fp16 x) { return __hc_log1p_half(x); }
1294 
1295  HCC_MATH_LIB_FN
1296  float log1p(float x) { return precise_math::log1pf(x); }
1297 
1298  HCC_MATH_LIB_FN
1299  double log1p(double x) { return __hc_log1p(x); }
1300 
1301  HCC_MATH_LIB_FN
1302  float logbf(float x) { return __hc_logb(x); }
1303 
1304  HCC_MATH_LIB_FN
1305  __fp16 logb(__fp16 x) { return __hc_logb_half(x); }
1306 
1307  HCC_MATH_LIB_FN
1308  float logb(float x) { return precise_math::logbf(x); }
1309 
1310  HCC_MATH_LIB_FN
1311  double logb(double x) { return __hc_logb_double(x); }
1312 
1313  HCC_MATH_LIB_FN
1314  float modff(float x, float *iptr) { return __hc_modf(x, iptr); }
1315 
1316  HCC_MATH_LIB_FN
1317  __fp16 modf(__fp16 x, __fp16* p) { return __hc_modf_half(x, p); }
1318 
1319  HCC_MATH_LIB_FN
1320  float modf(float x, float* p) { return precise_math::modff(x, p); }
1321 
1322  HCC_MATH_LIB_FN
1323  double modf(double x, double* p) { return __hc_modf_double(x, p); }
1324 
1325  HCC_MATH_LIB_FN
1326  __fp16 nanh(int x) { return __hc_nan_half(x); }
1327 
1328  HCC_MATH_LIB_FN
1329  float nanf(int tagp) { return __hc_nan(tagp); }
1330 
1331  HCC_MATH_LIB_FN
1332  double nan(int tagp)
1333  {
1334  return __hc_nan_double(static_cast<unsigned long>(tagp));
1335  }
1336 
1337  HCC_MATH_LIB_FN
1338  float nearbyintf(float x) { return __hc_nearbyint(x); }
1339 
1340  HCC_MATH_LIB_FN
1341  __fp16 nearbyint(__fp16 x) { return __hc_nearbyint_half(x); }
1342 
1343  HCC_MATH_LIB_FN
1344  float nearbyint(float x) { return precise_math::nearbyintf(x); }
1345 
1346  HCC_MATH_LIB_FN
1347  double nearbyint(double x) { return __hc_nearbyint_double(x); }
1348 
1349  HCC_MATH_LIB_FN
1350  float nextafterf(float x, float y) { return __hc_nextafter(x, y); }
1351 
1352  HCC_MATH_LIB_FN
1353  __fp16 nextafter(__fp16 x, __fp16 y)
1354  {
1355  return __hc_nextafter_half(x, y);
1356  }
1357 
1358  HCC_MATH_LIB_FN
1359  float nextafter(float x, float y)
1360  {
1361  return precise_math::nextafterf(x, y);
1362  }
1363 
1364  HCC_MATH_LIB_FN
1365  double nextafter(double x, double y)
1366  {
1367  return __hc_nextafter_double(x, y);
1368  }
1369 
1370  HCC_MATH_LIB_FN
1371  float powf(float x, float y) { return __hc_pow(x, y); }
1372 
1373  HCC_MATH_LIB_FN
1374  __fp16 pow(__fp16 x, __fp16 y) { return __hc_pow_half(x, y); }
1375 
1376  HCC_MATH_LIB_FN
1377  float pow(float x, float y) { return precise_math::powf(x, y); }
1378 
1379  HCC_MATH_LIB_FN
1380  double pow(double x, double y) { return __hc_pow_double(x, y); }
1381 
1382  HCC_MATH_LIB_FN
1383  float rcbrtf(float x) { return __hc_rcbrt(x); }
1384 
1385  HCC_MATH_LIB_FN
1386  __fp16 rcbrt(__fp16 x) { return __hc_rcbrt_half(x); }
1387 
1388  HCC_MATH_LIB_FN
1389  float rcbrt(float x) { return precise_math::rcbrtf(x); }
1390 
1391  HCC_MATH_LIB_FN
1392  double rcbrt(double x) { return __hc_rcbrt_double(x); }
1393 
1394  HCC_MATH_LIB_FN
1395  float remainderf(float x, float y) { return __hc_remainder(x, y); }
1396 
1397  HCC_MATH_LIB_FN
1398  __fp16 remainder(__fp16 x, __fp16 y)
1399  {
1400  return __hc_remainder_half(x, y);
1401  }
1402 
1403  HCC_MATH_LIB_FN
1404  float remainder(float x, float y)
1405  {
1406  return precise_math::remainderf(x, y);
1407  }
1408 
1409  HCC_MATH_LIB_FN
1410  double remainder(double x, double y)
1411  {
1412  return __hc_remainder_double(x, y);
1413  }
1414 
1415  HCC_MATH_LIB_FN
1416  float remquof(float x, float y, int *quo)
1417  {
1418  return __hc_remquo(x, y, quo);
1419  }
1420 
1421  HCC_MATH_LIB_FN
1422  __fp16 remquo(__fp16 x, __fp16 y, int* q)
1423  {
1424  return __hc_remquo_half(x, y, q);
1425  }
1426 
1427  HCC_MATH_LIB_FN
1428  float remquo(float x, float y, int *quo)
1429  {
1430  return precise_math::remquof(x, y, quo);
1431  }
1432 
1433  HCC_MATH_LIB_FN
1434  double remquo(double x, double y, int *quo)
1435  {
1436  return __hc_remquo_double(x, y, quo);
1437  }
1438 
1439  HCC_MATH_LIB_FN
1440  float roundf(float x) { return __hc_round(x); }
1441 
1442  HCC_MATH_LIB_FN
1443  __fp16 round(__fp16 x) { return __hc_round_half(x); }
1444 
1445  HCC_MATH_LIB_FN
1446  float round(float x) { return precise_math::roundf(x); }
1447 
1448  HCC_MATH_LIB_FN
1449  double round(double x) { return __hc_round_double(x); }
1450 
1451  HCC_MATH_LIB_FN
1452  float rsqrtf(float x) { return __hc_rsqrt(x); }
1453 
1454  HCC_MATH_LIB_FN
1455  __fp16 rsqrt(__fp16 x) { return __hc_rsqrt_half(x); }
1456 
1457  HCC_MATH_LIB_FN
1458  float rsqrt(float x) { return precise_math::rsqrtf(x); }
1459 
1460  HCC_MATH_LIB_FN
1461  double rsqrt(double x) { return __hc_rsqrt_double(x); }
1462 
1463  HCC_MATH_LIB_FN
1464  float sinpif(float x) { return __hc_sinpi(x); }
1465 
1466  HCC_MATH_LIB_FN
1467  __fp16 sinpi(__fp16 x) { return __hc_sinpi_half(x); }
1468 
1469  HCC_MATH_LIB_FN
1470  float sinpi(float x) { return precise_math::sinpif(x); }
1471 
1472  HCC_MATH_LIB_FN
1473  double sinpi(double x) { return __hc_sinpi_double(x); }
1474 
1475  HCC_MATH_LIB_FN
1476  float scalbf(float x, float exp) { return __hc_scalb(x, exp); }
1477 
1478  HCC_MATH_LIB_FN
1479  __fp16 scalb(__fp16 x, __fp16 y) { return __hc_scalb_half(x, y); }
1480 
1481  HCC_MATH_LIB_FN
1482  float scalb(float x, float exp) { return precise_math::scalbf(x, exp); }
1483 
1484  HCC_MATH_LIB_FN
1485  double scalb(double x, double exp) { return __hc_scalb_double(x, exp); }
1486 
1487  HCC_MATH_LIB_FN
1488  float scalbnf(float x, int exp) { return __hc_scalbn(x, exp); }
1489 
1490  HCC_MATH_LIB_FN
1491  __fp16 scalbn(__fp16 x, int e) { return __hc_scalbn_half(x, e); }
1492 
1493  HCC_MATH_LIB_FN
1494  float scalbn(float x, int exp) { return precise_math::scalbnf(x, exp); }
1495 
1496  HCC_MATH_LIB_FN
1497  double scalbn(double x, int exp) { return __hc_scalbn_double(x, exp); }
1498 
1499  HCC_MATH_LIB_FN
1500  int signbitf(float x) { return __hc_signbit(x); }
1501 
1502  HCC_MATH_LIB_FN
1503  int signbit(__fp16 x) { return __hc_signbit_half(x); }
1504 
1505  HCC_MATH_LIB_FN
1506  int signbit(float x) { return precise_math::signbitf(x); }
1507 
1508  HCC_MATH_LIB_FN
1509  int signbit(double x) { return __hc_signbit_double(x); }
1510 
1511  HCC_MATH_LIB_FN
1512  float sinf(float x) { return __hc_sin(x); }
1513 
1514  HCC_MATH_LIB_FN
1515  __fp16 sin(__fp16 x) { return __hc_sin_half(x); }
1516 
1517  HCC_MATH_LIB_FN
1518  float sin(float x) { return precise_math::sinf(x); }
1519 
1520  HCC_MATH_LIB_FN
1521  double sin(double x) { return __hc_sin_double(x); }
1522 
1523  HCC_MATH_LIB_FN
1524  void sincosf(float x, float *s, float *c) { *s = __hc_sincos(x, c); }
1525 
1526  HCC_MATH_LIB_FN
1527  void sincos(__fp16 x, __fp16* s, __fp16* c)
1528  {
1529  *s = __hc_sincos_half(x, c);
1530  }
1531 
1532  HCC_MATH_LIB_FN
1533  void sincos(float x, float *s, float *c)
1534  {
1535  precise_math::sincosf(x, s, c);
1536  }
1537 
1538  HCC_MATH_LIB_FN
1539  void sincos(double x, double *s, double *c)
1540  {
1541  *s = __hc_sincos_double(x, c);
1542  }
1543 
1544  HCC_MATH_LIB_FN
1545  float sinhf(float x) { return __hc_sinh(x); }
1546 
1547  HCC_MATH_LIB_FN
1548  __fp16 sinh(__fp16 x) { return __hc_sinh_half(x); }
1549 
1550  HCC_MATH_LIB_FN
1551  float sinh(float x) { return precise_math::sinhf(x); }
1552 
1553  HCC_MATH_LIB_FN
1554  double sinh(double x) { return __hc_sinh_double(x); }
1555 
1556  HCC_MATH_LIB_FN
1557  float sqrtf(float x) { return __hc_sqrt(x); }
1558 
1559  HCC_MATH_LIB_FN
1560  __fp16 sqrt(__fp16 x) { return __hc_sqrt_half(x); }
1561 
1562  HCC_MATH_LIB_FN
1563  float sqrt(float x) { return precise_math::sqrtf(x); }
1564 
1565  HCC_MATH_LIB_FN
1566  double sqrt(double x) { return __hc_sqrt_double(x); }
1567 
1568  HCC_MATH_LIB_FN
1569  float tgammaf(float x) { return __hc_tgamma(x); }
1570 
1571  HCC_MATH_LIB_FN
1572  __fp16 tgamma(__fp16 x) { return __hc_tgamma_half(x); }
1573 
1574  HCC_MATH_LIB_FN
1575  float tgamma(float x) { return precise_math::tgammaf(x); }
1576 
1577  HCC_MATH_LIB_FN
1578  double tgamma(double x) { return __hc_tgamma_double(x); }
1579 
1580  HCC_MATH_LIB_FN
1581  float tanf(float x) { return __hc_tan(x); }
1582 
1583  HCC_MATH_LIB_FN
1584  __fp16 tan(__fp16 x) { return __hc_tan_half(x); }
1585 
1586  HCC_MATH_LIB_FN
1587  float tan(float x) { return precise_math::tanf(x); }
1588 
1589  HCC_MATH_LIB_FN
1590  double tan(double x) { return __hc_tan_double(x); }
1591 
1592  HCC_MATH_LIB_FN
1593  float tanhf(float x) { return __hc_tanh(x); }
1594 
1595  HCC_MATH_LIB_FN
1596  __fp16 tanh(__fp16 x) { return __hc_tanh_half(x); }
1597 
1598  HCC_MATH_LIB_FN
1599  float tanh(float x) { return precise_math::tanhf(x); }
1600 
1601  HCC_MATH_LIB_FN
1602  double tanh(double x) { return __hc_tanh(x); }
1603 
1604  HCC_MATH_LIB_FN
1605  float tanpif(float x) { return __hc_tanpi(x); }
1606 
1607  HCC_MATH_LIB_FN
1608  __fp16 tanpi(__fp16 x) { return __hc_tanpi_half(x); }
1609 
1610  HCC_MATH_LIB_FN
1611  float tanpi(float x) { return precise_math::tanpif(x); }
1612 
1613  HCC_MATH_LIB_FN
1614  double tanpi(double x) { return __hc_tanpi_double(x); }
1615 
1616  HCC_MATH_LIB_FN
1617  float truncf(float x) { return __hc_trunc(x); }
1618 
1619  HCC_MATH_LIB_FN
1620  __fp16 trunc(__fp16 x) { return __hc_trunc_half(x); }
1621 
1622  HCC_MATH_LIB_FN
1623  float trunc(float x) { return precise_math::truncf(x); }
1624 
1625  HCC_MATH_LIB_FN
1626  double trunc(double x) { return __hc_trunc_double(x); }
1627  } // namespace precise_math
1628 } // namespace Kalmar
namespace for internal classes of Kalmar compiler / runtime
Definition: hc.hpp:42
Definition: kalmar_math.h:691
Heterogeneous C++ (HC) namespace.
Definition: grid_launch.h:10
Definition: kalmar_math.h:297