[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
This commit is contained in:
Michael Liao 2021-01-07 05:24:12 -05:00
parent 2cbbc6e87c
commit f78d6af731
1 changed files with 28 additions and 0 deletions

View File

@ -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__