1 /*===- __clang_math_forward_declares.h - Prototypes of __device__ math fns --=== 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining a copy 4 * of this software and associated documentation files (the "Software"), to deal 5 * in the Software without restriction, including without limitation the rights 6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 * copies of the Software, and to permit persons to whom the Software is 8 * furnished to do so, subject to the following conditions: 9 * 10 * The above copyright notice and this permission notice shall be included in 11 * all copies or substantial portions of the Software. 12 * 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 * THE SOFTWARE. 20 * 21 *===-----------------------------------------------------------------------=== 22 */ 23 #ifndef __CLANG__CUDA_MATH_FORWARD_DECLARES_H__ 24 #define __CLANG__CUDA_MATH_FORWARD_DECLARES_H__ 25 #ifndef __CUDA__ 26 #error "This file is for CUDA compilation only." 27 #endif 28 29 // This file forward-declares of some math functions we (or the CUDA headers) 30 // will define later. We need to do this, and do it before cmath is included, 31 // because the standard library may have constexpr math functions. In the 32 // absence of a prior __device__ decl, those constexpr functions may become 33 // implicitly host+device. host+device functions can't be overloaded, so that 34 // would preclude the use of our own __device__ overloads for these functions. 35 36 #pragma push_macro("__DEVICE__") 37 #define __DEVICE__ \ 38 static __inline__ __attribute__((always_inline)) __attribute__((device)) 39 40 __DEVICE__ double abs(double); 41 __DEVICE__ float abs(float); 42 __DEVICE__ int abs(int); 43 __DEVICE__ long abs(long); 44 __DEVICE__ long long abs(long long); 45 __DEVICE__ double acos(double); 46 __DEVICE__ float acos(float); 47 __DEVICE__ double acosh(double); 48 __DEVICE__ float acosh(float); 49 __DEVICE__ double asin(double); 50 __DEVICE__ float asin(float); 51 __DEVICE__ double asinh(double); 52 __DEVICE__ float asinh(float); 53 __DEVICE__ double atan2(double, double); 54 __DEVICE__ float atan2(float, float); 55 __DEVICE__ double atan(double); 56 __DEVICE__ float atan(float); 57 __DEVICE__ double atanh(double); 58 __DEVICE__ float atanh(float); 59 __DEVICE__ double cbrt(double); 60 __DEVICE__ float cbrt(float); 61 __DEVICE__ double ceil(double); 62 __DEVICE__ float ceil(float); 63 __DEVICE__ double copysign(double, double); 64 __DEVICE__ float copysign(float, float); 65 __DEVICE__ double cos(double); 66 __DEVICE__ float cos(float); 67 __DEVICE__ double cosh(double); 68 __DEVICE__ float cosh(float); 69 __DEVICE__ double erfc(double); 70 __DEVICE__ float erfc(float); 71 __DEVICE__ double erf(double); 72 __DEVICE__ float erf(float); 73 __DEVICE__ double exp2(double); 74 __DEVICE__ float exp2(float); 75 __DEVICE__ double exp(double); 76 __DEVICE__ float exp(float); 77 __DEVICE__ double expm1(double); 78 __DEVICE__ float expm1(float); 79 __DEVICE__ double fabs(double); 80 __DEVICE__ float fabs(float); 81 __DEVICE__ double fdim(double, double); 82 __DEVICE__ float fdim(float, float); 83 __DEVICE__ double floor(double); 84 __DEVICE__ float floor(float); 85 __DEVICE__ double fma(double, double, double); 86 __DEVICE__ float fma(float, float, float); 87 __DEVICE__ double fmax(double, double); 88 __DEVICE__ float fmax(float, float); 89 __DEVICE__ double fmin(double, double); 90 __DEVICE__ float fmin(float, float); 91 __DEVICE__ double fmod(double, double); 92 __DEVICE__ float fmod(float, float); 93 __DEVICE__ int fpclassify(double); 94 __DEVICE__ int fpclassify(float); 95 __DEVICE__ double frexp(double, int *); 96 __DEVICE__ float frexp(float, int *); 97 __DEVICE__ double hypot(double, double); 98 __DEVICE__ float hypot(float, float); 99 __DEVICE__ int ilogb(double); 100 __DEVICE__ int ilogb(float); 101 __DEVICE__ bool isfinite(double); 102 __DEVICE__ bool isfinite(float); 103 __DEVICE__ bool isgreater(double, double); 104 __DEVICE__ bool isgreaterequal(double, double); 105 __DEVICE__ bool isgreaterequal(float, float); 106 __DEVICE__ bool isgreater(float, float); 107 __DEVICE__ bool isinf(double); 108 __DEVICE__ bool isinf(float); 109 __DEVICE__ bool isless(double, double); 110 __DEVICE__ bool islessequal(double, double); 111 __DEVICE__ bool islessequal(float, float); 112 __DEVICE__ bool isless(float, float); 113 __DEVICE__ bool islessgreater(double, double); 114 __DEVICE__ bool islessgreater(float, float); 115 __DEVICE__ bool isnan(double); 116 __DEVICE__ bool isnan(float); 117 __DEVICE__ bool isnormal(double); 118 __DEVICE__ bool isnormal(float); 119 __DEVICE__ bool isunordered(double, double); 120 __DEVICE__ bool isunordered(float, float); 121 __DEVICE__ long labs(long); 122 __DEVICE__ double ldexp(double, int); 123 __DEVICE__ float ldexp(float, int); 124 __DEVICE__ double lgamma(double); 125 __DEVICE__ float lgamma(float); 126 __DEVICE__ long long llabs(long long); 127 __DEVICE__ long long llrint(double); 128 __DEVICE__ long long llrint(float); 129 __DEVICE__ double log10(double); 130 __DEVICE__ float log10(float); 131 __DEVICE__ double log1p(double); 132 __DEVICE__ float log1p(float); 133 __DEVICE__ double log2(double); 134 __DEVICE__ float log2(float); 135 __DEVICE__ double logb(double); 136 __DEVICE__ float logb(float); 137 __DEVICE__ double log(double); 138 __DEVICE__ float log(float); 139 __DEVICE__ long lrint(double); 140 __DEVICE__ long lrint(float); 141 __DEVICE__ long lround(double); 142 __DEVICE__ long lround(float); 143 __DEVICE__ double modf(double, double *); 144 __DEVICE__ float modf(float, float *); 145 __DEVICE__ double nan(const char *); 146 __DEVICE__ float nanf(const char *); 147 __DEVICE__ double nearbyint(double); 148 __DEVICE__ float nearbyint(float); 149 __DEVICE__ double nextafter(double, double); 150 __DEVICE__ float nextafter(float, float); 151 __DEVICE__ double nexttoward(double, double); 152 __DEVICE__ float nexttoward(float, float); 153 __DEVICE__ double pow(double, double); 154 __DEVICE__ double pow(double, int); 155 __DEVICE__ float pow(float, float); 156 __DEVICE__ float pow(float, int); 157 __DEVICE__ double remainder(double, double); 158 __DEVICE__ float remainder(float, float); 159 __DEVICE__ double remquo(double, double, int *); 160 __DEVICE__ float remquo(float, float, int *); 161 __DEVICE__ double rint(double); 162 __DEVICE__ float rint(float); 163 __DEVICE__ double round(double); 164 __DEVICE__ float round(float); 165 __DEVICE__ double scalbln(double, long); 166 __DEVICE__ float scalbln(float, long); 167 __DEVICE__ double scalbn(double, int); 168 __DEVICE__ float scalbn(float, int); 169 __DEVICE__ bool signbit(double); 170 __DEVICE__ bool signbit(float); 171 __DEVICE__ double sin(double); 172 __DEVICE__ float sin(float); 173 __DEVICE__ double sinh(double); 174 __DEVICE__ float sinh(float); 175 __DEVICE__ double sqrt(double); 176 __DEVICE__ float sqrt(float); 177 __DEVICE__ double tan(double); 178 __DEVICE__ float tan(float); 179 __DEVICE__ double tanh(double); 180 __DEVICE__ float tanh(float); 181 __DEVICE__ double tgamma(double); 182 __DEVICE__ float tgamma(float); 183 __DEVICE__ double trunc(double); 184 __DEVICE__ float trunc(float); 185 186 namespace std { 187 using ::abs; 188 using ::acos; 189 using ::acosh; 190 using ::asin; 191 using ::asinh; 192 using ::atan; 193 using ::atan2; 194 using ::atanh; 195 using ::cbrt; 196 using ::ceil; 197 using ::copysign; 198 using ::cos; 199 using ::cosh; 200 using ::erf; 201 using ::erfc; 202 using ::exp; 203 using ::exp2; 204 using ::expm1; 205 using ::fabs; 206 using ::fdim; 207 using ::floor; 208 using ::fma; 209 using ::fmax; 210 using ::fmin; 211 using ::fmod; 212 using ::fpclassify; 213 using ::frexp; 214 using ::hypot; 215 using ::ilogb; 216 using ::isfinite; 217 using ::isgreater; 218 using ::isgreaterequal; 219 using ::isinf; 220 using ::isless; 221 using ::islessequal; 222 using ::islessgreater; 223 using ::isnan; 224 using ::isnormal; 225 using ::isunordered; 226 using ::labs; 227 using ::ldexp; 228 using ::lgamma; 229 using ::llabs; 230 using ::llrint; 231 using ::log; 232 using ::log10; 233 using ::log1p; 234 using ::log2; 235 using ::logb; 236 using ::lrint; 237 using ::lround; 238 using ::modf; 239 using ::nan; 240 using ::nanf; 241 using ::nearbyint; 242 using ::nextafter; 243 using ::nexttoward; 244 using ::pow; 245 using ::remainder; 246 using ::remquo; 247 using ::rint; 248 using ::round; 249 using ::scalbln; 250 using ::scalbn; 251 using ::signbit; 252 using ::sin; 253 using ::sinh; 254 using ::sqrt; 255 using ::tan; 256 using ::tanh; 257 using ::tgamma; 258 using ::trunc; 259 } // namespace std 260 261 #pragma pop_macro("__DEVICE__") 262 263 #endif 264