File: cmath

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (132 lines) | stat: -rw-r--r-- 5,252 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*===-- __clang_openmp_device_functions.h - OpenMP math declares ------ c++ -===
 *
 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 * See https://llvm.org/LICENSE.txt for license information.
 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 *
 *===-----------------------------------------------------------------------===
 */

#ifndef __CLANG_OPENMP_CMATH_H__
#define __CLANG_OPENMP_CMATH_H__

#ifndef _OPENMP
#error "This file is for OpenMP compilation only."
#endif

#include_next <cmath>

// Make sure we include our math.h overlay, it probably happend already but we
// need to be sure.
#include <math.h>

// We (might) need cstdlib because __clang_cuda_cmath.h below declares `abs`
// which might live in cstdlib.
#include <cstdlib>

// We need limits because __clang_cuda_cmath.h below uses `std::numeric_limit`.
#include <limits>

#pragma omp begin declare variant match(                                       \
    device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any, allow_templates)})

#define __CUDA__
#define __OPENMP_NVPTX__
#include <__clang_cuda_cmath.h>
#undef __OPENMP_NVPTX__
#undef __CUDA__

// Overloads not provided by the CUDA wrappers but by the CUDA system headers.
// Since we do not include the latter we define them ourselves.
#define __DEVICE__ static constexpr __attribute__((always_inline, nothrow))

__DEVICE__ float acosh(float __x) { return ::acoshf(__x); }
__DEVICE__ float asinh(float __x) { return ::asinhf(__x); }
__DEVICE__ float atanh(float __x) { return ::atanhf(__x); }
__DEVICE__ float cbrt(float __x) { return ::cbrtf(__x); }
__DEVICE__ float erf(float __x) { return ::erff(__x); }
__DEVICE__ float erfc(float __x) { return ::erfcf(__x); }
__DEVICE__ float exp2(float __x) { return ::exp2f(__x); }
__DEVICE__ float expm1(float __x) { return ::expm1f(__x); }
__DEVICE__ float fdim(float __x, float __y) { return ::fdimf(__x, __y); }
__DEVICE__ float hypot(float __x, float __y) { return ::hypotf(__x, __y); }
__DEVICE__ int ilogb(float __x) { return ::ilogbf(__x); }
__DEVICE__ float lgamma(float __x) { return ::lgammaf(__x); }
__DEVICE__ long long int llrint(float __x) { return ::llrintf(__x); }
__DEVICE__ long long int llround(float __x) { return ::llroundf(__x); }
__DEVICE__ float log1p(float __x) { return ::log1pf(__x); }
__DEVICE__ float log2(float __x) { return ::log2f(__x); }
__DEVICE__ float logb(float __x) { return ::logbf(__x); }
__DEVICE__ long int lrint(float __x) { return ::lrintf(__x); }
__DEVICE__ long int lround(float __x) { return ::lroundf(__x); }
__DEVICE__ float nextafter(float __x, float __y) {
  return ::nextafterf(__x, __y);
}
__DEVICE__ float remainder(float __x, float __y) {
  return ::remainderf(__x, __y);
}
__DEVICE__ float scalbln(float __x, long int __y) {
  return ::scalblnf(__x, __y);
}
__DEVICE__ float scalbn(float __x, int __y) { return ::scalbnf(__x, __y); }
__DEVICE__ float tgamma(float __x) { return ::tgammaf(__x); }

#undef __DEVICE__

#pragma omp end declare variant

#ifdef __AMDGCN__
#pragma omp begin declare variant match(device = {arch(amdgcn)})

#pragma push_macro("__constant__")
#define __constant__ __attribute__((constant))
#define __OPENMP_AMDGCN__

#include <__clang_hip_cmath.h>

#pragma pop_macro("__constant__")
#undef __OPENMP_AMDGCN__

// Define overloads otherwise which are absent
#define __DEVICE__ static constexpr __attribute__((always_inline, nothrow))

__DEVICE__ float acos(float __x) { return ::acosf(__x); }
__DEVICE__ float acosh(float __x) { return ::acoshf(__x); }
__DEVICE__ float asin(float __x) { return ::asinf(__x); }
__DEVICE__ float asinh(float __x) { return ::asinhf(__x); }
__DEVICE__ float atan(float __x) { return ::atanf(__x); }
__DEVICE__ float atan2(float __x, float __y) { return ::atan2f(__x, __y); }
__DEVICE__ float atanh(float __x) { return ::atanhf(__x); }
__DEVICE__ float cbrt(float __x) { return ::cbrtf(__x); }
__DEVICE__ float cosh(float __x) { return ::coshf(__x); }
__DEVICE__ float erf(float __x) { return ::erff(__x); }
__DEVICE__ float erfc(float __x) { return ::erfcf(__x); }
__DEVICE__ float exp2(float __x) { return ::exp2f(__x); }
__DEVICE__ float expm1(float __x) { return ::expm1f(__x); }
__DEVICE__ float fdim(float __x, float __y) { return ::fdimf(__x, __y); }
__DEVICE__ float hypot(float __x, float __y) { return ::hypotf(__x, __y); }
__DEVICE__ int ilogb(float __x) { return ::ilogbf(__x); }
__DEVICE__ float ldexp(float __arg, int __exp) {
  return ::ldexpf(__arg, __exp);
}
__DEVICE__ float lgamma(float __x) { return ::lgammaf(__x); }
__DEVICE__ float log1p(float __x) { return ::log1pf(__x); }
__DEVICE__ float logb(float __x) { return ::logbf(__x); }
__DEVICE__ float nextafter(float __x, float __y) {
  return ::nextafterf(__x, __y);
}
__DEVICE__ float remainder(float __x, float __y) {
  return ::remainderf(__x, __y);
}
__DEVICE__ float scalbn(float __x, int __y) { return ::scalbnf(__x, __y); }
__DEVICE__ float sinh(float __x) { return ::sinhf(__x); }
__DEVICE__ float tan(float __x) { return ::tanf(__x); }
__DEVICE__ float tanh(float __x) { return ::tanhf(__x); }
__DEVICE__ float tgamma(float __x) { return ::tgammaf(__x); }

#undef __DEVICE__

#pragma omp end declare variant
#endif // __AMDGCN__

#endif