15ffd83dbSDimitry Andric /*===---- __clang_cuda_math.h - Device-side CUDA math support --------------=== 25ffd83dbSDimitry Andric * 35ffd83dbSDimitry Andric * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 45ffd83dbSDimitry Andric * See https://llvm.org/LICENSE.txt for license information. 55ffd83dbSDimitry Andric * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 65ffd83dbSDimitry Andric * 75ffd83dbSDimitry Andric *===-----------------------------------------------------------------------=== 85ffd83dbSDimitry Andric */ 95ffd83dbSDimitry Andric #ifndef __CLANG_CUDA_MATH_H__ 105ffd83dbSDimitry Andric #define __CLANG_CUDA_MATH_H__ 115ffd83dbSDimitry Andric #ifndef __CUDA__ 125ffd83dbSDimitry Andric #error "This file is for CUDA compilation only." 135ffd83dbSDimitry Andric #endif 145ffd83dbSDimitry Andric 155ffd83dbSDimitry Andric #ifndef __OPENMP_NVPTX__ 165ffd83dbSDimitry Andric #if CUDA_VERSION < 9000 175ffd83dbSDimitry Andric #error This file is intended to be used with CUDA-9+ only. 185ffd83dbSDimitry Andric #endif 195ffd83dbSDimitry Andric #endif 205ffd83dbSDimitry Andric 215ffd83dbSDimitry Andric // __DEVICE__ is a helper macro with common set of attributes for the wrappers 225ffd83dbSDimitry Andric // we implement in this file. We need static in order to avoid emitting unused 235ffd83dbSDimitry Andric // functions and __forceinline__ helps inlining these wrappers at -O1. 245ffd83dbSDimitry Andric #pragma push_macro("__DEVICE__") 255ffd83dbSDimitry Andric #ifdef __OPENMP_NVPTX__ 265ffd83dbSDimitry Andric #if defined(__cplusplus) 275ffd83dbSDimitry Andric #define __DEVICE__ static constexpr __attribute__((always_inline, nothrow)) 285ffd83dbSDimitry Andric #else 295ffd83dbSDimitry Andric #define __DEVICE__ static __attribute__((always_inline, nothrow)) 305ffd83dbSDimitry Andric #endif 315ffd83dbSDimitry Andric #else 325ffd83dbSDimitry Andric #define __DEVICE__ static __device__ __forceinline__ 335ffd83dbSDimitry Andric #endif 345ffd83dbSDimitry Andric 355ffd83dbSDimitry Andric // Specialized version of __DEVICE__ for functions with void return type. Needed 365ffd83dbSDimitry Andric // because the OpenMP overlay requires constexpr functions here but prior to 375ffd83dbSDimitry Andric // c++14 void return functions could not be constexpr. 385ffd83dbSDimitry Andric #pragma push_macro("__DEVICE_VOID__") 398a4dda33SDimitry Andric #if defined(__OPENMP_NVPTX__) && defined(__cplusplus) && __cplusplus < 201402L 405ffd83dbSDimitry Andric #define __DEVICE_VOID__ static __attribute__((always_inline, nothrow)) 415ffd83dbSDimitry Andric #else 425ffd83dbSDimitry Andric #define __DEVICE_VOID__ __DEVICE__ 435ffd83dbSDimitry Andric #endif 445ffd83dbSDimitry Andric 455ffd83dbSDimitry Andric // libdevice provides fast low precision and slow full-recision implementations 465ffd83dbSDimitry Andric // for some functions. Which one gets selected depends on 475ffd83dbSDimitry Andric // __CLANG_CUDA_APPROX_TRANSCENDENTALS__ which gets defined by clang if 48*5f757f3fSDimitry Andric // -ffast-math or -fgpu-approx-transcendentals are in effect. 495ffd83dbSDimitry Andric #pragma push_macro("__FAST_OR_SLOW") 50*5f757f3fSDimitry Andric #if defined(__CLANG_GPU_APPROX_TRANSCENDENTALS__) 515ffd83dbSDimitry Andric #define __FAST_OR_SLOW(fast, slow) fast 525ffd83dbSDimitry Andric #else 535ffd83dbSDimitry Andric #define __FAST_OR_SLOW(fast, slow) slow 545ffd83dbSDimitry Andric #endif 555ffd83dbSDimitry Andric 565ffd83dbSDimitry Andric __DEVICE__ int abs(int __a) { return __nv_abs(__a); } 575ffd83dbSDimitry Andric __DEVICE__ double fabs(double __a) { return __nv_fabs(__a); } 585ffd83dbSDimitry Andric __DEVICE__ double acos(double __a) { return __nv_acos(__a); } 595ffd83dbSDimitry Andric __DEVICE__ float acosf(float __a) { return __nv_acosf(__a); } 605ffd83dbSDimitry Andric __DEVICE__ double acosh(double __a) { return __nv_acosh(__a); } 615ffd83dbSDimitry Andric __DEVICE__ float acoshf(float __a) { return __nv_acoshf(__a); } 625ffd83dbSDimitry Andric __DEVICE__ double asin(double __a) { return __nv_asin(__a); } 635ffd83dbSDimitry Andric __DEVICE__ float asinf(float __a) { return __nv_asinf(__a); } 645ffd83dbSDimitry Andric __DEVICE__ double asinh(double __a) { return __nv_asinh(__a); } 655ffd83dbSDimitry Andric __DEVICE__ float asinhf(float __a) { return __nv_asinhf(__a); } 665ffd83dbSDimitry Andric __DEVICE__ double atan(double __a) { return __nv_atan(__a); } 675ffd83dbSDimitry Andric __DEVICE__ double atan2(double __a, double __b) { return __nv_atan2(__a, __b); } 685ffd83dbSDimitry Andric __DEVICE__ float atan2f(float __a, float __b) { return __nv_atan2f(__a, __b); } 695ffd83dbSDimitry Andric __DEVICE__ float atanf(float __a) { return __nv_atanf(__a); } 705ffd83dbSDimitry Andric __DEVICE__ double atanh(double __a) { return __nv_atanh(__a); } 715ffd83dbSDimitry Andric __DEVICE__ float atanhf(float __a) { return __nv_atanhf(__a); } 725ffd83dbSDimitry Andric __DEVICE__ double cbrt(double __a) { return __nv_cbrt(__a); } 735ffd83dbSDimitry Andric __DEVICE__ float cbrtf(float __a) { return __nv_cbrtf(__a); } 745ffd83dbSDimitry Andric __DEVICE__ double ceil(double __a) { return __nv_ceil(__a); } 755ffd83dbSDimitry Andric __DEVICE__ float ceilf(float __a) { return __nv_ceilf(__a); } 765ffd83dbSDimitry Andric __DEVICE__ double copysign(double __a, double __b) { 775ffd83dbSDimitry Andric return __nv_copysign(__a, __b); 785ffd83dbSDimitry Andric } 795ffd83dbSDimitry Andric __DEVICE__ float copysignf(float __a, float __b) { 805ffd83dbSDimitry Andric return __nv_copysignf(__a, __b); 815ffd83dbSDimitry Andric } 825ffd83dbSDimitry Andric __DEVICE__ double cos(double __a) { return __nv_cos(__a); } 835ffd83dbSDimitry Andric __DEVICE__ float cosf(float __a) { 845ffd83dbSDimitry Andric return __FAST_OR_SLOW(__nv_fast_cosf, __nv_cosf)(__a); 855ffd83dbSDimitry Andric } 865ffd83dbSDimitry Andric __DEVICE__ double cosh(double __a) { return __nv_cosh(__a); } 875ffd83dbSDimitry Andric __DEVICE__ float coshf(float __a) { return __nv_coshf(__a); } 885ffd83dbSDimitry Andric __DEVICE__ double cospi(double __a) { return __nv_cospi(__a); } 895ffd83dbSDimitry Andric __DEVICE__ float cospif(float __a) { return __nv_cospif(__a); } 905ffd83dbSDimitry Andric __DEVICE__ double cyl_bessel_i0(double __a) { return __nv_cyl_bessel_i0(__a); } 915ffd83dbSDimitry Andric __DEVICE__ float cyl_bessel_i0f(float __a) { return __nv_cyl_bessel_i0f(__a); } 925ffd83dbSDimitry Andric __DEVICE__ double cyl_bessel_i1(double __a) { return __nv_cyl_bessel_i1(__a); } 935ffd83dbSDimitry Andric __DEVICE__ float cyl_bessel_i1f(float __a) { return __nv_cyl_bessel_i1f(__a); } 945ffd83dbSDimitry Andric __DEVICE__ double erf(double __a) { return __nv_erf(__a); } 955ffd83dbSDimitry Andric __DEVICE__ double erfc(double __a) { return __nv_erfc(__a); } 965ffd83dbSDimitry Andric __DEVICE__ float erfcf(float __a) { return __nv_erfcf(__a); } 975ffd83dbSDimitry Andric __DEVICE__ double erfcinv(double __a) { return __nv_erfcinv(__a); } 985ffd83dbSDimitry Andric __DEVICE__ float erfcinvf(float __a) { return __nv_erfcinvf(__a); } 995ffd83dbSDimitry Andric __DEVICE__ double erfcx(double __a) { return __nv_erfcx(__a); } 1005ffd83dbSDimitry Andric __DEVICE__ float erfcxf(float __a) { return __nv_erfcxf(__a); } 1015ffd83dbSDimitry Andric __DEVICE__ float erff(float __a) { return __nv_erff(__a); } 1025ffd83dbSDimitry Andric __DEVICE__ double erfinv(double __a) { return __nv_erfinv(__a); } 1035ffd83dbSDimitry Andric __DEVICE__ float erfinvf(float __a) { return __nv_erfinvf(__a); } 1045ffd83dbSDimitry Andric __DEVICE__ double exp(double __a) { return __nv_exp(__a); } 1055ffd83dbSDimitry Andric __DEVICE__ double exp10(double __a) { return __nv_exp10(__a); } 1065ffd83dbSDimitry Andric __DEVICE__ float exp10f(float __a) { return __nv_exp10f(__a); } 1075ffd83dbSDimitry Andric __DEVICE__ double exp2(double __a) { return __nv_exp2(__a); } 1085ffd83dbSDimitry Andric __DEVICE__ float exp2f(float __a) { return __nv_exp2f(__a); } 1095ffd83dbSDimitry Andric __DEVICE__ float expf(float __a) { return __nv_expf(__a); } 1105ffd83dbSDimitry Andric __DEVICE__ double expm1(double __a) { return __nv_expm1(__a); } 1115ffd83dbSDimitry Andric __DEVICE__ float expm1f(float __a) { return __nv_expm1f(__a); } 1125ffd83dbSDimitry Andric __DEVICE__ float fabsf(float __a) { return __nv_fabsf(__a); } 1135ffd83dbSDimitry Andric __DEVICE__ double fdim(double __a, double __b) { return __nv_fdim(__a, __b); } 1145ffd83dbSDimitry Andric __DEVICE__ float fdimf(float __a, float __b) { return __nv_fdimf(__a, __b); } 1155ffd83dbSDimitry Andric __DEVICE__ double fdivide(double __a, double __b) { return __a / __b; } 1165ffd83dbSDimitry Andric __DEVICE__ float fdividef(float __a, float __b) { 1175ffd83dbSDimitry Andric #if __FAST_MATH__ && !__CUDA_PREC_DIV 1185ffd83dbSDimitry Andric return __nv_fast_fdividef(__a, __b); 1195ffd83dbSDimitry Andric #else 1205ffd83dbSDimitry Andric return __a / __b; 1215ffd83dbSDimitry Andric #endif 1225ffd83dbSDimitry Andric } 1235ffd83dbSDimitry Andric __DEVICE__ double floor(double __f) { return __nv_floor(__f); } 1245ffd83dbSDimitry Andric __DEVICE__ float floorf(float __f) { return __nv_floorf(__f); } 1255ffd83dbSDimitry Andric __DEVICE__ double fma(double __a, double __b, double __c) { 1265ffd83dbSDimitry Andric return __nv_fma(__a, __b, __c); 1275ffd83dbSDimitry Andric } 1285ffd83dbSDimitry Andric __DEVICE__ float fmaf(float __a, float __b, float __c) { 1295ffd83dbSDimitry Andric return __nv_fmaf(__a, __b, __c); 1305ffd83dbSDimitry Andric } 1315ffd83dbSDimitry Andric __DEVICE__ double fmax(double __a, double __b) { return __nv_fmax(__a, __b); } 1325ffd83dbSDimitry Andric __DEVICE__ float fmaxf(float __a, float __b) { return __nv_fmaxf(__a, __b); } 1335ffd83dbSDimitry Andric __DEVICE__ double fmin(double __a, double __b) { return __nv_fmin(__a, __b); } 1345ffd83dbSDimitry Andric __DEVICE__ float fminf(float __a, float __b) { return __nv_fminf(__a, __b); } 1355ffd83dbSDimitry Andric __DEVICE__ double fmod(double __a, double __b) { return __nv_fmod(__a, __b); } 1365ffd83dbSDimitry Andric __DEVICE__ float fmodf(float __a, float __b) { return __nv_fmodf(__a, __b); } 1375ffd83dbSDimitry Andric __DEVICE__ double frexp(double __a, int *__b) { return __nv_frexp(__a, __b); } 1385ffd83dbSDimitry Andric __DEVICE__ float frexpf(float __a, int *__b) { return __nv_frexpf(__a, __b); } 1395ffd83dbSDimitry Andric __DEVICE__ double hypot(double __a, double __b) { return __nv_hypot(__a, __b); } 1405ffd83dbSDimitry Andric __DEVICE__ float hypotf(float __a, float __b) { return __nv_hypotf(__a, __b); } 1415ffd83dbSDimitry Andric __DEVICE__ int ilogb(double __a) { return __nv_ilogb(__a); } 1425ffd83dbSDimitry Andric __DEVICE__ int ilogbf(float __a) { return __nv_ilogbf(__a); } 1435ffd83dbSDimitry Andric __DEVICE__ double j0(double __a) { return __nv_j0(__a); } 1445ffd83dbSDimitry Andric __DEVICE__ float j0f(float __a) { return __nv_j0f(__a); } 1455ffd83dbSDimitry Andric __DEVICE__ double j1(double __a) { return __nv_j1(__a); } 1465ffd83dbSDimitry Andric __DEVICE__ float j1f(float __a) { return __nv_j1f(__a); } 1475ffd83dbSDimitry Andric __DEVICE__ double jn(int __n, double __a) { return __nv_jn(__n, __a); } 1485ffd83dbSDimitry Andric __DEVICE__ float jnf(int __n, float __a) { return __nv_jnf(__n, __a); } 1495ffd83dbSDimitry Andric #if defined(__LP64__) || defined(_WIN64) 1505ffd83dbSDimitry Andric __DEVICE__ long labs(long __a) { return __nv_llabs(__a); }; 1515ffd83dbSDimitry Andric #else 1525ffd83dbSDimitry Andric __DEVICE__ long labs(long __a) { return __nv_abs(__a); }; 1535ffd83dbSDimitry Andric #endif 1545ffd83dbSDimitry Andric __DEVICE__ double ldexp(double __a, int __b) { return __nv_ldexp(__a, __b); } 1555ffd83dbSDimitry Andric __DEVICE__ float ldexpf(float __a, int __b) { return __nv_ldexpf(__a, __b); } 1565ffd83dbSDimitry Andric __DEVICE__ double lgamma(double __a) { return __nv_lgamma(__a); } 1575ffd83dbSDimitry Andric __DEVICE__ float lgammaf(float __a) { return __nv_lgammaf(__a); } 1585ffd83dbSDimitry Andric __DEVICE__ long long llabs(long long __a) { return __nv_llabs(__a); } 1595ffd83dbSDimitry Andric __DEVICE__ long long llmax(long long __a, long long __b) { 1605ffd83dbSDimitry Andric return __nv_llmax(__a, __b); 1615ffd83dbSDimitry Andric } 1625ffd83dbSDimitry Andric __DEVICE__ long long llmin(long long __a, long long __b) { 1635ffd83dbSDimitry Andric return __nv_llmin(__a, __b); 1645ffd83dbSDimitry Andric } 1655ffd83dbSDimitry Andric __DEVICE__ long long llrint(double __a) { return __nv_llrint(__a); } 1665ffd83dbSDimitry Andric __DEVICE__ long long llrintf(float __a) { return __nv_llrintf(__a); } 1675ffd83dbSDimitry Andric __DEVICE__ long long llround(double __a) { return __nv_llround(__a); } 1685ffd83dbSDimitry Andric __DEVICE__ long long llroundf(float __a) { return __nv_llroundf(__a); } 169fe6060f1SDimitry Andric __DEVICE__ double round(double __a) { return __nv_round(__a); } 170fe6060f1SDimitry Andric __DEVICE__ float roundf(float __a) { return __nv_roundf(__a); } 1715ffd83dbSDimitry Andric __DEVICE__ double log(double __a) { return __nv_log(__a); } 1725ffd83dbSDimitry Andric __DEVICE__ double log10(double __a) { return __nv_log10(__a); } 1735ffd83dbSDimitry Andric __DEVICE__ float log10f(float __a) { return __nv_log10f(__a); } 1745ffd83dbSDimitry Andric __DEVICE__ double log1p(double __a) { return __nv_log1p(__a); } 1755ffd83dbSDimitry Andric __DEVICE__ float log1pf(float __a) { return __nv_log1pf(__a); } 1765ffd83dbSDimitry Andric __DEVICE__ double log2(double __a) { return __nv_log2(__a); } 1775ffd83dbSDimitry Andric __DEVICE__ float log2f(float __a) { 1785ffd83dbSDimitry Andric return __FAST_OR_SLOW(__nv_fast_log2f, __nv_log2f)(__a); 1795ffd83dbSDimitry Andric } 1805ffd83dbSDimitry Andric __DEVICE__ double logb(double __a) { return __nv_logb(__a); } 1815ffd83dbSDimitry Andric __DEVICE__ float logbf(float __a) { return __nv_logbf(__a); } 1825ffd83dbSDimitry Andric __DEVICE__ float logf(float __a) { 1835ffd83dbSDimitry Andric return __FAST_OR_SLOW(__nv_fast_logf, __nv_logf)(__a); 1845ffd83dbSDimitry Andric } 1855ffd83dbSDimitry Andric #if defined(__LP64__) || defined(_WIN64) 1865ffd83dbSDimitry Andric __DEVICE__ long lrint(double __a) { return llrint(__a); } 1875ffd83dbSDimitry Andric __DEVICE__ long lrintf(float __a) { return __float2ll_rn(__a); } 1885ffd83dbSDimitry Andric __DEVICE__ long lround(double __a) { return llround(__a); } 1895ffd83dbSDimitry Andric __DEVICE__ long lroundf(float __a) { return llroundf(__a); } 1905ffd83dbSDimitry Andric #else 1915ffd83dbSDimitry Andric __DEVICE__ long lrint(double __a) { return (long)rint(__a); } 1925ffd83dbSDimitry Andric __DEVICE__ long lrintf(float __a) { return __float2int_rn(__a); } 1935ffd83dbSDimitry Andric __DEVICE__ long lround(double __a) { return round(__a); } 1945ffd83dbSDimitry Andric __DEVICE__ long lroundf(float __a) { return roundf(__a); } 1955ffd83dbSDimitry Andric #endif 1965ffd83dbSDimitry Andric __DEVICE__ int max(int __a, int __b) { return __nv_max(__a, __b); } 1975ffd83dbSDimitry Andric __DEVICE__ int min(int __a, int __b) { return __nv_min(__a, __b); } 1985ffd83dbSDimitry Andric __DEVICE__ double modf(double __a, double *__b) { return __nv_modf(__a, __b); } 1995ffd83dbSDimitry Andric __DEVICE__ float modff(float __a, float *__b) { return __nv_modff(__a, __b); } 200e8d8bef9SDimitry Andric __DEVICE__ double nearbyint(double __a) { return __builtin_nearbyint(__a); } 201e8d8bef9SDimitry Andric __DEVICE__ float nearbyintf(float __a) { return __builtin_nearbyintf(__a); } 2025ffd83dbSDimitry Andric __DEVICE__ double nextafter(double __a, double __b) { 2035ffd83dbSDimitry Andric return __nv_nextafter(__a, __b); 2045ffd83dbSDimitry Andric } 2055ffd83dbSDimitry Andric __DEVICE__ float nextafterf(float __a, float __b) { 2065ffd83dbSDimitry Andric return __nv_nextafterf(__a, __b); 2075ffd83dbSDimitry Andric } 2085ffd83dbSDimitry Andric __DEVICE__ double norm(int __dim, const double *__t) { 2095ffd83dbSDimitry Andric return __nv_norm(__dim, __t); 2105ffd83dbSDimitry Andric } 2115ffd83dbSDimitry Andric __DEVICE__ double norm3d(double __a, double __b, double __c) { 2125ffd83dbSDimitry Andric return __nv_norm3d(__a, __b, __c); 2135ffd83dbSDimitry Andric } 2145ffd83dbSDimitry Andric __DEVICE__ float norm3df(float __a, float __b, float __c) { 2155ffd83dbSDimitry Andric return __nv_norm3df(__a, __b, __c); 2165ffd83dbSDimitry Andric } 2175ffd83dbSDimitry Andric __DEVICE__ double norm4d(double __a, double __b, double __c, double __d) { 2185ffd83dbSDimitry Andric return __nv_norm4d(__a, __b, __c, __d); 2195ffd83dbSDimitry Andric } 2205ffd83dbSDimitry Andric __DEVICE__ float norm4df(float __a, float __b, float __c, float __d) { 2215ffd83dbSDimitry Andric return __nv_norm4df(__a, __b, __c, __d); 2225ffd83dbSDimitry Andric } 2235ffd83dbSDimitry Andric __DEVICE__ double normcdf(double __a) { return __nv_normcdf(__a); } 2245ffd83dbSDimitry Andric __DEVICE__ float normcdff(float __a) { return __nv_normcdff(__a); } 2255ffd83dbSDimitry Andric __DEVICE__ double normcdfinv(double __a) { return __nv_normcdfinv(__a); } 2265ffd83dbSDimitry Andric __DEVICE__ float normcdfinvf(float __a) { return __nv_normcdfinvf(__a); } 2275ffd83dbSDimitry Andric __DEVICE__ float normf(int __dim, const float *__t) { 2285ffd83dbSDimitry Andric return __nv_normf(__dim, __t); 2295ffd83dbSDimitry Andric } 2305ffd83dbSDimitry Andric __DEVICE__ double pow(double __a, double __b) { return __nv_pow(__a, __b); } 2315ffd83dbSDimitry Andric __DEVICE__ float powf(float __a, float __b) { return __nv_powf(__a, __b); } 2325ffd83dbSDimitry Andric __DEVICE__ double powi(double __a, int __b) { return __nv_powi(__a, __b); } 2335ffd83dbSDimitry Andric __DEVICE__ float powif(float __a, int __b) { return __nv_powif(__a, __b); } 2345ffd83dbSDimitry Andric __DEVICE__ double rcbrt(double __a) { return __nv_rcbrt(__a); } 2355ffd83dbSDimitry Andric __DEVICE__ float rcbrtf(float __a) { return __nv_rcbrtf(__a); } 2365ffd83dbSDimitry Andric __DEVICE__ double remainder(double __a, double __b) { 2375ffd83dbSDimitry Andric return __nv_remainder(__a, __b); 2385ffd83dbSDimitry Andric } 2395ffd83dbSDimitry Andric __DEVICE__ float remainderf(float __a, float __b) { 2405ffd83dbSDimitry Andric return __nv_remainderf(__a, __b); 2415ffd83dbSDimitry Andric } 2425ffd83dbSDimitry Andric __DEVICE__ double remquo(double __a, double __b, int *__c) { 2435ffd83dbSDimitry Andric return __nv_remquo(__a, __b, __c); 2445ffd83dbSDimitry Andric } 2455ffd83dbSDimitry Andric __DEVICE__ float remquof(float __a, float __b, int *__c) { 2465ffd83dbSDimitry Andric return __nv_remquof(__a, __b, __c); 2475ffd83dbSDimitry Andric } 2485ffd83dbSDimitry Andric __DEVICE__ double rhypot(double __a, double __b) { 2495ffd83dbSDimitry Andric return __nv_rhypot(__a, __b); 2505ffd83dbSDimitry Andric } 2515ffd83dbSDimitry Andric __DEVICE__ float rhypotf(float __a, float __b) { 2525ffd83dbSDimitry Andric return __nv_rhypotf(__a, __b); 2535ffd83dbSDimitry Andric } 254e8d8bef9SDimitry Andric // __nv_rint* in libdevice is buggy and produces incorrect results. 255e8d8bef9SDimitry Andric __DEVICE__ double rint(double __a) { return __builtin_rint(__a); } 256e8d8bef9SDimitry Andric __DEVICE__ float rintf(float __a) { return __builtin_rintf(__a); } 2575ffd83dbSDimitry Andric __DEVICE__ double rnorm(int __a, const double *__b) { 2585ffd83dbSDimitry Andric return __nv_rnorm(__a, __b); 2595ffd83dbSDimitry Andric } 2605ffd83dbSDimitry Andric __DEVICE__ double rnorm3d(double __a, double __b, double __c) { 2615ffd83dbSDimitry Andric return __nv_rnorm3d(__a, __b, __c); 2625ffd83dbSDimitry Andric } 2635ffd83dbSDimitry Andric __DEVICE__ float rnorm3df(float __a, float __b, float __c) { 2645ffd83dbSDimitry Andric return __nv_rnorm3df(__a, __b, __c); 2655ffd83dbSDimitry Andric } 2665ffd83dbSDimitry Andric __DEVICE__ double rnorm4d(double __a, double __b, double __c, double __d) { 2675ffd83dbSDimitry Andric return __nv_rnorm4d(__a, __b, __c, __d); 2685ffd83dbSDimitry Andric } 2695ffd83dbSDimitry Andric __DEVICE__ float rnorm4df(float __a, float __b, float __c, float __d) { 2705ffd83dbSDimitry Andric return __nv_rnorm4df(__a, __b, __c, __d); 2715ffd83dbSDimitry Andric } 2725ffd83dbSDimitry Andric __DEVICE__ float rnormf(int __dim, const float *__t) { 2735ffd83dbSDimitry Andric return __nv_rnormf(__dim, __t); 2745ffd83dbSDimitry Andric } 2755ffd83dbSDimitry Andric __DEVICE__ double rsqrt(double __a) { return __nv_rsqrt(__a); } 2765ffd83dbSDimitry Andric __DEVICE__ float rsqrtf(float __a) { return __nv_rsqrtf(__a); } 2775ffd83dbSDimitry Andric __DEVICE__ double scalbn(double __a, int __b) { return __nv_scalbn(__a, __b); } 2785ffd83dbSDimitry Andric __DEVICE__ float scalbnf(float __a, int __b) { return __nv_scalbnf(__a, __b); } 2795ffd83dbSDimitry Andric __DEVICE__ double scalbln(double __a, long __b) { 2805ffd83dbSDimitry Andric if (__b > INT_MAX) 2815ffd83dbSDimitry Andric return __a > 0 ? HUGE_VAL : -HUGE_VAL; 2825ffd83dbSDimitry Andric if (__b < INT_MIN) 2835ffd83dbSDimitry Andric return __a > 0 ? 0.0 : -0.0; 2845ffd83dbSDimitry Andric return scalbn(__a, (int)__b); 2855ffd83dbSDimitry Andric } 2865ffd83dbSDimitry Andric __DEVICE__ float scalblnf(float __a, long __b) { 2875ffd83dbSDimitry Andric if (__b > INT_MAX) 2885ffd83dbSDimitry Andric return __a > 0 ? HUGE_VALF : -HUGE_VALF; 2895ffd83dbSDimitry Andric if (__b < INT_MIN) 2905ffd83dbSDimitry Andric return __a > 0 ? 0.f : -0.f; 2915ffd83dbSDimitry Andric return scalbnf(__a, (int)__b); 2925ffd83dbSDimitry Andric } 2935ffd83dbSDimitry Andric __DEVICE__ double sin(double __a) { return __nv_sin(__a); } 2945ffd83dbSDimitry Andric __DEVICE_VOID__ void sincos(double __a, double *__s, double *__c) { 2955ffd83dbSDimitry Andric return __nv_sincos(__a, __s, __c); 2965ffd83dbSDimitry Andric } 2975ffd83dbSDimitry Andric __DEVICE_VOID__ void sincosf(float __a, float *__s, float *__c) { 2985ffd83dbSDimitry Andric return __FAST_OR_SLOW(__nv_fast_sincosf, __nv_sincosf)(__a, __s, __c); 2995ffd83dbSDimitry Andric } 3005ffd83dbSDimitry Andric __DEVICE_VOID__ void sincospi(double __a, double *__s, double *__c) { 3015ffd83dbSDimitry Andric return __nv_sincospi(__a, __s, __c); 3025ffd83dbSDimitry Andric } 3035ffd83dbSDimitry Andric __DEVICE_VOID__ void sincospif(float __a, float *__s, float *__c) { 3045ffd83dbSDimitry Andric return __nv_sincospif(__a, __s, __c); 3055ffd83dbSDimitry Andric } 3065ffd83dbSDimitry Andric __DEVICE__ float sinf(float __a) { 3075ffd83dbSDimitry Andric return __FAST_OR_SLOW(__nv_fast_sinf, __nv_sinf)(__a); 3085ffd83dbSDimitry Andric } 3095ffd83dbSDimitry Andric __DEVICE__ double sinh(double __a) { return __nv_sinh(__a); } 3105ffd83dbSDimitry Andric __DEVICE__ float sinhf(float __a) { return __nv_sinhf(__a); } 3115ffd83dbSDimitry Andric __DEVICE__ double sinpi(double __a) { return __nv_sinpi(__a); } 3125ffd83dbSDimitry Andric __DEVICE__ float sinpif(float __a) { return __nv_sinpif(__a); } 3135ffd83dbSDimitry Andric __DEVICE__ double sqrt(double __a) { return __nv_sqrt(__a); } 3145ffd83dbSDimitry Andric __DEVICE__ float sqrtf(float __a) { return __nv_sqrtf(__a); } 3155ffd83dbSDimitry Andric __DEVICE__ double tan(double __a) { return __nv_tan(__a); } 3165ffd83dbSDimitry Andric __DEVICE__ float tanf(float __a) { return __nv_tanf(__a); } 3175ffd83dbSDimitry Andric __DEVICE__ double tanh(double __a) { return __nv_tanh(__a); } 3185ffd83dbSDimitry Andric __DEVICE__ float tanhf(float __a) { return __nv_tanhf(__a); } 3195ffd83dbSDimitry Andric __DEVICE__ double tgamma(double __a) { return __nv_tgamma(__a); } 3205ffd83dbSDimitry Andric __DEVICE__ float tgammaf(float __a) { return __nv_tgammaf(__a); } 3215ffd83dbSDimitry Andric __DEVICE__ double trunc(double __a) { return __nv_trunc(__a); } 3225ffd83dbSDimitry Andric __DEVICE__ float truncf(float __a) { return __nv_truncf(__a); } 3235ffd83dbSDimitry Andric __DEVICE__ unsigned long long ullmax(unsigned long long __a, 3245ffd83dbSDimitry Andric unsigned long long __b) { 3255ffd83dbSDimitry Andric return __nv_ullmax(__a, __b); 3265ffd83dbSDimitry Andric } 3275ffd83dbSDimitry Andric __DEVICE__ unsigned long long ullmin(unsigned long long __a, 3285ffd83dbSDimitry Andric unsigned long long __b) { 3295ffd83dbSDimitry Andric return __nv_ullmin(__a, __b); 3305ffd83dbSDimitry Andric } 3315ffd83dbSDimitry Andric __DEVICE__ unsigned int umax(unsigned int __a, unsigned int __b) { 3325ffd83dbSDimitry Andric return __nv_umax(__a, __b); 3335ffd83dbSDimitry Andric } 3345ffd83dbSDimitry Andric __DEVICE__ unsigned int umin(unsigned int __a, unsigned int __b) { 3355ffd83dbSDimitry Andric return __nv_umin(__a, __b); 3365ffd83dbSDimitry Andric } 3375ffd83dbSDimitry Andric __DEVICE__ double y0(double __a) { return __nv_y0(__a); } 3385ffd83dbSDimitry Andric __DEVICE__ float y0f(float __a) { return __nv_y0f(__a); } 3395ffd83dbSDimitry Andric __DEVICE__ double y1(double __a) { return __nv_y1(__a); } 3405ffd83dbSDimitry Andric __DEVICE__ float y1f(float __a) { return __nv_y1f(__a); } 3415ffd83dbSDimitry Andric __DEVICE__ double yn(int __a, double __b) { return __nv_yn(__a, __b); } 3425ffd83dbSDimitry Andric __DEVICE__ float ynf(int __a, float __b) { return __nv_ynf(__a, __b); } 3435ffd83dbSDimitry Andric 3445ffd83dbSDimitry Andric #pragma pop_macro("__DEVICE__") 3455ffd83dbSDimitry Andric #pragma pop_macro("__DEVICE_VOID__") 3465ffd83dbSDimitry Andric #pragma pop_macro("__FAST_OR_SLOW") 3475ffd83dbSDimitry Andric 34804eeddc0SDimitry Andric #endif // __CLANG_CUDA_MATH_H__ 349