Skip to content

Commit 211f64d

Browse files
authored
[SYCLomatic] Using static_cast when calling sycl::max/min (#1957)
Signed-off-by: Jiang, Zhiwei <[email protected]>
1 parent 31d0bbf commit 211f64d

File tree

1 file changed

+8
-4
lines changed
  • clang/runtime/dpct-rt/include/dpct

1 file changed

+8
-4
lines changed

clang/runtime/dpct-rt/include/dpct/math.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,25 +419,29 @@ template <typename T1, typename T2>
419419
std::enable_if_t<std::is_integral_v<T1> && std::is_integral_v<T2>,
420420
std::common_type_t<T1, T2>>
421421
min(T1 a, T2 b) {
422-
return sycl::min<std::common_type_t<T1, T2>>(a, b);
422+
using common_t = std::common_type_t<T1, T2>;
423+
return sycl::min(static_cast<common_t>(a), static_cast<common_t>(b));
423424
}
424425
template <typename T1, typename T2>
425426
std::enable_if_t<std::is_floating_point_v<T1> && std::is_floating_point_v<T2>,
426427
std::common_type_t<T1, T2>>
427428
min(T1 a, T2 b) {
428-
return sycl::fmin<std::common_type_t<T1, T2>>(a, b);
429+
using common_t = std::common_type_t<T1, T2>;
430+
return sycl::fmin(static_cast<common_t>(a), static_cast<common_t>(b));
429431
}
430432
template <typename T1, typename T2>
431433
std::enable_if_t<std::is_integral_v<T1> && std::is_integral_v<T2>,
432434
std::common_type_t<T1, T2>>
433435
max(T1 a, T2 b) {
434-
return sycl::max<std::common_type_t<T1, T2>>(a, b);
436+
using common_t = std::common_type_t<T1, T2>;
437+
return sycl::max(static_cast<common_t>(a), static_cast<common_t>(b));
435438
}
436439
template <typename T1, typename T2>
437440
std::enable_if_t<std::is_floating_point_v<T1> && std::is_floating_point_v<T2>,
438441
std::common_type_t<T1, T2>>
439442
max(T1 a, T2 b) {
440-
return sycl::fmax<std::common_type_t<T1, T2>>(a, b);
443+
using common_t = std::common_type_t<T1, T2>;
444+
return sycl::fmax(static_cast<common_t>(a), static_cast<common_t>(b));
441445
}
442446

443447
// pow functions overload.

0 commit comments

Comments
 (0)