Skip to content

Commit 36e82f2

Browse files
[SYCL] Try to fix MacOS build after #11956 (#12444)
MacOS' STL is not standard-conformant, try to workaround for that in our code.
1 parent 6501156 commit 36e82f2

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

sycl/source/builtins/relational_functions.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
namespace sycl {
1717
inline namespace _V1 {
1818

19+
template <typename T> static auto process_arg_for_macos(T x) {
20+
// Workaround for MacOS that doesn't provide some std::is* functions as
21+
// overloads over FP types (e.g., isfinite)
22+
if constexpr (std::is_same_v<T, half>)
23+
return static_cast<float>(x);
24+
else
25+
return x;
26+
}
27+
1928
#if defined(__GNUC__) && !defined(__clang__)
2029
// sycl::vec has UB in operator[] (aliasing violation) that causes the following
2130
// warning here. Note that the way this #pragma works is that we have to put it
@@ -36,7 +45,9 @@ inline namespace _V1 {
3645
} \
3746
EXPORT_SCALAR_AND_VEC_1_16(NUM_ARGS, NAME, FP_TYPES)
3847
#define REL_BUILTIN(NUM_ARGS, NAME) \
39-
REL_BUILTIN_CUSTOM(NUM_ARGS, NAME, std::NAME)
48+
REL_BUILTIN_CUSTOM(NUM_ARGS, NAME, [](auto... xs) { \
49+
return std::NAME(process_arg_for_macos(xs)...); \
50+
})
4051

4152
#if defined(__GNUC__) && !defined(__clang__)
4253
#pragma GCC diagnostic pop
@@ -57,10 +68,9 @@ REL_BUILTIN(ONE_ARG, isfinite)
5768
REL_BUILTIN(ONE_ARG, isinf)
5869
REL_BUILTIN(ONE_ARG, isnan)
5970
REL_BUILTIN(ONE_ARG, isnormal)
71+
REL_BUILTIN(TWO_ARGS, isunordered)
6072
REL_BUILTIN_CUSTOM(TWO_ARGS, isordered,
61-
([](auto x, auto y) { return !std::isunordered(x, y); }))
62-
REL_BUILTIN_CUSTOM(TWO_ARGS, isunordered,
63-
([](auto x, auto y) { return std::isunordered(x, y); }))
73+
([](auto x, auto y) { return !sycl::isunordered(x, y); }))
6474
#if defined(__GNUC__) && !defined(__clang__)
6575
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112816
6676
#pragma GCC push_options

0 commit comments

Comments
 (0)