]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/clang/lib/Headers/__clang_cuda_math_forward_declares.h
MFC r355940:
[FreeBSD/FreeBSD.git] / contrib / llvm-project / clang / lib / Headers / __clang_cuda_math_forward_declares.h
1 /*===- __clang_math_forward_declares.h - Prototypes of __device__ math fns --===
2  *
3  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4  * See https://llvm.org/LICENSE.txt for license information.
5  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6  *
7  *===-----------------------------------------------------------------------===
8  */
9 #ifndef __CLANG__CUDA_MATH_FORWARD_DECLARES_H__
10 #define __CLANG__CUDA_MATH_FORWARD_DECLARES_H__
11 #ifndef __CUDA__
12 #error "This file is for CUDA compilation only."
13 #endif
14
15 // This file forward-declares of some math functions we (or the CUDA headers)
16 // will define later.  We need to do this, and do it before cmath is included,
17 // because the standard library may have constexpr math functions.  In the
18 // absence of a prior __device__ decl, those constexpr functions may become
19 // implicitly host+device.  host+device functions can't be overloaded, so that
20 // would preclude the use of our own __device__ overloads for these functions.
21
22 #pragma push_macro("__DEVICE__")
23 #ifdef _OPENMP
24 #define __DEVICE__ static __inline__ __attribute__((always_inline))
25 #else
26 #define __DEVICE__                                                             \
27   static __inline__ __attribute__((always_inline)) __attribute__((device))
28 #endif
29
30 // For C++ 17 we need to include noexcept attribute to be compatible
31 // with the header-defined version. This may be removed once
32 // variant is supported.
33 #if defined(_OPENMP) && defined(__cplusplus) && __cplusplus >= 201703L
34 #define __NOEXCEPT noexcept
35 #else
36 #define __NOEXCEPT
37 #endif
38
39 #if !(defined(_OPENMP) && defined(__cplusplus))
40 __DEVICE__ long abs(long);
41 __DEVICE__ long long abs(long long);
42 __DEVICE__ double abs(double);
43 __DEVICE__ float abs(float);
44 #endif
45 // While providing the CUDA declarations and definitions for math functions,
46 // we may manually define additional functions.
47 // TODO: Once variant is supported the additional functions will have
48 // to be removed.
49 #if defined(_OPENMP) && defined(__cplusplus)
50 __DEVICE__ const double abs(const double);
51 __DEVICE__ const float abs(const float);
52 #endif
53 __DEVICE__ int abs(int) __NOEXCEPT;
54 __DEVICE__ double acos(double);
55 __DEVICE__ float acos(float);
56 __DEVICE__ double acosh(double);
57 __DEVICE__ float acosh(float);
58 __DEVICE__ double asin(double);
59 __DEVICE__ float asin(float);
60 __DEVICE__ double asinh(double);
61 __DEVICE__ float asinh(float);
62 __DEVICE__ double atan2(double, double);
63 __DEVICE__ float atan2(float, float);
64 __DEVICE__ double atan(double);
65 __DEVICE__ float atan(float);
66 __DEVICE__ double atanh(double);
67 __DEVICE__ float atanh(float);
68 __DEVICE__ double cbrt(double);
69 __DEVICE__ float cbrt(float);
70 __DEVICE__ double ceil(double);
71 __DEVICE__ float ceil(float);
72 __DEVICE__ double copysign(double, double);
73 __DEVICE__ float copysign(float, float);
74 __DEVICE__ double cos(double);
75 __DEVICE__ float cos(float);
76 __DEVICE__ double cosh(double);
77 __DEVICE__ float cosh(float);
78 __DEVICE__ double erfc(double);
79 __DEVICE__ float erfc(float);
80 __DEVICE__ double erf(double);
81 __DEVICE__ float erf(float);
82 __DEVICE__ double exp2(double);
83 __DEVICE__ float exp2(float);
84 __DEVICE__ double exp(double);
85 __DEVICE__ float exp(float);
86 __DEVICE__ double expm1(double);
87 __DEVICE__ float expm1(float);
88 __DEVICE__ double fabs(double) __NOEXCEPT;
89 __DEVICE__ float fabs(float) __NOEXCEPT;
90 __DEVICE__ double fdim(double, double);
91 __DEVICE__ float fdim(float, float);
92 __DEVICE__ double floor(double);
93 __DEVICE__ float floor(float);
94 __DEVICE__ double fma(double, double, double);
95 __DEVICE__ float fma(float, float, float);
96 __DEVICE__ double fmax(double, double);
97 __DEVICE__ float fmax(float, float);
98 __DEVICE__ double fmin(double, double);
99 __DEVICE__ float fmin(float, float);
100 __DEVICE__ double fmod(double, double);
101 __DEVICE__ float fmod(float, float);
102 __DEVICE__ int fpclassify(double);
103 __DEVICE__ int fpclassify(float);
104 __DEVICE__ double frexp(double, int *);
105 __DEVICE__ float frexp(float, int *);
106 __DEVICE__ double hypot(double, double);
107 __DEVICE__ float hypot(float, float);
108 __DEVICE__ int ilogb(double);
109 __DEVICE__ int ilogb(float);
110 #ifdef _MSC_VER
111 __DEVICE__ bool isfinite(long double);
112 #endif
113 __DEVICE__ bool isfinite(double);
114 __DEVICE__ bool isfinite(float);
115 __DEVICE__ bool isgreater(double, double);
116 __DEVICE__ bool isgreaterequal(double, double);
117 __DEVICE__ bool isgreaterequal(float, float);
118 __DEVICE__ bool isgreater(float, float);
119 #ifdef _MSC_VER
120 __DEVICE__ bool isinf(long double);
121 #endif
122 __DEVICE__ bool isinf(double);
123 __DEVICE__ bool isinf(float);
124 __DEVICE__ bool isless(double, double);
125 __DEVICE__ bool islessequal(double, double);
126 __DEVICE__ bool islessequal(float, float);
127 __DEVICE__ bool isless(float, float);
128 __DEVICE__ bool islessgreater(double, double);
129 __DEVICE__ bool islessgreater(float, float);
130 #ifdef _MSC_VER
131 __DEVICE__ bool isnan(long double);
132 #endif
133 __DEVICE__ bool isnan(double);
134 __DEVICE__ bool isnan(float);
135 __DEVICE__ bool isnormal(double);
136 __DEVICE__ bool isnormal(float);
137 __DEVICE__ bool isunordered(double, double);
138 __DEVICE__ bool isunordered(float, float);
139 __DEVICE__ long labs(long) __NOEXCEPT;
140 __DEVICE__ double ldexp(double, int);
141 __DEVICE__ float ldexp(float, int);
142 __DEVICE__ double lgamma(double);
143 __DEVICE__ float lgamma(float);
144 __DEVICE__ long long llabs(long long) __NOEXCEPT;
145 __DEVICE__ long long llrint(double);
146 __DEVICE__ long long llrint(float);
147 __DEVICE__ double log10(double);
148 __DEVICE__ float log10(float);
149 __DEVICE__ double log1p(double);
150 __DEVICE__ float log1p(float);
151 __DEVICE__ double log2(double);
152 __DEVICE__ float log2(float);
153 __DEVICE__ double logb(double);
154 __DEVICE__ float logb(float);
155 #if defined(_OPENMP) && defined(__cplusplus)
156 __DEVICE__ long double log(long double);
157 #endif
158 __DEVICE__ double log(double);
159 __DEVICE__ float log(float);
160 __DEVICE__ long lrint(double);
161 __DEVICE__ long lrint(float);
162 __DEVICE__ long lround(double);
163 __DEVICE__ long lround(float);
164 __DEVICE__ long long llround(float); // No llround(double).
165 __DEVICE__ double modf(double, double *);
166 __DEVICE__ float modf(float, float *);
167 __DEVICE__ double nan(const char *);
168 __DEVICE__ float nanf(const char *);
169 __DEVICE__ double nearbyint(double);
170 __DEVICE__ float nearbyint(float);
171 __DEVICE__ double nextafter(double, double);
172 __DEVICE__ float nextafter(float, float);
173 __DEVICE__ double pow(double, double);
174 __DEVICE__ double pow(double, int);
175 __DEVICE__ float pow(float, float);
176 __DEVICE__ float pow(float, int);
177 __DEVICE__ double remainder(double, double);
178 __DEVICE__ float remainder(float, float);
179 __DEVICE__ double remquo(double, double, int *);
180 __DEVICE__ float remquo(float, float, int *);
181 __DEVICE__ double rint(double);
182 __DEVICE__ float rint(float);
183 __DEVICE__ double round(double);
184 __DEVICE__ float round(float);
185 __DEVICE__ double scalbln(double, long);
186 __DEVICE__ float scalbln(float, long);
187 __DEVICE__ double scalbn(double, int);
188 __DEVICE__ float scalbn(float, int);
189 __DEVICE__ bool signbit(double);
190 __DEVICE__ bool signbit(float);
191 __DEVICE__ double sin(double);
192 __DEVICE__ float sin(float);
193 __DEVICE__ double sinh(double);
194 __DEVICE__ float sinh(float);
195 __DEVICE__ double sqrt(double);
196 __DEVICE__ float sqrt(float);
197 __DEVICE__ double tan(double);
198 __DEVICE__ float tan(float);
199 __DEVICE__ double tanh(double);
200 __DEVICE__ float tanh(float);
201 __DEVICE__ double tgamma(double);
202 __DEVICE__ float tgamma(float);
203 __DEVICE__ double trunc(double);
204 __DEVICE__ float trunc(float);
205
206 // Notably missing above is nexttoward, which we don't define on
207 // the device side because libdevice doesn't give us an implementation, and we
208 // don't want to be in the business of writing one ourselves.
209
210 // We need to define these overloads in exactly the namespace our standard
211 // library uses (including the right inline namespace), otherwise they won't be
212 // picked up by other functions in the standard library (e.g. functions in
213 // <complex>).  Thus the ugliness below.
214 #ifdef _LIBCPP_BEGIN_NAMESPACE_STD
215 _LIBCPP_BEGIN_NAMESPACE_STD
216 #else
217 namespace std {
218 #ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
219 _GLIBCXX_BEGIN_NAMESPACE_VERSION
220 #endif
221 #endif
222
223 using ::abs;
224 using ::acos;
225 using ::acosh;
226 using ::asin;
227 using ::asinh;
228 using ::atan;
229 using ::atan2;
230 using ::atanh;
231 using ::cbrt;
232 using ::ceil;
233 using ::copysign;
234 using ::cos;
235 using ::cosh;
236 using ::erf;
237 using ::erfc;
238 using ::exp;
239 using ::exp2;
240 using ::expm1;
241 using ::fabs;
242 using ::fdim;
243 using ::floor;
244 using ::fma;
245 using ::fmax;
246 using ::fmin;
247 using ::fmod;
248 using ::fpclassify;
249 using ::frexp;
250 using ::hypot;
251 using ::ilogb;
252 using ::isfinite;
253 using ::isgreater;
254 using ::isgreaterequal;
255 using ::isinf;
256 using ::isless;
257 using ::islessequal;
258 using ::islessgreater;
259 using ::isnan;
260 using ::isnormal;
261 using ::isunordered;
262 using ::labs;
263 using ::ldexp;
264 using ::lgamma;
265 using ::llabs;
266 using ::llrint;
267 using ::log;
268 using ::log10;
269 using ::log1p;
270 using ::log2;
271 using ::logb;
272 using ::lrint;
273 using ::lround;
274 using ::llround;
275 using ::modf;
276 using ::nan;
277 using ::nanf;
278 using ::nearbyint;
279 using ::nextafter;
280 using ::pow;
281 using ::remainder;
282 using ::remquo;
283 using ::rint;
284 using ::round;
285 using ::scalbln;
286 using ::scalbn;
287 using ::signbit;
288 using ::sin;
289 using ::sinh;
290 using ::sqrt;
291 using ::tan;
292 using ::tanh;
293 using ::tgamma;
294 using ::trunc;
295
296 #ifdef _LIBCPP_END_NAMESPACE_STD
297 _LIBCPP_END_NAMESPACE_STD
298 #else
299 #ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
300 _GLIBCXX_END_NAMESPACE_VERSION
301 #endif
302 } // namespace std
303 #endif
304
305 #undef __NOEXCEPT
306 #pragma pop_macro("__DEVICE__")
307
308 #endif