Skip to content

Commit

Permalink
[GCC14] Avoid std::clamp in device code
Browse files Browse the repository at this point in the history
  • Loading branch information
iarspider committed Feb 5, 2025
1 parent e740ec1 commit 4d90f6a
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder {
// fill hist (bin shall be wider than "eps")
for (auto i : cms::alpakatools::uniform_elements(acc, nt)) {
int iz = static_cast<int>(zt[i] * 10.f); // valid if eps <= 0.1
iz = std::clamp(iz, INT8_MIN, INT8_MAX);
// Equivalent of iz = std::clamp(iz, INT8_MIN, INT8_MAX)
// which doesn't compile with gcc14 due to reference to __glibcxx_assert
// See https://github.com/llvm/llvm-project/issues/95183
int tmp_max = std::max<int>(iz, INT8_MIN);
iz = std::min<int>(iz, INT8_MAX);
ALPAKA_ASSERT_ACC(iz - INT8_MIN >= 0);
ALPAKA_ASSERT_ACC(iz - INT8_MIN < 256);
izt[i] = iz - INT8_MIN;
Expand Down

0 comments on commit 4d90f6a

Please sign in to comment.