Skip to content

Commit 48644cc

Browse files
doru1004ronlieb
authored andcommitted
Fix issue with tan while inlining cmath functions
Change-Id: Ie5420c27981a7ee143432b83244223a48bdd4f5e
1 parent 1d9e4d4 commit 48644cc

File tree

1 file changed

+48
-2
lines changed
  • clang/lib/Headers/openmp_wrappers

1 file changed

+48
-2
lines changed

clang/lib/Headers/openmp_wrappers/cmath

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,59 @@ __DEVICE__ float tgamma(float __x) { return ::tgammaf(__x); }
7979
#endif // __NVPTX__
8080

8181
#ifdef __AMDGCN__
82-
#pragma omp begin declare variant match( \
83-
device = {arch(amdgcn)}, implementation = {extension(match_any, allow_templates)})
82+
#pragma omp begin declare variant match(device = {arch(amdgcn)})
83+
84+
#pragma push_macro("__constant__")
85+
#define __constant__ __attribute__((constant))
86+
8487
#define __HIP__
8588
#define __OPENMP_AMDGCN__
89+
8690
#include <__clang_hip_cmath.h>
91+
92+
#pragma pop_macro("__constant__")
93+
#undef __OPENMP_AMDGCN__
8794
#undef __HIP__
8895

96+
// Define overloads otherwise which are absent
97+
#define __DEVICE__ static constexpr __attribute__((always_inline, nothrow))
98+
99+
__DEVICE__ float acos(float __x) { return ::acosf(__x); }
100+
__DEVICE__ float acosh(float __x) { return ::acoshf(__x); }
101+
__DEVICE__ float asin(float __x) { return ::asinf(__x); }
102+
__DEVICE__ float asinh(float __x) { return ::asinhf(__x); }
103+
__DEVICE__ float atan(float __x) { return ::atanf(__x); }
104+
__DEVICE__ float atan2(float __x, float __y) { return ::atan2f(__x, __y); }
105+
__DEVICE__ float atanh(float __x) { return ::atanhf(__x); }
106+
__DEVICE__ float cbrt(float __x) { return ::cbrtf(__x); }
107+
__DEVICE__ float cosh(float __x) { return ::coshf(__x); }
108+
__DEVICE__ float erf(float __x) { return ::erff(__x); }
109+
__DEVICE__ float erfc(float __x) { return ::erfcf(__x); }
110+
__DEVICE__ float exp2(float __x) { return ::exp2f(__x); }
111+
__DEVICE__ float expm1(float __x) { return ::expm1f(__x); }
112+
__DEVICE__ float fdim(float __x, float __y) { return ::fdimf(__x, __y); }
113+
__DEVICE__ float hypot(float __x, float __y) { return ::hypotf(__x, __y); }
114+
__DEVICE__ int ilogb(float __x) { return ::ilogbf(__x); }
115+
__DEVICE__ float ldexp(float __arg, int __exp) {
116+
return ::ldexpf(__arg, __exp);
117+
}
118+
__DEVICE__ float lgamma(float __x) { return ::lgammaf(__x); }
119+
__DEVICE__ float log1p(float __x) { return ::log1pf(__x); }
120+
__DEVICE__ float logb(float __x) { return ::logbf(__x); }
121+
__DEVICE__ float nextafter(float __x, float __y) {
122+
return ::nextafterf(__x, __y);
123+
}
124+
__DEVICE__ float remainder(float __x, float __y) {
125+
return ::remainderf(__x, __y);
126+
}
127+
__DEVICE__ float scalbn(float __x, int __y) { return ::scalbnf(__x, __y); }
128+
__DEVICE__ float sinh(float __x) { return ::sinhf(__x); }
129+
__DEVICE__ float tan(float __x) { return ::tanf(__x); }
130+
__DEVICE__ float tanh(float __x) { return ::tanhf(__x); }
131+
__DEVICE__ float tgamma(float __x) { return ::tgammaf(__x); }
132+
133+
#undef __DEVICE__
134+
89135
#pragma omp end declare variant
90136
#endif // __AMDGCN__
91137

0 commit comments

Comments
 (0)