__clang_cuda_math_forward_declares.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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. // This file forward-declares of some math functions we (or the CUDA headers)
  29. // will define later. We need to do this, and do it before cmath is included,
  30. // because the standard library may have constexpr math functions. In the
  31. // absence of a prior __device__ decl, those constexpr functions may become
  32. // implicitly host+device. host+device functions can't be overloaded, so that
  33. // would preclude the use of our own __device__ overloads for these functions.
  34. #pragma push_macro("__DEVICE__")
  35. #define __DEVICE__ \
  36. static __inline__ __attribute__((always_inline)) __attribute__((device))
  37. __DEVICE__ double abs(double);
  38. __DEVICE__ float abs(float);
  39. __DEVICE__ int abs(int);
  40. __DEVICE__ long abs(long);
  41. __DEVICE__ long long abs(long long);
  42. __DEVICE__ double acos(double);
  43. __DEVICE__ float acos(float);
  44. __DEVICE__ double acosh(double);
  45. __DEVICE__ float acosh(float);
  46. __DEVICE__ double asin(double);
  47. __DEVICE__ float asin(float);
  48. __DEVICE__ double asinh(double);
  49. __DEVICE__ float asinh(float);
  50. __DEVICE__ double atan2(double, double);
  51. __DEVICE__ float atan2(float, float);
  52. __DEVICE__ double atan(double);
  53. __DEVICE__ float atan(float);
  54. __DEVICE__ double atanh(double);
  55. __DEVICE__ float atanh(float);
  56. __DEVICE__ double cbrt(double);
  57. __DEVICE__ float cbrt(float);
  58. __DEVICE__ double ceil(double);
  59. __DEVICE__ float ceil(float);
  60. __DEVICE__ double copysign(double, double);
  61. __DEVICE__ float copysign(float, float);
  62. __DEVICE__ double cos(double);
  63. __DEVICE__ float cos(float);
  64. __DEVICE__ double cosh(double);
  65. __DEVICE__ float cosh(float);
  66. __DEVICE__ double erfc(double);
  67. __DEVICE__ float erfc(float);
  68. __DEVICE__ double erf(double);
  69. __DEVICE__ float erf(float);
  70. __DEVICE__ double exp2(double);
  71. __DEVICE__ float exp2(float);
  72. __DEVICE__ double exp(double);
  73. __DEVICE__ float exp(float);
  74. __DEVICE__ double expm1(double);
  75. __DEVICE__ float expm1(float);
  76. __DEVICE__ double fabs(double);
  77. __DEVICE__ float fabs(float);
  78. __DEVICE__ double fdim(double, double);
  79. __DEVICE__ float fdim(float, float);
  80. __DEVICE__ double floor(double);
  81. __DEVICE__ float floor(float);
  82. __DEVICE__ double fma(double, double, double);
  83. __DEVICE__ float fma(float, float, float);
  84. __DEVICE__ double fmax(double, double);
  85. __DEVICE__ float fmax(float, float);
  86. __DEVICE__ double fmin(double, double);
  87. __DEVICE__ float fmin(float, float);
  88. __DEVICE__ double fmod(double, double);
  89. __DEVICE__ float fmod(float, float);
  90. __DEVICE__ int fpclassify(double);
  91. __DEVICE__ int fpclassify(float);
  92. __DEVICE__ double frexp(double, int *);
  93. __DEVICE__ float frexp(float, int *);
  94. __DEVICE__ double hypot(double, double);
  95. __DEVICE__ float hypot(float, float);
  96. __DEVICE__ int ilogb(double);
  97. __DEVICE__ int ilogb(float);
  98. __DEVICE__ bool isfinite(double);
  99. __DEVICE__ bool isfinite(float);
  100. __DEVICE__ bool isgreater(double, double);
  101. __DEVICE__ bool isgreaterequal(double, double);
  102. __DEVICE__ bool isgreaterequal(float, float);
  103. __DEVICE__ bool isgreater(float, float);
  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. __DEVICE__ bool isnan(double);
  113. __DEVICE__ bool isnan(float);
  114. __DEVICE__ bool isnormal(double);
  115. __DEVICE__ bool isnormal(float);
  116. __DEVICE__ bool isunordered(double, double);
  117. __DEVICE__ bool isunordered(float, float);
  118. __DEVICE__ long labs(long);
  119. __DEVICE__ double ldexp(double, int);
  120. __DEVICE__ float ldexp(float, int);
  121. __DEVICE__ double lgamma(double);
  122. __DEVICE__ float lgamma(float);
  123. __DEVICE__ long long llabs(long long);
  124. __DEVICE__ long long llrint(double);
  125. __DEVICE__ long long llrint(float);
  126. __DEVICE__ double log10(double);
  127. __DEVICE__ float log10(float);
  128. __DEVICE__ double log1p(double);
  129. __DEVICE__ float log1p(float);
  130. __DEVICE__ double log2(double);
  131. __DEVICE__ float log2(float);
  132. __DEVICE__ double logb(double);
  133. __DEVICE__ float logb(float);
  134. __DEVICE__ double log(double);
  135. __DEVICE__ float log(float);
  136. __DEVICE__ long lrint(double);
  137. __DEVICE__ long lrint(float);
  138. __DEVICE__ long lround(double);
  139. __DEVICE__ long lround(float);
  140. __DEVICE__ long long llround(float); // No llround(double).
  141. __DEVICE__ double modf(double, double *);
  142. __DEVICE__ float modf(float, float *);
  143. __DEVICE__ double nan(const char *);
  144. __DEVICE__ float nanf(const char *);
  145. __DEVICE__ double nearbyint(double);
  146. __DEVICE__ float nearbyint(float);
  147. __DEVICE__ double nextafter(double, double);
  148. __DEVICE__ float nextafter(float, float);
  149. __DEVICE__ double pow(double, double);
  150. __DEVICE__ double pow(double, int);
  151. __DEVICE__ float pow(float, float);
  152. __DEVICE__ float pow(float, int);
  153. __DEVICE__ double remainder(double, double);
  154. __DEVICE__ float remainder(float, float);
  155. __DEVICE__ double remquo(double, double, int *);
  156. __DEVICE__ float remquo(float, float, int *);
  157. __DEVICE__ double rint(double);
  158. __DEVICE__ float rint(float);
  159. __DEVICE__ double round(double);
  160. __DEVICE__ float round(float);
  161. __DEVICE__ double scalbln(double, long);
  162. __DEVICE__ float scalbln(float, long);
  163. __DEVICE__ double scalbn(double, int);
  164. __DEVICE__ float scalbn(float, int);
  165. __DEVICE__ bool signbit(double);
  166. __DEVICE__ bool signbit(float);
  167. __DEVICE__ double sin(double);
  168. __DEVICE__ float sin(float);
  169. __DEVICE__ double sinh(double);
  170. __DEVICE__ float sinh(float);
  171. __DEVICE__ double sqrt(double);
  172. __DEVICE__ float sqrt(float);
  173. __DEVICE__ double tan(double);
  174. __DEVICE__ float tan(float);
  175. __DEVICE__ double tanh(double);
  176. __DEVICE__ float tanh(float);
  177. __DEVICE__ double tgamma(double);
  178. __DEVICE__ float tgamma(float);
  179. __DEVICE__ double trunc(double);
  180. __DEVICE__ float trunc(float);
  181. // Notably missing above is nexttoward, which we don't define on
  182. // the device side because libdevice doesn't give us an implementation, and we
  183. // don't want to be in the business of writing one ourselves.
  184. // We need to define these overloads in exactly the namespace our standard
  185. // library uses (including the right inline namespace), otherwise they won't be
  186. // picked up by other functions in the standard library (e.g. functions in
  187. // <complex>). Thus the ugliness below.
  188. #ifdef _LIBCPP_BEGIN_NAMESPACE_STD
  189. _LIBCPP_BEGIN_NAMESPACE_STD
  190. #else
  191. namespace std {
  192. #ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
  193. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  194. #endif
  195. #endif
  196. using ::abs;
  197. using ::acos;
  198. using ::acosh;
  199. using ::asin;
  200. using ::asinh;
  201. using ::atan;
  202. using ::atan2;
  203. using ::atanh;
  204. using ::cbrt;
  205. using ::ceil;
  206. using ::copysign;
  207. using ::cos;
  208. using ::cosh;
  209. using ::erf;
  210. using ::erfc;
  211. using ::exp;
  212. using ::exp2;
  213. using ::expm1;
  214. using ::fabs;
  215. using ::fdim;
  216. using ::floor;
  217. using ::fma;
  218. using ::fmax;
  219. using ::fmin;
  220. using ::fmod;
  221. using ::fpclassify;
  222. using ::frexp;
  223. using ::hypot;
  224. using ::ilogb;
  225. using ::isfinite;
  226. using ::isgreater;
  227. using ::isgreaterequal;
  228. using ::isinf;
  229. using ::isless;
  230. using ::islessequal;
  231. using ::islessgreater;
  232. using ::isnan;
  233. using ::isnormal;
  234. using ::isunordered;
  235. using ::labs;
  236. using ::ldexp;
  237. using ::lgamma;
  238. using ::llabs;
  239. using ::llrint;
  240. using ::log;
  241. using ::log10;
  242. using ::log1p;
  243. using ::log2;
  244. using ::logb;
  245. using ::lrint;
  246. using ::lround;
  247. using ::llround;
  248. using ::modf;
  249. using ::nan;
  250. using ::nanf;
  251. using ::nearbyint;
  252. using ::nextafter;
  253. using ::pow;
  254. using ::remainder;
  255. using ::remquo;
  256. using ::rint;
  257. using ::round;
  258. using ::scalbln;
  259. using ::scalbn;
  260. using ::signbit;
  261. using ::sin;
  262. using ::sinh;
  263. using ::sqrt;
  264. using ::tan;
  265. using ::tanh;
  266. using ::tgamma;
  267. using ::trunc;
  268. #ifdef _LIBCPP_END_NAMESPACE_STD
  269. _LIBCPP_END_NAMESPACE_STD
  270. #else
  271. #ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
  272. _GLIBCXX_END_NAMESPACE_VERSION
  273. #endif
  274. } // namespace std
  275. #endif
  276. #pragma pop_macro("__DEVICE__")
  277. #endif