1ec727ea7Spatrick /*===---- __clang_cuda_math.h - Device-side CUDA math support --------------===
2ec727ea7Spatrick  *
3ec727ea7Spatrick  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4ec727ea7Spatrick  * See https://llvm.org/LICENSE.txt for license information.
5ec727ea7Spatrick  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6ec727ea7Spatrick  *
7ec727ea7Spatrick  *===-----------------------------------------------------------------------===
8ec727ea7Spatrick  */
9ec727ea7Spatrick #ifndef __CLANG_CUDA_MATH_H__
10ec727ea7Spatrick #define __CLANG_CUDA_MATH_H__
11ec727ea7Spatrick #ifndef __CUDA__
12ec727ea7Spatrick #error "This file is for CUDA compilation only."
13ec727ea7Spatrick #endif
14ec727ea7Spatrick 
15ec727ea7Spatrick #ifndef __OPENMP_NVPTX__
16ec727ea7Spatrick #if CUDA_VERSION < 9000
17ec727ea7Spatrick #error This file is intended to be used with CUDA-9+ only.
18ec727ea7Spatrick #endif
19ec727ea7Spatrick #endif
20ec727ea7Spatrick 
21ec727ea7Spatrick // __DEVICE__ is a helper macro with common set of attributes for the wrappers
22ec727ea7Spatrick // we implement in this file. We need static in order to avoid emitting unused
23ec727ea7Spatrick // functions and __forceinline__ helps inlining these wrappers at -O1.
24ec727ea7Spatrick #pragma push_macro("__DEVICE__")
25ec727ea7Spatrick #ifdef __OPENMP_NVPTX__
26ec727ea7Spatrick #if defined(__cplusplus)
27ec727ea7Spatrick #define __DEVICE__ static constexpr __attribute__((always_inline, nothrow))
28ec727ea7Spatrick #else
29ec727ea7Spatrick #define __DEVICE__ static __attribute__((always_inline, nothrow))
30ec727ea7Spatrick #endif
31ec727ea7Spatrick #else
32ec727ea7Spatrick #define __DEVICE__ static __device__ __forceinline__
33ec727ea7Spatrick #endif
34ec727ea7Spatrick 
35ec727ea7Spatrick // Specialized version of __DEVICE__ for functions with void return type. Needed
36ec727ea7Spatrick // because the OpenMP overlay requires constexpr functions here but prior to
37ec727ea7Spatrick // c++14 void return functions could not be constexpr.
38ec727ea7Spatrick #pragma push_macro("__DEVICE_VOID__")
39ec727ea7Spatrick #ifdef __OPENMP_NVPTX__ && defined(__cplusplus) && __cplusplus < 201402L
40ec727ea7Spatrick #define __DEVICE_VOID__ static __attribute__((always_inline, nothrow))
41ec727ea7Spatrick #else
42ec727ea7Spatrick #define __DEVICE_VOID__ __DEVICE__
43ec727ea7Spatrick #endif
44ec727ea7Spatrick 
45ec727ea7Spatrick // libdevice provides fast low precision and slow full-recision implementations
46ec727ea7Spatrick // for some functions. Which one gets selected depends on
47ec727ea7Spatrick // __CLANG_CUDA_APPROX_TRANSCENDENTALS__ which gets defined by clang if
48ec727ea7Spatrick // -ffast-math or -fcuda-approx-transcendentals are in effect.
49ec727ea7Spatrick #pragma push_macro("__FAST_OR_SLOW")
50ec727ea7Spatrick #if defined(__CLANG_CUDA_APPROX_TRANSCENDENTALS__)
51ec727ea7Spatrick #define __FAST_OR_SLOW(fast, slow) fast
52ec727ea7Spatrick #else
53ec727ea7Spatrick #define __FAST_OR_SLOW(fast, slow) slow
54ec727ea7Spatrick #endif
55ec727ea7Spatrick 
abs(int __a)56ec727ea7Spatrick __DEVICE__ int abs(int __a) { return __nv_abs(__a); }
fabs(double __a)57ec727ea7Spatrick __DEVICE__ double fabs(double __a) { return __nv_fabs(__a); }
acos(double __a)58ec727ea7Spatrick __DEVICE__ double acos(double __a) { return __nv_acos(__a); }
acosf(float __a)59ec727ea7Spatrick __DEVICE__ float acosf(float __a) { return __nv_acosf(__a); }
acosh(double __a)60ec727ea7Spatrick __DEVICE__ double acosh(double __a) { return __nv_acosh(__a); }
acoshf(float __a)61ec727ea7Spatrick __DEVICE__ float acoshf(float __a) { return __nv_acoshf(__a); }
asin(double __a)62ec727ea7Spatrick __DEVICE__ double asin(double __a) { return __nv_asin(__a); }
asinf(float __a)63ec727ea7Spatrick __DEVICE__ float asinf(float __a) { return __nv_asinf(__a); }
asinh(double __a)64ec727ea7Spatrick __DEVICE__ double asinh(double __a) { return __nv_asinh(__a); }
asinhf(float __a)65ec727ea7Spatrick __DEVICE__ float asinhf(float __a) { return __nv_asinhf(__a); }
atan(double __a)66ec727ea7Spatrick __DEVICE__ double atan(double __a) { return __nv_atan(__a); }
atan2(double __a,double __b)67ec727ea7Spatrick __DEVICE__ double atan2(double __a, double __b) { return __nv_atan2(__a, __b); }
atan2f(float __a,float __b)68ec727ea7Spatrick __DEVICE__ float atan2f(float __a, float __b) { return __nv_atan2f(__a, __b); }
atanf(float __a)69ec727ea7Spatrick __DEVICE__ float atanf(float __a) { return __nv_atanf(__a); }
atanh(double __a)70ec727ea7Spatrick __DEVICE__ double atanh(double __a) { return __nv_atanh(__a); }
atanhf(float __a)71ec727ea7Spatrick __DEVICE__ float atanhf(float __a) { return __nv_atanhf(__a); }
cbrt(double __a)72ec727ea7Spatrick __DEVICE__ double cbrt(double __a) { return __nv_cbrt(__a); }
cbrtf(float __a)73ec727ea7Spatrick __DEVICE__ float cbrtf(float __a) { return __nv_cbrtf(__a); }
ceil(double __a)74ec727ea7Spatrick __DEVICE__ double ceil(double __a) { return __nv_ceil(__a); }
ceilf(float __a)75ec727ea7Spatrick __DEVICE__ float ceilf(float __a) { return __nv_ceilf(__a); }
copysign(double __a,double __b)76ec727ea7Spatrick __DEVICE__ double copysign(double __a, double __b) {
77ec727ea7Spatrick   return __nv_copysign(__a, __b);
78ec727ea7Spatrick }
copysignf(float __a,float __b)79ec727ea7Spatrick __DEVICE__ float copysignf(float __a, float __b) {
80ec727ea7Spatrick   return __nv_copysignf(__a, __b);
81ec727ea7Spatrick }
cos(double __a)82ec727ea7Spatrick __DEVICE__ double cos(double __a) { return __nv_cos(__a); }
cosf(float __a)83ec727ea7Spatrick __DEVICE__ float cosf(float __a) {
84ec727ea7Spatrick   return __FAST_OR_SLOW(__nv_fast_cosf, __nv_cosf)(__a);
85ec727ea7Spatrick }
cosh(double __a)86ec727ea7Spatrick __DEVICE__ double cosh(double __a) { return __nv_cosh(__a); }
coshf(float __a)87ec727ea7Spatrick __DEVICE__ float coshf(float __a) { return __nv_coshf(__a); }
cospi(double __a)88ec727ea7Spatrick __DEVICE__ double cospi(double __a) { return __nv_cospi(__a); }
cospif(float __a)89ec727ea7Spatrick __DEVICE__ float cospif(float __a) { return __nv_cospif(__a); }
cyl_bessel_i0(double __a)90ec727ea7Spatrick __DEVICE__ double cyl_bessel_i0(double __a) { return __nv_cyl_bessel_i0(__a); }
cyl_bessel_i0f(float __a)91ec727ea7Spatrick __DEVICE__ float cyl_bessel_i0f(float __a) { return __nv_cyl_bessel_i0f(__a); }
cyl_bessel_i1(double __a)92ec727ea7Spatrick __DEVICE__ double cyl_bessel_i1(double __a) { return __nv_cyl_bessel_i1(__a); }
cyl_bessel_i1f(float __a)93ec727ea7Spatrick __DEVICE__ float cyl_bessel_i1f(float __a) { return __nv_cyl_bessel_i1f(__a); }
erf(double __a)94ec727ea7Spatrick __DEVICE__ double erf(double __a) { return __nv_erf(__a); }
erfc(double __a)95ec727ea7Spatrick __DEVICE__ double erfc(double __a) { return __nv_erfc(__a); }
erfcf(float __a)96ec727ea7Spatrick __DEVICE__ float erfcf(float __a) { return __nv_erfcf(__a); }
erfcinv(double __a)97ec727ea7Spatrick __DEVICE__ double erfcinv(double __a) { return __nv_erfcinv(__a); }
erfcinvf(float __a)98ec727ea7Spatrick __DEVICE__ float erfcinvf(float __a) { return __nv_erfcinvf(__a); }
erfcx(double __a)99ec727ea7Spatrick __DEVICE__ double erfcx(double __a) { return __nv_erfcx(__a); }
erfcxf(float __a)100ec727ea7Spatrick __DEVICE__ float erfcxf(float __a) { return __nv_erfcxf(__a); }
erff(float __a)101ec727ea7Spatrick __DEVICE__ float erff(float __a) { return __nv_erff(__a); }
erfinv(double __a)102ec727ea7Spatrick __DEVICE__ double erfinv(double __a) { return __nv_erfinv(__a); }
erfinvf(float __a)103ec727ea7Spatrick __DEVICE__ float erfinvf(float __a) { return __nv_erfinvf(__a); }
exp(double __a)104ec727ea7Spatrick __DEVICE__ double exp(double __a) { return __nv_exp(__a); }
exp10(double __a)105ec727ea7Spatrick __DEVICE__ double exp10(double __a) { return __nv_exp10(__a); }
exp10f(float __a)106ec727ea7Spatrick __DEVICE__ float exp10f(float __a) { return __nv_exp10f(__a); }
exp2(double __a)107ec727ea7Spatrick __DEVICE__ double exp2(double __a) { return __nv_exp2(__a); }
exp2f(float __a)108ec727ea7Spatrick __DEVICE__ float exp2f(float __a) { return __nv_exp2f(__a); }
expf(float __a)109ec727ea7Spatrick __DEVICE__ float expf(float __a) { return __nv_expf(__a); }
expm1(double __a)110ec727ea7Spatrick __DEVICE__ double expm1(double __a) { return __nv_expm1(__a); }
expm1f(float __a)111ec727ea7Spatrick __DEVICE__ float expm1f(float __a) { return __nv_expm1f(__a); }
fabsf(float __a)112ec727ea7Spatrick __DEVICE__ float fabsf(float __a) { return __nv_fabsf(__a); }
fdim(double __a,double __b)113ec727ea7Spatrick __DEVICE__ double fdim(double __a, double __b) { return __nv_fdim(__a, __b); }
fdimf(float __a,float __b)114ec727ea7Spatrick __DEVICE__ float fdimf(float __a, float __b) { return __nv_fdimf(__a, __b); }
fdivide(double __a,double __b)115ec727ea7Spatrick __DEVICE__ double fdivide(double __a, double __b) { return __a / __b; }
fdividef(float __a,float __b)116ec727ea7Spatrick __DEVICE__ float fdividef(float __a, float __b) {
117ec727ea7Spatrick #if __FAST_MATH__ && !__CUDA_PREC_DIV
118ec727ea7Spatrick   return __nv_fast_fdividef(__a, __b);
119ec727ea7Spatrick #else
120ec727ea7Spatrick   return __a / __b;
121ec727ea7Spatrick #endif
122ec727ea7Spatrick }
floor(double __f)123ec727ea7Spatrick __DEVICE__ double floor(double __f) { return __nv_floor(__f); }
floorf(float __f)124ec727ea7Spatrick __DEVICE__ float floorf(float __f) { return __nv_floorf(__f); }
fma(double __a,double __b,double __c)125ec727ea7Spatrick __DEVICE__ double fma(double __a, double __b, double __c) {
126ec727ea7Spatrick   return __nv_fma(__a, __b, __c);
127ec727ea7Spatrick }
fmaf(float __a,float __b,float __c)128ec727ea7Spatrick __DEVICE__ float fmaf(float __a, float __b, float __c) {
129ec727ea7Spatrick   return __nv_fmaf(__a, __b, __c);
130ec727ea7Spatrick }
fmax(double __a,double __b)131ec727ea7Spatrick __DEVICE__ double fmax(double __a, double __b) { return __nv_fmax(__a, __b); }
fmaxf(float __a,float __b)132ec727ea7Spatrick __DEVICE__ float fmaxf(float __a, float __b) { return __nv_fmaxf(__a, __b); }
fmin(double __a,double __b)133ec727ea7Spatrick __DEVICE__ double fmin(double __a, double __b) { return __nv_fmin(__a, __b); }
fminf(float __a,float __b)134ec727ea7Spatrick __DEVICE__ float fminf(float __a, float __b) { return __nv_fminf(__a, __b); }
fmod(double __a,double __b)135ec727ea7Spatrick __DEVICE__ double fmod(double __a, double __b) { return __nv_fmod(__a, __b); }
fmodf(float __a,float __b)136ec727ea7Spatrick __DEVICE__ float fmodf(float __a, float __b) { return __nv_fmodf(__a, __b); }
frexp(double __a,int * __b)137ec727ea7Spatrick __DEVICE__ double frexp(double __a, int *__b) { return __nv_frexp(__a, __b); }
frexpf(float __a,int * __b)138ec727ea7Spatrick __DEVICE__ float frexpf(float __a, int *__b) { return __nv_frexpf(__a, __b); }
hypot(double __a,double __b)139ec727ea7Spatrick __DEVICE__ double hypot(double __a, double __b) { return __nv_hypot(__a, __b); }
hypotf(float __a,float __b)140ec727ea7Spatrick __DEVICE__ float hypotf(float __a, float __b) { return __nv_hypotf(__a, __b); }
ilogb(double __a)141ec727ea7Spatrick __DEVICE__ int ilogb(double __a) { return __nv_ilogb(__a); }
ilogbf(float __a)142ec727ea7Spatrick __DEVICE__ int ilogbf(float __a) { return __nv_ilogbf(__a); }
j0(double __a)143ec727ea7Spatrick __DEVICE__ double j0(double __a) { return __nv_j0(__a); }
j0f(float __a)144ec727ea7Spatrick __DEVICE__ float j0f(float __a) { return __nv_j0f(__a); }
j1(double __a)145ec727ea7Spatrick __DEVICE__ double j1(double __a) { return __nv_j1(__a); }
j1f(float __a)146ec727ea7Spatrick __DEVICE__ float j1f(float __a) { return __nv_j1f(__a); }
jn(int __n,double __a)147ec727ea7Spatrick __DEVICE__ double jn(int __n, double __a) { return __nv_jn(__n, __a); }
jnf(int __n,float __a)148ec727ea7Spatrick __DEVICE__ float jnf(int __n, float __a) { return __nv_jnf(__n, __a); }
149ec727ea7Spatrick #if defined(__LP64__) || defined(_WIN64)
labs(long __a)150ec727ea7Spatrick __DEVICE__ long labs(long __a) { return __nv_llabs(__a); };
151ec727ea7Spatrick #else
labs(long __a)152ec727ea7Spatrick __DEVICE__ long labs(long __a) { return __nv_abs(__a); };
153ec727ea7Spatrick #endif
ldexp(double __a,int __b)154ec727ea7Spatrick __DEVICE__ double ldexp(double __a, int __b) { return __nv_ldexp(__a, __b); }
ldexpf(float __a,int __b)155ec727ea7Spatrick __DEVICE__ float ldexpf(float __a, int __b) { return __nv_ldexpf(__a, __b); }
lgamma(double __a)156ec727ea7Spatrick __DEVICE__ double lgamma(double __a) { return __nv_lgamma(__a); }
lgammaf(float __a)157ec727ea7Spatrick __DEVICE__ float lgammaf(float __a) { return __nv_lgammaf(__a); }
llabs(long long __a)158ec727ea7Spatrick __DEVICE__ long long llabs(long long __a) { return __nv_llabs(__a); }
llmax(long long __a,long long __b)159ec727ea7Spatrick __DEVICE__ long long llmax(long long __a, long long __b) {
160ec727ea7Spatrick   return __nv_llmax(__a, __b);
161ec727ea7Spatrick }
llmin(long long __a,long long __b)162ec727ea7Spatrick __DEVICE__ long long llmin(long long __a, long long __b) {
163ec727ea7Spatrick   return __nv_llmin(__a, __b);
164ec727ea7Spatrick }
llrint(double __a)165ec727ea7Spatrick __DEVICE__ long long llrint(double __a) { return __nv_llrint(__a); }
llrintf(float __a)166ec727ea7Spatrick __DEVICE__ long long llrintf(float __a) { return __nv_llrintf(__a); }
llround(double __a)167ec727ea7Spatrick __DEVICE__ long long llround(double __a) { return __nv_llround(__a); }
llroundf(float __a)168ec727ea7Spatrick __DEVICE__ long long llroundf(float __a) { return __nv_llroundf(__a); }
round(double __a)169a9ac8606Spatrick __DEVICE__ double round(double __a) { return __nv_round(__a); }
roundf(float __a)170a9ac8606Spatrick __DEVICE__ float roundf(float __a) { return __nv_roundf(__a); }
log(double __a)171ec727ea7Spatrick __DEVICE__ double log(double __a) { return __nv_log(__a); }
log10(double __a)172ec727ea7Spatrick __DEVICE__ double log10(double __a) { return __nv_log10(__a); }
log10f(float __a)173ec727ea7Spatrick __DEVICE__ float log10f(float __a) { return __nv_log10f(__a); }
log1p(double __a)174ec727ea7Spatrick __DEVICE__ double log1p(double __a) { return __nv_log1p(__a); }
log1pf(float __a)175ec727ea7Spatrick __DEVICE__ float log1pf(float __a) { return __nv_log1pf(__a); }
log2(double __a)176ec727ea7Spatrick __DEVICE__ double log2(double __a) { return __nv_log2(__a); }
log2f(float __a)177ec727ea7Spatrick __DEVICE__ float log2f(float __a) {
178ec727ea7Spatrick   return __FAST_OR_SLOW(__nv_fast_log2f, __nv_log2f)(__a);
179ec727ea7Spatrick }
logb(double __a)180ec727ea7Spatrick __DEVICE__ double logb(double __a) { return __nv_logb(__a); }
logbf(float __a)181ec727ea7Spatrick __DEVICE__ float logbf(float __a) { return __nv_logbf(__a); }
logf(float __a)182ec727ea7Spatrick __DEVICE__ float logf(float __a) {
183ec727ea7Spatrick   return __FAST_OR_SLOW(__nv_fast_logf, __nv_logf)(__a);
184ec727ea7Spatrick }
185ec727ea7Spatrick #if defined(__LP64__) || defined(_WIN64)
lrint(double __a)186ec727ea7Spatrick __DEVICE__ long lrint(double __a) { return llrint(__a); }
lrintf(float __a)187ec727ea7Spatrick __DEVICE__ long lrintf(float __a) { return __float2ll_rn(__a); }
lround(double __a)188ec727ea7Spatrick __DEVICE__ long lround(double __a) { return llround(__a); }
lroundf(float __a)189ec727ea7Spatrick __DEVICE__ long lroundf(float __a) { return llroundf(__a); }
190ec727ea7Spatrick #else
lrint(double __a)191ec727ea7Spatrick __DEVICE__ long lrint(double __a) { return (long)rint(__a); }
lrintf(float __a)192ec727ea7Spatrick __DEVICE__ long lrintf(float __a) { return __float2int_rn(__a); }
lround(double __a)193ec727ea7Spatrick __DEVICE__ long lround(double __a) { return round(__a); }
lroundf(float __a)194ec727ea7Spatrick __DEVICE__ long lroundf(float __a) { return roundf(__a); }
195ec727ea7Spatrick #endif
max(int __a,int __b)196ec727ea7Spatrick __DEVICE__ int max(int __a, int __b) { return __nv_max(__a, __b); }
min(int __a,int __b)197ec727ea7Spatrick __DEVICE__ int min(int __a, int __b) { return __nv_min(__a, __b); }
modf(double __a,double * __b)198ec727ea7Spatrick __DEVICE__ double modf(double __a, double *__b) { return __nv_modf(__a, __b); }
modff(float __a,float * __b)199ec727ea7Spatrick __DEVICE__ float modff(float __a, float *__b) { return __nv_modff(__a, __b); }
nearbyint(double __a)200a9ac8606Spatrick __DEVICE__ double nearbyint(double __a) { return __builtin_nearbyint(__a); }
nearbyintf(float __a)201a9ac8606Spatrick __DEVICE__ float nearbyintf(float __a) { return __builtin_nearbyintf(__a); }
nextafter(double __a,double __b)202ec727ea7Spatrick __DEVICE__ double nextafter(double __a, double __b) {
203ec727ea7Spatrick   return __nv_nextafter(__a, __b);
204ec727ea7Spatrick }
nextafterf(float __a,float __b)205ec727ea7Spatrick __DEVICE__ float nextafterf(float __a, float __b) {
206ec727ea7Spatrick   return __nv_nextafterf(__a, __b);
207ec727ea7Spatrick }
norm(int __dim,const double * __t)208ec727ea7Spatrick __DEVICE__ double norm(int __dim, const double *__t) {
209ec727ea7Spatrick   return __nv_norm(__dim, __t);
210ec727ea7Spatrick }
norm3d(double __a,double __b,double __c)211ec727ea7Spatrick __DEVICE__ double norm3d(double __a, double __b, double __c) {
212ec727ea7Spatrick   return __nv_norm3d(__a, __b, __c);
213ec727ea7Spatrick }
norm3df(float __a,float __b,float __c)214ec727ea7Spatrick __DEVICE__ float norm3df(float __a, float __b, float __c) {
215ec727ea7Spatrick   return __nv_norm3df(__a, __b, __c);
216ec727ea7Spatrick }
norm4d(double __a,double __b,double __c,double __d)217ec727ea7Spatrick __DEVICE__ double norm4d(double __a, double __b, double __c, double __d) {
218ec727ea7Spatrick   return __nv_norm4d(__a, __b, __c, __d);
219ec727ea7Spatrick }
norm4df(float __a,float __b,float __c,float __d)220ec727ea7Spatrick __DEVICE__ float norm4df(float __a, float __b, float __c, float __d) {
221ec727ea7Spatrick   return __nv_norm4df(__a, __b, __c, __d);
222ec727ea7Spatrick }
normcdf(double __a)223ec727ea7Spatrick __DEVICE__ double normcdf(double __a) { return __nv_normcdf(__a); }
normcdff(float __a)224ec727ea7Spatrick __DEVICE__ float normcdff(float __a) { return __nv_normcdff(__a); }
normcdfinv(double __a)225ec727ea7Spatrick __DEVICE__ double normcdfinv(double __a) { return __nv_normcdfinv(__a); }
normcdfinvf(float __a)226ec727ea7Spatrick __DEVICE__ float normcdfinvf(float __a) { return __nv_normcdfinvf(__a); }
normf(int __dim,const float * __t)227ec727ea7Spatrick __DEVICE__ float normf(int __dim, const float *__t) {
228ec727ea7Spatrick   return __nv_normf(__dim, __t);
229ec727ea7Spatrick }
pow(double __a,double __b)230ec727ea7Spatrick __DEVICE__ double pow(double __a, double __b) { return __nv_pow(__a, __b); }
powf(float __a,float __b)231ec727ea7Spatrick __DEVICE__ float powf(float __a, float __b) { return __nv_powf(__a, __b); }
powi(double __a,int __b)232ec727ea7Spatrick __DEVICE__ double powi(double __a, int __b) { return __nv_powi(__a, __b); }
powif(float __a,int __b)233ec727ea7Spatrick __DEVICE__ float powif(float __a, int __b) { return __nv_powif(__a, __b); }
rcbrt(double __a)234ec727ea7Spatrick __DEVICE__ double rcbrt(double __a) { return __nv_rcbrt(__a); }
rcbrtf(float __a)235ec727ea7Spatrick __DEVICE__ float rcbrtf(float __a) { return __nv_rcbrtf(__a); }
remainder(double __a,double __b)236ec727ea7Spatrick __DEVICE__ double remainder(double __a, double __b) {
237ec727ea7Spatrick   return __nv_remainder(__a, __b);
238ec727ea7Spatrick }
remainderf(float __a,float __b)239ec727ea7Spatrick __DEVICE__ float remainderf(float __a, float __b) {
240ec727ea7Spatrick   return __nv_remainderf(__a, __b);
241ec727ea7Spatrick }
remquo(double __a,double __b,int * __c)242ec727ea7Spatrick __DEVICE__ double remquo(double __a, double __b, int *__c) {
243ec727ea7Spatrick   return __nv_remquo(__a, __b, __c);
244ec727ea7Spatrick }
remquof(float __a,float __b,int * __c)245ec727ea7Spatrick __DEVICE__ float remquof(float __a, float __b, int *__c) {
246ec727ea7Spatrick   return __nv_remquof(__a, __b, __c);
247ec727ea7Spatrick }
rhypot(double __a,double __b)248ec727ea7Spatrick __DEVICE__ double rhypot(double __a, double __b) {
249ec727ea7Spatrick   return __nv_rhypot(__a, __b);
250ec727ea7Spatrick }
rhypotf(float __a,float __b)251ec727ea7Spatrick __DEVICE__ float rhypotf(float __a, float __b) {
252ec727ea7Spatrick   return __nv_rhypotf(__a, __b);
253ec727ea7Spatrick }
254a9ac8606Spatrick // __nv_rint* in libdevice is buggy and produces incorrect results.
rint(double __a)255a9ac8606Spatrick __DEVICE__ double rint(double __a) { return __builtin_rint(__a); }
rintf(float __a)256a9ac8606Spatrick __DEVICE__ float rintf(float __a) { return __builtin_rintf(__a); }
rnorm(int __a,const double * __b)257ec727ea7Spatrick __DEVICE__ double rnorm(int __a, const double *__b) {
258ec727ea7Spatrick   return __nv_rnorm(__a, __b);
259ec727ea7Spatrick }
rnorm3d(double __a,double __b,double __c)260ec727ea7Spatrick __DEVICE__ double rnorm3d(double __a, double __b, double __c) {
261ec727ea7Spatrick   return __nv_rnorm3d(__a, __b, __c);
262ec727ea7Spatrick }
rnorm3df(float __a,float __b,float __c)263ec727ea7Spatrick __DEVICE__ float rnorm3df(float __a, float __b, float __c) {
264ec727ea7Spatrick   return __nv_rnorm3df(__a, __b, __c);
265ec727ea7Spatrick }
rnorm4d(double __a,double __b,double __c,double __d)266ec727ea7Spatrick __DEVICE__ double rnorm4d(double __a, double __b, double __c, double __d) {
267ec727ea7Spatrick   return __nv_rnorm4d(__a, __b, __c, __d);
268ec727ea7Spatrick }
rnorm4df(float __a,float __b,float __c,float __d)269ec727ea7Spatrick __DEVICE__ float rnorm4df(float __a, float __b, float __c, float __d) {
270ec727ea7Spatrick   return __nv_rnorm4df(__a, __b, __c, __d);
271ec727ea7Spatrick }
rnormf(int __dim,const float * __t)272ec727ea7Spatrick __DEVICE__ float rnormf(int __dim, const float *__t) {
273ec727ea7Spatrick   return __nv_rnormf(__dim, __t);
274ec727ea7Spatrick }
rsqrt(double __a)275ec727ea7Spatrick __DEVICE__ double rsqrt(double __a) { return __nv_rsqrt(__a); }
rsqrtf(float __a)276ec727ea7Spatrick __DEVICE__ float rsqrtf(float __a) { return __nv_rsqrtf(__a); }
scalbn(double __a,int __b)277ec727ea7Spatrick __DEVICE__ double scalbn(double __a, int __b) { return __nv_scalbn(__a, __b); }
scalbnf(float __a,int __b)278ec727ea7Spatrick __DEVICE__ float scalbnf(float __a, int __b) { return __nv_scalbnf(__a, __b); }
scalbln(double __a,long __b)279ec727ea7Spatrick __DEVICE__ double scalbln(double __a, long __b) {
280ec727ea7Spatrick   if (__b > INT_MAX)
281ec727ea7Spatrick     return __a > 0 ? HUGE_VAL : -HUGE_VAL;
282ec727ea7Spatrick   if (__b < INT_MIN)
283ec727ea7Spatrick     return __a > 0 ? 0.0 : -0.0;
284ec727ea7Spatrick   return scalbn(__a, (int)__b);
285ec727ea7Spatrick }
scalblnf(float __a,long __b)286ec727ea7Spatrick __DEVICE__ float scalblnf(float __a, long __b) {
287ec727ea7Spatrick   if (__b > INT_MAX)
288ec727ea7Spatrick     return __a > 0 ? HUGE_VALF : -HUGE_VALF;
289ec727ea7Spatrick   if (__b < INT_MIN)
290ec727ea7Spatrick     return __a > 0 ? 0.f : -0.f;
291ec727ea7Spatrick   return scalbnf(__a, (int)__b);
292ec727ea7Spatrick }
sin(double __a)293ec727ea7Spatrick __DEVICE__ double sin(double __a) { return __nv_sin(__a); }
sincos(double __a,double * __s,double * __c)294ec727ea7Spatrick __DEVICE_VOID__ void sincos(double __a, double *__s, double *__c) {
295ec727ea7Spatrick   return __nv_sincos(__a, __s, __c);
296ec727ea7Spatrick }
sincosf(float __a,float * __s,float * __c)297ec727ea7Spatrick __DEVICE_VOID__ void sincosf(float __a, float *__s, float *__c) {
298ec727ea7Spatrick   return __FAST_OR_SLOW(__nv_fast_sincosf, __nv_sincosf)(__a, __s, __c);
299ec727ea7Spatrick }
sincospi(double __a,double * __s,double * __c)300ec727ea7Spatrick __DEVICE_VOID__ void sincospi(double __a, double *__s, double *__c) {
301ec727ea7Spatrick   return __nv_sincospi(__a, __s, __c);
302ec727ea7Spatrick }
sincospif(float __a,float * __s,float * __c)303ec727ea7Spatrick __DEVICE_VOID__ void sincospif(float __a, float *__s, float *__c) {
304ec727ea7Spatrick   return __nv_sincospif(__a, __s, __c);
305ec727ea7Spatrick }
sinf(float __a)306ec727ea7Spatrick __DEVICE__ float sinf(float __a) {
307ec727ea7Spatrick   return __FAST_OR_SLOW(__nv_fast_sinf, __nv_sinf)(__a);
308ec727ea7Spatrick }
sinh(double __a)309ec727ea7Spatrick __DEVICE__ double sinh(double __a) { return __nv_sinh(__a); }
sinhf(float __a)310ec727ea7Spatrick __DEVICE__ float sinhf(float __a) { return __nv_sinhf(__a); }
sinpi(double __a)311ec727ea7Spatrick __DEVICE__ double sinpi(double __a) { return __nv_sinpi(__a); }
sinpif(float __a)312ec727ea7Spatrick __DEVICE__ float sinpif(float __a) { return __nv_sinpif(__a); }
sqrt(double __a)313ec727ea7Spatrick __DEVICE__ double sqrt(double __a) { return __nv_sqrt(__a); }
sqrtf(float __a)314ec727ea7Spatrick __DEVICE__ float sqrtf(float __a) { return __nv_sqrtf(__a); }
tan(double __a)315ec727ea7Spatrick __DEVICE__ double tan(double __a) { return __nv_tan(__a); }
tanf(float __a)316ec727ea7Spatrick __DEVICE__ float tanf(float __a) { return __nv_tanf(__a); }
tanh(double __a)317ec727ea7Spatrick __DEVICE__ double tanh(double __a) { return __nv_tanh(__a); }
tanhf(float __a)318ec727ea7Spatrick __DEVICE__ float tanhf(float __a) { return __nv_tanhf(__a); }
tgamma(double __a)319ec727ea7Spatrick __DEVICE__ double tgamma(double __a) { return __nv_tgamma(__a); }
tgammaf(float __a)320ec727ea7Spatrick __DEVICE__ float tgammaf(float __a) { return __nv_tgammaf(__a); }
trunc(double __a)321ec727ea7Spatrick __DEVICE__ double trunc(double __a) { return __nv_trunc(__a); }
truncf(float __a)322ec727ea7Spatrick __DEVICE__ float truncf(float __a) { return __nv_truncf(__a); }
ullmax(unsigned long long __a,unsigned long long __b)323ec727ea7Spatrick __DEVICE__ unsigned long long ullmax(unsigned long long __a,
324ec727ea7Spatrick                                      unsigned long long __b) {
325ec727ea7Spatrick   return __nv_ullmax(__a, __b);
326ec727ea7Spatrick }
ullmin(unsigned long long __a,unsigned long long __b)327ec727ea7Spatrick __DEVICE__ unsigned long long ullmin(unsigned long long __a,
328ec727ea7Spatrick                                      unsigned long long __b) {
329ec727ea7Spatrick   return __nv_ullmin(__a, __b);
330ec727ea7Spatrick }
umax(unsigned int __a,unsigned int __b)331ec727ea7Spatrick __DEVICE__ unsigned int umax(unsigned int __a, unsigned int __b) {
332ec727ea7Spatrick   return __nv_umax(__a, __b);
333ec727ea7Spatrick }
umin(unsigned int __a,unsigned int __b)334ec727ea7Spatrick __DEVICE__ unsigned int umin(unsigned int __a, unsigned int __b) {
335ec727ea7Spatrick   return __nv_umin(__a, __b);
336ec727ea7Spatrick }
y0(double __a)337ec727ea7Spatrick __DEVICE__ double y0(double __a) { return __nv_y0(__a); }
y0f(float __a)338ec727ea7Spatrick __DEVICE__ float y0f(float __a) { return __nv_y0f(__a); }
y1(double __a)339ec727ea7Spatrick __DEVICE__ double y1(double __a) { return __nv_y1(__a); }
y1f(float __a)340ec727ea7Spatrick __DEVICE__ float y1f(float __a) { return __nv_y1f(__a); }
yn(int __a,double __b)341ec727ea7Spatrick __DEVICE__ double yn(int __a, double __b) { return __nv_yn(__a, __b); }
ynf(int __a,float __b)342ec727ea7Spatrick __DEVICE__ float ynf(int __a, float __b) { return __nv_ynf(__a, __b); }
343ec727ea7Spatrick 
344ec727ea7Spatrick #pragma pop_macro("__DEVICE__")
345ec727ea7Spatrick #pragma pop_macro("__DEVICE_VOID__")
346ec727ea7Spatrick #pragma pop_macro("__FAST_OR_SLOW")
347ec727ea7Spatrick 
348*12c85518Srobert #endif // __CLANG_CUDA_MATH_H__
349