From c636253a718395edff13e4f14174cb7dde31f56e Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Mon, 6 Apr 2020 06:05:18 -0400 Subject: [PATCH] Fix ambiguity of fma for _Float16 for libc++ (#1976) libc++ defines fma as template function for auto promotion of mixed-type arguments. libc++ does not handle _Float16 as _Float16 is not a supported type by C++ standard. As such, it is unlikely we can commit our fix for _Float16 to libc++ trunk. Therefore we handle _Float16 with a template specialization of __numeric_type in HIP headers. Change-Id: If01960a657ebf1a7a67463cdcf66fab7458dff3c [ROCm/hip commit: 4af2106d10ae5ed33fb0f8ab7d3716d0b61273bd] --- .../hip/include/hip/hcc_detail/math_functions.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/projects/hip/include/hip/hcc_detail/math_functions.h b/projects/hip/include/hip/hcc_detail/math_functions.h index 19def9ec7e..e146b1ae4f 100644 --- a/projects/hip/include/hip/hcc_detail/math_functions.h +++ b/projects/hip/include/hip/hcc_detail/math_functions.h @@ -47,6 +47,19 @@ THE SOFTWARE. #include "kalmar_math.h" #endif +#if _LIBCPP_VERSION && __HIP__ +namespace std { +template <> +struct __numeric_type<_Float16> +{ + static _Float16 __test(_Float16); + + typedef _Float16 type; + static const bool value = true; +}; +} +#endif // _LIBCPP_VERSION + #pragma push_macro("__DEVICE__") #pragma push_macro("__RETURN_TYPE")