Skip to content

Commit 6f439f0

Browse files
authored
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
1 parent e524d1d commit 6f439f0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

hipamd/include/hip/hcc_detail/math_functions.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ THE SOFTWARE.
4747
#include "kalmar_math.h"
4848
#endif
4949

50+
#if _LIBCPP_VERSION && __HIP__
51+
namespace std {
52+
template <>
53+
struct __numeric_type<_Float16>
54+
{
55+
static _Float16 __test(_Float16);
56+
57+
typedef _Float16 type;
58+
static const bool value = true;
59+
};
60+
}
61+
#endif // _LIBCPP_VERSION
62+
5063
#pragma push_macro("__DEVICE__")
5164
#pragma push_macro("__RETURN_TYPE")
5265

0 commit comments

Comments
 (0)