Skip to content

Commit 7f97dda

Browse files
Revert "[OpenMP][AMDGCN] Initial math headers support"
Broke nvptx compilation on files including <complex> This reverts commit 12da97e.
1 parent 3f2828d commit 7f97dda

File tree

11 files changed

+92
-276
lines changed

11 files changed

+92
-276
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,8 +1256,7 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
12561256
// If we are offloading to a target via OpenMP we need to include the
12571257
// openmp_wrappers folder which contains alternative system headers.
12581258
if (JA.isDeviceOffloading(Action::OFK_OpenMP) &&
1259-
(getToolChain().getTriple().isNVPTX() ||
1260-
getToolChain().getTriple().isAMDGCN())) {
1259+
getToolChain().getTriple().isNVPTX()){
12611260
if (!Args.hasArg(options::OPT_nobuiltininc)) {
12621261
// Add openmp_wrappers/* to our system include path. This lets us wrap
12631262
// standard library headers.

clang/lib/Headers/__clang_hip_cmath.h

Lines changed: 78 additions & 110 deletions
Large diffs are not rendered by default.

clang/lib/Headers/__clang_hip_math.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef __CLANG_HIP_MATH_H__
1010
#define __CLANG_HIP_MATH_H__
1111

12-
#if !defined(__HIP__) && !defined(__OPENMP_AMDGCN__)
12+
#if !defined(__HIP__)
1313
#error "This file is for HIP and OpenMP AMDGCN device compilation only."
1414
#endif
1515

@@ -19,27 +19,18 @@
1919
#endif
2020
#include <limits.h>
2121
#include <stdint.h>
22-
#endif // !defined(__HIPCC_RTC__)
22+
#endif // __HIPCC_RTC__
2323

2424
#pragma push_macro("__DEVICE__")
25-
26-
#ifdef __OPENMP_AMDGCN__
27-
#define __DEVICE__ static inline __attribute__((always_inline, nothrow))
28-
#else
2925
#define __DEVICE__ static __device__ inline __attribute__((always_inline))
30-
#endif
3126

3227
// A few functions return bool type starting only in C++11.
3328
#pragma push_macro("__RETURN_TYPE")
34-
#ifdef __OPENMP_AMDGCN__
35-
#define __RETURN_TYPE int
36-
#else
3729
#if defined(__cplusplus)
3830
#define __RETURN_TYPE bool
3931
#else
4032
#define __RETURN_TYPE int
4133
#endif
42-
#endif // __OPENMP_AMDGCN__
4334

4435
#if defined (__cplusplus) && __cplusplus < 201103L
4536
// emulate static_assert on type sizes
@@ -1271,15 +1262,15 @@ float min(float __x, float __y) { return fminf(__x, __y); }
12711262
__DEVICE__
12721263
double min(double __x, double __y) { return fmin(__x, __y); }
12731264

1274-
#if !defined(__HIPCC_RTC__) && !defined(__OPENMP_AMDGCN__)
1265+
#if !defined(__HIPCC_RTC__)
12751266
__host__ inline static int min(int __arg1, int __arg2) {
12761267
return std::min(__arg1, __arg2);
12771268
}
12781269

12791270
__host__ inline static int max(int __arg1, int __arg2) {
12801271
return std::max(__arg1, __arg2);
12811272
}
1282-
#endif // !defined(__HIPCC_RTC__) && !defined(__OPENMP_AMDGCN__)
1273+
#endif // __HIPCC_RTC__
12831274
#endif
12841275

12851276
#pragma pop_macro("__DEVICE__")

clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
#error "This file is for OpenMP compilation only."
1515
#endif
1616

17+
#pragma omp begin declare variant match( \
18+
device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)})
19+
1720
#ifdef __cplusplus
1821
extern "C" {
1922
#endif
2023

21-
#pragma omp begin declare variant match( \
22-
device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)})
23-
2424
#define __CUDA__
2525
#define __OPENMP_NVPTX__
2626

@@ -33,32 +33,12 @@ extern "C" {
3333
#undef __OPENMP_NVPTX__
3434
#undef __CUDA__
3535

36-
#pragma omp end declare variant
37-
38-
#pragma omp begin declare variant match(device = {arch(amdgcn)})
39-
40-
// Import types which will be used by __clang_hip_libdevice_declares.h
41-
#ifndef __cplusplus
42-
#include <stdbool.h>
43-
#include <stdint.h>
44-
#endif
45-
46-
#define __OPENMP_AMDGCN__
47-
#pragma push_macro("__device__")
48-
#define __device__
49-
50-
/// Include declarations for libdevice functions.
51-
#include <__clang_hip_libdevice_declares.h>
52-
53-
#pragma pop_macro("__device__")
54-
#undef __OPENMP_AMDGCN__
55-
56-
#pragma omp end declare variant
57-
5836
#ifdef __cplusplus
5937
} // extern "C"
6038
#endif
6139

40+
#pragma omp end declare variant
41+
6242
// Ensure we make `_ZdlPv`, aka. `operator delete(void*)` available without the
6343
// need to `include <new>` in C++ mode.
6444
#ifdef __cplusplus

clang/lib/Headers/openmp_wrappers/cmath

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -75,58 +75,4 @@ __DEVICE__ float tgamma(float __x) { return ::tgammaf(__x); }
7575

7676
#pragma omp end declare variant
7777

