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