clang 20.0.0git
__clang_cuda_math_forward_declares.h
Go to the documentation of this file.
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#if !defined(__CUDA__) && !__HIP__
12#error "This file is for CUDA/HIP 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#define __DEVICE__ \
24 static __inline__ __attribute__((always_inline)) __attribute__((device))
25
26__DEVICE__ long abs(long);
27__DEVICE__ long long abs(long long);
28__DEVICE__ double abs(double);
29__DEVICE__ float abs(float);
30__DEVICE__ int abs(int);
31__DEVICE__ double acos(double);
32__DEVICE__ float acos(float);
33__DEVICE__ double acosh(double);
34__DEVICE__ float acosh(float);
35__DEVICE__ double asin(double);
36__DEVICE__ float asin(float);
37__DEVICE__ double asinh(double);
38__DEVICE__ float asinh(float);
39__DEVICE__ double atan2(double, double);
40__DEVICE__ float atan2(float, float);
41__DEVICE__ double atan(double);
42__DEVICE__ float atan(float);
43__DEVICE__ double atanh(double);
44__DEVICE__ float atanh(float);
45__DEVICE__ double cbrt(double);
46__DEVICE__ float cbrt(float);
47__DEVICE__ double ceil(double);
48__DEVICE__ float ceil(float);
49__DEVICE__ double copysign(double, double);
50__DEVICE__ float copysign(float, float);
51__DEVICE__ double cos(double);
52__DEVICE__ float cos(float);
53__DEVICE__ double cosh(double);
54__DEVICE__ float cosh(float);
55__DEVICE__ double erfc(double);
56__DEVICE__ float erfc(float);
57__DEVICE__ double erf(double);
58__DEVICE__ float erf(float);
59__DEVICE__ double exp2(double);
60__DEVICE__ float exp2(float);
61__DEVICE__ double exp(double);
62__DEVICE__ float exp(float);
63__DEVICE__ double expm1(double);
64__DEVICE__ float expm1(float);
65__DEVICE__ double fabs(double);
66__DEVICE__ float fabs(float);
67__DEVICE__ double fdim(double, double);
68__DEVICE__ float fdim(float, float);
69__DEVICE__ double floor(double);
70__DEVICE__ float floor(float);
71__DEVICE__ double fma(double, double, double);
72__DEVICE__ float fma(float, float, float);
73__DEVICE__ double fmax(double, double);
74__DEVICE__ float fmax(float, float);
75__DEVICE__ double fmin(double, double);
76__DEVICE__ float fmin(float, float);
77__DEVICE__ double fmod(double, double);
78__DEVICE__ float fmod(float, float);
79__DEVICE__ int fpclassify(double);
80__DEVICE__ int fpclassify(float);
81__DEVICE__ double frexp(double, int *);
82__DEVICE__ float frexp(float, int *);
83__DEVICE__ double hypot(double, double);
84__DEVICE__ float hypot(float, float);
85__DEVICE__ int ilogb(double);
86__DEVICE__ int ilogb(float);
87#ifdef _MSC_VER
88__DEVICE__ bool isfinite(long double);
89#endif
90__DEVICE__ bool isfinite(double);
91__DEVICE__ bool isfinite(float);
92__DEVICE__ bool isgreater(double, double);
93__DEVICE__ bool isgreaterequal(double, double);
94__DEVICE__ bool isgreaterequal(float, float);
95__DEVICE__ bool isgreater(float, float);
96#ifdef _MSC_VER
97__DEVICE__ bool isinf(long double);
98#endif
99__DEVICE__ bool isinf(double);
100__DEVICE__ bool isinf(float);
101__DEVICE__ bool isless(double, double);
102__DEVICE__ bool islessequal(double, double);
103__DEVICE__ bool islessequal(float, float);
104__DEVICE__ bool isless(float, float);
105__DEVICE__ bool islessgreater(double, double);
106__DEVICE__ bool islessgreater(float, float);
107#ifdef _MSC_VER
108__DEVICE__ bool isnan(long double);
109#endif
110__DEVICE__ bool isnan(double);
111__DEVICE__ bool isnan(float);
112__DEVICE__ bool isnormal(double);
113__DEVICE__ bool isnormal(float);
114__DEVICE__ bool isunordered(double, double);
115__DEVICE__ bool isunordered(float, float);
116__DEVICE__ long labs(long);
117__DEVICE__ double ldexp(double, int);
118__DEVICE__ float ldexp(float, int);
119__DEVICE__ double lgamma(double);
120__DEVICE__ float lgamma(float);
121__DEVICE__ long long llabs(long long);
122__DEVICE__ long long llrint(double);
123__DEVICE__ long long llrint(float);
124__DEVICE__ double log10(double);
125__DEVICE__ float log10(float);
126__DEVICE__ double log1p(double);
127__DEVICE__ float log1p(float);
128__DEVICE__ double log2(double);
129__DEVICE__ float log2(float);
130__DEVICE__ double logb(double);
131__DEVICE__ float logb(float);
132__DEVICE__ double log(double);
133__DEVICE__ float log(float);
134__DEVICE__ long lrint(double);
135__DEVICE__ long lrint(float);
136__DEVICE__ long lround(double);
137__DEVICE__ long lround(float);
138__DEVICE__ long long llround(float); // No llround(double).
139__DEVICE__ double modf(double, double *);
140__DEVICE__ float modf(float, float *);
141__DEVICE__ double nan(const char *);
142__DEVICE__ float nanf(const char *);
143__DEVICE__ double nearbyint(double);
145__DEVICE__ double nextafter(double, double);
146__DEVICE__ float nextafter(float, float);
147__DEVICE__ double pow(double, double);
148__DEVICE__ double pow(double, int);
149__DEVICE__ float pow(float, float);
150__DEVICE__ float pow(float, int);
151__DEVICE__ double remainder(double, double);
152__DEVICE__ float remainder(float, float);
153__DEVICE__ double remquo(double, double, int *);
154__DEVICE__ float remquo(float, float, int *);
155__DEVICE__ double rint(double);
156__DEVICE__ float rint(float);
157__DEVICE__ double round(double);
158__DEVICE__ float round(float);
159__DEVICE__ double scalbln(double, long);
160__DEVICE__ float scalbln(float, long);
161__DEVICE__ double scalbn(double, int);
162__DEVICE__ float scalbn(float, int);
163#ifdef _MSC_VER
164__DEVICE__ bool signbit(long double);
165#endif
166__DEVICE__ bool signbit(double);
167__DEVICE__ bool signbit(float);
168__DEVICE__ double sin(double);
169__DEVICE__ float sin(float);
170__DEVICE__ double sinh(double);
171__DEVICE__ float sinh(float);
172__DEVICE__ double sqrt(double);
173__DEVICE__ float sqrt(float);
174__DEVICE__ double tan(double);
175__DEVICE__ float tan(float);
176__DEVICE__ double tanh(double);
177__DEVICE__ float tanh(float);
178__DEVICE__ double tgamma(double);
179__DEVICE__ float tgamma(float);
180__DEVICE__ double trunc(double);
181__DEVICE__ float trunc(float);
182
183// Notably missing above is nexttoward, which we don't define on
184// the device side because libdevice doesn't give us an implementation, and we
185// don't want to be in the business of writing one ourselves.
186
187// We need to define these overloads in exactly the namespace our standard
188// library uses (including the right inline namespace), otherwise they won't be
189// picked up by other functions in the standard library (e.g. functions in
190// <complex>). Thus the ugliness below.
191#ifdef _LIBCPP_BEGIN_NAMESPACE_STD
192_LIBCPP_BEGIN_NAMESPACE_STD
193#else
194namespace std {
195#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
196_GLIBCXX_BEGIN_NAMESPACE_VERSION
197#endif
198#endif
199
200using ::abs;
201using ::acos;
202using ::acosh;
203using ::asin;
204using ::asinh;
205using ::atan;
206using ::atan2;
207using ::atanh;
208using ::cbrt;
209using ::ceil;
210using ::copysign;
211using ::cos;
212using ::cosh;
213using ::erf;
214using ::erfc;
215using ::exp;
216using ::exp2;
217using ::expm1;
218using ::fabs;
219using ::fdim;
220using ::floor;
221using ::fma;
222using ::fmax;
223using ::fmin;
224using ::fmod;
225using ::fpclassify;
226using ::frexp;
227using ::hypot;
228using ::ilogb;
229using ::isfinite;
230using ::isgreater;
231using ::isgreaterequal;
232using ::isinf;
233using ::isless;
234using ::islessequal;
235using ::islessgreater;
236using ::isnan;
237using ::isnormal;
238using ::isunordered;
239using ::labs;
240using ::ldexp;
241using ::lgamma;
242using ::llabs;
243using ::llrint;
244using ::log;
245using ::log10;
246using ::log1p;
247using ::log2;
248using ::logb;
249using ::lrint;
250using ::lround;
251using ::llround;
252using ::modf;
253using ::nan;
254using ::nanf;
255using ::nearbyint;
256using ::nextafter;
257using ::pow;
258using ::remainder;
259using ::remquo;
260using ::rint;
261using ::round;
262using ::scalbln;
263using ::scalbn;
264using ::signbit;
265using ::sin;
266using ::sinh;
267using ::sqrt;
268using ::tan;
269using ::tanh;
270using ::tgamma;
271using ::trunc;
272
273#ifdef _LIBCPP_END_NAMESPACE_STD
274_LIBCPP_END_NAMESPACE_STD
275#else
276#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
277_GLIBCXX_END_NAMESPACE_VERSION
278#endif
279} // namespace std
280#endif
281
282#pragma pop_macro("__DEVICE__")
283
284#endif
__DEVICE__ float nanf(const char *)
__DEVICE__ bool islessgreater(double, double)
__DEVICE__ int fpclassify(double)
__DEVICE__ bool isnan(double)
__DEVICE__ bool signbit(double)
__DEVICE__ long abs(long)
__DEVICE__ bool isgreater(double, double)
__DEVICE__ long long llabs(long long)
__DEVICE__ bool isunordered(double, double)
__DEVICE__ bool islessequal(double, double)
__DEVICE__ long labs(long)
__DEVICE__ bool isnormal(double)
__DEVICE__ double modf(double, double *)
__DEVICE__ bool isinf(double)
__DEVICE__ double nan(const char *)
__DEVICE__ bool isgreaterequal(double, double)
__DEVICE__ bool isless(double, double)
__DEVICE__ bool isfinite(double)
#define sinh(__x)
Definition: tgmath.h:373
#define asin(__x)
Definition: tgmath.h:112
#define scalbln(__x, __y)
Definition: tgmath.h:1182
#define sqrt(__x)
Definition: tgmath.h:520
#define acos(__x)
Definition: tgmath.h:83
#define fmin(__x, __y)
Definition: tgmath.h:780
#define exp(__x)
Definition: tgmath.h:431
#define ilogb(__x)
Definition: tgmath.h:851
#define copysign(__x, __y)
Definition: tgmath.h:618
#define erf(__x)
Definition: tgmath.h:636
#define atanh(__x)
Definition: tgmath.h:228
#define remquo(__x, __y, __z)
Definition: tgmath.h:1111
#define nextafter(__x, __y)
Definition: tgmath.h:1055
#define frexp(__x, __y)
Definition: tgmath.h:816
#define asinh(__x)
Definition: tgmath.h:199
#define erfc(__x)
Definition: tgmath.h:653
#define atan2(__x, __y)
Definition: tgmath.h:566
#define hypot(__x, __y)
Definition: tgmath.h:833
#define exp2(__x)
Definition: tgmath.h:670
#define sin(__x)
Definition: tgmath.h:286
#define cbrt(__x)
Definition: tgmath.h:584
#define log2(__x)
Definition: tgmath.h:970
#define llround(__x)
Definition: tgmath.h:919
#define cosh(__x)
Definition: tgmath.h:344
#define trunc(__x)
Definition: tgmath.h:1216
#define fmax(__x, __y)
Definition: tgmath.h:762
#define ldexp(__x, __y)
Definition: tgmath.h:868
#define acosh(__x)
Definition: tgmath.h:170
#define tgamma(__x)
Definition: tgmath.h:1199
#define scalbn(__x, __y)
Definition: tgmath.h:1165
#define round(__x)
Definition: tgmath.h:1148
#define fmod(__x, __y)
Definition: tgmath.h:798
#define llrint(__x)
Definition: tgmath.h:902
#define tan(__x)
Definition: tgmath.h:315
#define cos(__x)
Definition: tgmath.h:257
#define log10(__x)
Definition: tgmath.h:936
#define fabs(__x)
Definition: tgmath.h:549
#define pow(__x, __y)
Definition: tgmath.h:490
#define log1p(__x)
Definition: tgmath.h:953
#define rint(__x)
Definition: tgmath.h:1131
#define expm1(__x)
Definition: tgmath.h:687
#define remainder(__x, __y)
Definition: tgmath.h:1090
#define fdim(__x, __y)
Definition: tgmath.h:704
#define lgamma(__x)
Definition: tgmath.h:885
#define tanh(__x)
Definition: tgmath.h:402
#define lrint(__x)
Definition: tgmath.h:1004
#define atan(__x)
Definition: tgmath.h:141
#define floor(__x)
Definition: tgmath.h:722
#define ceil(__x)
Definition: tgmath.h:601
#define log(__x)
Definition: tgmath.h:460
#define logb(__x)
Definition: tgmath.h:987
#define nearbyint(__x)
Definition: tgmath.h:1038
#define lround(__x)
Definition: tgmath.h:1021
#define fma(__x, __y, __z)
Definition: tgmath.h:742