78-
#ifdef __AMDGCN__
79-
#pragma omp begin declare variant match(device = {arch(amdgcn)})
80-
81-
#pragma push_macro("__constant__")
82-
#define __constant__ __attribute__((constant))
83-
#define __OPENMP_AMDGCN__
84-
85-
#include <__clang_hip_cmath.h>
86-
87-
#pragma pop_macro("__constant__")
88-
#undef __OPENMP_AMDGCN__
89-
90-
// Define overloads otherwise which are absent
91-
#define __DEVICE__ static constexpr __attribute__((always_inline, nothrow))
92-
93-
__DEVICE__ float acos(float __x) { return ::acosf(__x); }
94-
__DEVICE__ float acosh(float __x) { return ::acoshf(__x); }
95-
__DEVICE__ float asin(float __x) { return ::asinf(__x); }
96-
__DEVICE__ float asinh(float __x) { return ::asinhf(__x); }
97-
__DEVICE__ float atan(float __x) { return ::atanf(__x); }
98-
__DEVICE__ float atan2(float __x, float __y) { return ::atan2f(__x, __y); }
99-
__DEVICE__ float atanh(float __x) { return ::atanhf(__x); }
100-
__DEVICE__ float cbrt(float __x) { return ::cbrtf(__x); }
101-
__DEVICE__ float cosh(float __x) { return ::coshf(__x); }
102-
__DEVICE__ float erf(float __x) { return ::erff(__x); }
103-
__DEVICE__ float erfc(float __x) { return ::erfcf(__x); }
104-
__DEVICE__ float exp2(float __x) { return ::exp2f(__x); }
105-
__DEVICE__ float expm1(float __x) { return ::expm1f(__x); }
106-
__DEVICE__ float fdim(float __x, float __y) { return ::fdimf(__x, __y); }
107-
__DEVICE__ float hypot(float __x, float __y) { return ::hypotf(__x, __y); }
108-
__DEVICE__ int ilogb(float __x) { return ::ilogbf(__x); }
109-
__DEVICE__ float ldexp(float __arg, int __exp) {
110-
return ::ldexpf(__arg, __exp);
111-
}
112-
__DEVICE__ float lgamma(float __x) { return ::lgammaf(__x); }
113-
__DEVICE__ float log1p(float __x) { return ::log1pf(__x); }
114-
__DEVICE__ float logb(float __x) { return ::logbf(__x); }
115-
__DEVICE__ float nextafter(float __x, float __y) {
116-
return ::nextafterf(__x, __y);
117-
}
118-
__DEVICE__ float remainder(float __x, float __y) {
119-
return ::remainderf(__x, __y);
120-
}
121-
__DEVICE__ float scalbn(float __x, int __y) { return ::scalbnf(__x, __y); }
122-
__DEVICE__ float sinh(float __x) { return ::sinhf(__x); }
123-
__DEVICE__ float tan(float __x) { return ::tanf(__x); }
124-
__DEVICE__ float tanh(float __x) { return ::tanhf(__x); }
125-
__DEVICE__ float tgamma(float __x) { return ::tgammaf(__x); }
126-
127-
#undef __DEVICE__
128-
129-
#pragma omp end declare variant
130-
#endif // __AMDGCN__
131-
13278
#endif

clang/lib/Headers/openmp_wrappers/math.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,4 @@
4848

4949
#pragma omp end declare variant
5050

51-
#pragma omp begin declare variant match(device = {arch(amdgcn)})
52-
53-
#define __OPENMP_AMDGCN__
54-
#include <__clang_hip_math.h>
55-
#undef __OPENMP_AMDGCN__
56-
57-
#pragma omp end declare variant
58-
5951
#endif

clang/test/Headers/Inputs/include/algorithm

Lines changed: 0 additions & 6 deletions
This file was deleted.

clang/test/Headers/Inputs/include/cstdlib

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@ float abs(float __x) { return fabs(__x); }
2727
double abs(double __x) { return fabs(__x); }
2828

2929
}
30-

clang/test/Headers/Inputs/include/utility

Lines changed: 0 additions & 2 deletions
This file was deleted.

clang/test/Headers/amdgcn_openmp_device_math.c

Lines changed: 0 additions & 51 deletions
This file was deleted.

clang/test/Headers/openmp_device_math_isnan.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
double math(float f, double d) {
2222
double r = 0;
2323
// INT_RETURN: call i32 @__nv_isnanf(float
24-
// AMD_INT_RETURN: call i32 @__ocml_isnan_f32(float
24+
// AMD_INT_RETURN: call i32 @_{{.*}}isnanf(float
2525
// BOOL_RETURN: call i32 @__nv_isnanf(float
26-
// AMD_BOOL_RETURN: call i32 @__ocml_isnan_f32(float
26+
// AMD_BOOL_RETURN: call zeroext i1 @_{{.*}}isnanf(float
2727
r += std::isnan(f);
2828
// INT_RETURN: call i32 @__nv_isnand(double
29-
// AMD_INT_RETURN: call i32 @__ocml_isnan_f64(double
29+
// AMD_INT_RETURN: call i32 @_{{.*}}isnand(double
3030
// BOOL_RETURN: call i32 @__nv_isnand(double
31-
// AMD_BOOL_RETURN: call i32 @__ocml_isnan_f64(double
31+
// AMD_BOOL_RETURN: call zeroext i1 @_{{.*}}isnand(double
3232
r += std::isnan(d);
3333
return r;
3434
}

0 commit comments

Comments
 (0)