Clang Project

clang_source_code/lib/Headers/__clang_cuda_math_forward_declares.h
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(doubledouble);
54__DEVICE__ float atan2(floatfloat);
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(doubledouble);
64__DEVICE__ float copysign(floatfloat);
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(doubledouble);
82__DEVICE__ float fdim(floatfloat);
83__DEVICE__ double floor(double);
84__DEVICE__ float floor(float);
85__DEVICE__ double fma(doubledoubledouble);
86__DEVICE__ float fma(floatfloatfloat);
87__DEVICE__ double fmax(doubledouble);
88__DEVICE__ float fmax(floatfloat);
89__DEVICE__ double fmin(doubledouble);
90__DEVICE__ float fmin(floatfloat);
91__DEVICE__ double fmod(doubledouble);
92__DEVICE__ float fmod(floatfloat);
93__DEVICE__ int fpclassify(double);
94__DEVICE__ int fpclassify(float);
95__DEVICE__ double frexp(doubleint *);
96__DEVICE__ float frexp(floatint *);
97__DEVICE__ double hypot(doubledouble);
98__DEVICE__ float hypot(floatfloat);
99__DEVICE__ int ilogb(double);
100__DEVICE__ int ilogb(float);
101__DEVICE__ bool isfinite(double);
102__DEVICE__ bool isfinite(float);
103__DEVICE__ bool isgreater(doubledouble);
104__DEVICE__ bool isgreaterequal(doubledouble);
105__DEVICE__ bool isgreaterequal(floatfloat);
106__DEVICE__ bool isgreater(floatfloat);
107__DEVICE__ bool isinf(double);
108__DEVICE__ bool isinf(float);
109__DEVICE__ bool isless(doubledouble);
110__DEVICE__ bool islessequal(doubledouble);
111__DEVICE__ bool islessequal(floatfloat);
112__DEVICE__ bool isless(floatfloat);
113__DEVICE__ bool islessgreater(doubledouble);
114__DEVICE__ bool islessgreater(floatfloat);
115__DEVICE__ bool isnan(double);
116__DEVICE__ bool isnan(float);
117__DEVICE__ bool isnormal(double);
118__DEVICE__ bool isnormal(float);
119__DEVICE__ bool isunordered(doubledouble);
120__DEVICE__ bool isunordered(floatfloat);
121__DEVICE__ long labs(long);
122__DEVICE__ double ldexp(doubleint);
123__DEVICE__ float ldexp(floatint);
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__ long long llround(float); // No llround(double).
144__DEVICE__ double modf(doubledouble *);
145__DEVICE__ float modf(floatfloat *);
146__DEVICE__ double nan(const char *);
147__DEVICE__ float nanf(const char *);
148__DEVICE__ double nearbyint(double);
149__DEVICE__ float nearbyint(float);
150__DEVICE__ double nextafter(doubledouble);
151__DEVICE__ float nextafter(floatfloat);
152__DEVICE__ double pow(doubledouble);
153__DEVICE__ double pow(doubleint);
154__DEVICE__ float pow(floatfloat);
155__DEVICE__ float pow(floatint);
156__DEVICE__ double remainder(doubledouble);
157__DEVICE__ float remainder(floatfloat);
158__DEVICE__ double remquo(doubledoubleint *);
159__DEVICE__ float remquo(floatfloatint *);
160__DEVICE__ double rint(double);
161__DEVICE__ float rint(float);
162__DEVICE__ double round(double);
163__DEVICE__ float round(float);
164__DEVICE__ double scalbln(doublelong);
165__DEVICE__ float scalbln(floatlong);
166__DEVICE__ double scalbn(doubleint);
167__DEVICE__ float scalbn(floatint);
168__DEVICE__ bool signbit(double);
169__DEVICE__ bool signbit(float);
170__DEVICE__ double sin(double);
171__DEVICE__ float sin(float);
172__DEVICE__ double sinh(double);
173__DEVICE__ float sinh(float);
174__DEVICE__ double sqrt(double);
175__DEVICE__ float sqrt(float);
176__DEVICE__ double tan(double);
177__DEVICE__ float tan(float);
178__DEVICE__ double tanh(double);
179__DEVICE__ float tanh(float);
180__DEVICE__ double tgamma(double);
181__DEVICE__ float tgamma(float);
182__DEVICE__ double trunc(double);
183__DEVICE__ float trunc(float);
184
185// Notably missing above is nexttoward, which we don't define on
186// the device side because libdevice doesn't give us an implementation, and we
187// don't want to be in the business of writing one ourselves.
188
189// We need to define these overloads in exactly the namespace our standard
190// library uses (including the right inline namespace), otherwise they won't be
191// picked up by other functions in the standard library (e.g. functions in
192// <complex>).  Thus the ugliness below.
193#ifdef _LIBCPP_BEGIN_NAMESPACE_STD
194_LIBCPP_BEGIN_NAMESPACE_STD
195#else
196namespace std {
197#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
198_GLIBCXX_BEGIN_NAMESPACE_VERSION
199#endif
200#endif
201
202using ::abs;
203using ::acos;
204using ::acosh;
205using ::asin;
206using ::asinh;
207using ::atan;
208using ::atan2;
209using ::atanh;
210using ::cbrt;
211using ::ceil;
212using ::copysign;
213using ::cos;
214using ::cosh;
215using ::erf;
216using ::erfc;
217using ::exp;
218using ::exp2;
219using ::expm1;
220using ::fabs;
221using ::fdim;
222using ::floor;
223using ::fma;
224using ::fmax;
225using ::fmin;
226using ::fmod;
227using ::fpclassify;
228using ::frexp;
229using ::hypot;
230using ::ilogb;
231using ::isfinite;
232using ::isgreater;
233using ::isgreaterequal;
234using ::isinf;
235using ::isless;
236using ::islessequal;
237using ::islessgreater;
238using ::isnan;
239using ::isnormal;
240using ::isunordered;
241using ::labs;
242using ::ldexp;
243using ::lgamma;
244using ::llabs;
245using ::llrint;
246using ::log;
247using ::log10;
248using ::log1p;
249using ::log2;
250using ::logb;
251using ::lrint;
252using ::lround;
253using ::llround;
254using ::modf;
255using ::nan;
256using ::nanf;
257using ::nearbyint;
258using ::nextafter;
259using ::pow;
260using ::remainder;
261using ::remquo;
262using ::rint;
263using ::round;
264using ::scalbln;
265using ::scalbn;
266using ::signbit;
267using ::sin;
268using ::sinh;
269using ::sqrt;
270using ::tan;
271using ::tanh;
272using ::tgamma;
273using ::trunc;
274
275#ifdef _LIBCPP_END_NAMESPACE_STD
276_LIBCPP_END_NAMESPACE_STD
277#else
278#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
279_GLIBCXX_END_NAMESPACE_VERSION
280#endif
281// namespace std
282#endif
283
284#pragma pop_macro("__DEVICE__")
285
286#endif
287