[llvm-branch-commits] [clang] f78d6af - [hip] Enable HIP compilation with `<complex`> on MSVC.
Michael Liao via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jan 7 14:45:48 PST 2021
Author: Michael Liao
Date: 2021-01-07T17:41:28-05:00
New Revision: f78d6af7319aa676a0f9f6cbb982f21c96e9aac5
URL: https://github.com/llvm/llvm-project/commit/f78d6af7319aa676a0f9f6cbb982f21c96e9aac5
DIFF: https://github.com/llvm/llvm-project/commit/f78d6af7319aa676a0f9f6cbb982f21c96e9aac5.diff
LOG: [hip] Enable HIP compilation with `<complex`> on MSVC.
- MSVC has different `<complex>` implementation which calls into functions
declared in `<ymath.h>`. Provide their device-side implementation to enable
`<complex>` compilation on HIP Windows.
Differential Revision: https://reviews.llvm.org/D93638
Added:
Modified:
clang/lib/Headers/__clang_hip_cmath.h
Removed:
################################################################################
diff --git a/clang/lib/Headers/__clang_hip_cmath.h b/clang/lib/Headers/__clang_hip_cmath.h
index 3a702587ee17..128d64e271b8 100644
--- a/clang/lib/Headers/__clang_hip_cmath.h
+++ b/clang/lib/Headers/__clang_hip_cmath.h
@@ -624,6 +624,34 @@ _GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
+// Define device-side math functions from <ymath.h> on MSVC.
+#if defined(_MSC_VER)
+#if defined(__cplusplus)
+extern "C" {
+#endif // defined(__cplusplus)
+__DEVICE__ __attribute__((overloadable)) double _Cosh(double x, double y) {
+ return cosh(x) * y;
+}
+__DEVICE__ __attribute__((overloadable)) float _FCosh(float x, float y) {
+ return coshf(x) * y;
+}
+__DEVICE__ __attribute__((overloadable)) short _Dtest(double *p) {
+ return fpclassify(*p);
+}
+__DEVICE__ __attribute__((overloadable)) short _FDtest(float *p) {
+ return fpclassify(*p);
+}
+__DEVICE__ __attribute__((overloadable)) double _Sinh(double x, double y) {
+ return sinh(x) * y;
+}
+__DEVICE__ __attribute__((overloadable)) float _FSinh(float x, float y) {
+ return sinhf(x) * y;
+}
+#if defined(__cplusplus)
+}
+#endif // defined(__cplusplus)
+#endif // defined(_MSC_VER)
+
#pragma pop_macro("__DEVICE__")
#endif // __CLANG_HIP_CMATH_H__
More information about the llvm-branch-commits
mailing list