Skip to content

Commit 1cd573e

Browse files
authored
Merge pull request #47266 from iarspider/no-std-clamp
[GCC14] Avoid std::clamp in device code
2 parents 6a35b52 + 9291eee commit 1cd573e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

RecoLocalTracker/SiPixelRecHits/interface/pixelCPEforDevice.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,11 @@ namespace pixelCPEforDevice {
379379
int high_value = kNumErrorBins - 1;
380380
int bin_value = float(kNumErrorBins) * (cp.xpos[ic] + xoff) / (2 * xoff);
381381
// return estimated bin value truncated to [0, 15]
382-
int jx = std::clamp(bin_value, low_value, high_value);
382+
// Equivalent of jx = std::clamp(bin_value, low_value, high_value)
383+
// which doesn't compile with gcc14 due to reference to __glibcxx_assert
384+
// See https://github.com/llvm/llvm-project/issues/95183
385+
int tmp_max = std::max<int>(bin_value, low_value);
386+
int jx = std::min<int>(tmp_max, high_value);
383387

384388
auto toCM = [](uint8_t x) { return float(x) * 1.e-4f; };
385389

RecoVertex/PixelVertexFinding/plugins/alpaka/clusterTracksByDensity.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder {
7676
// fill hist (bin shall be wider than "eps")
7777
for (auto i : cms::alpakatools::uniform_elements(acc, nt)) {
7878
int iz = static_cast<int>(zt[i] * 10.f); // valid if eps <= 0.1
79-
iz = std::clamp(iz, INT8_MIN, INT8_MAX);
79+
// Equivalent of iz = std::clamp(iz, INT8_MIN, INT8_MAX)
80+
// which doesn't compile with gcc14 due to reference to __glibcxx_assert
81+
// See https://github.com/llvm/llvm-project/issues/95183
82+
int tmp_max = std::max<int>(iz, INT8_MIN);
83+
iz = std::min<int>(tmp_max, INT8_MAX);
8084
ALPAKA_ASSERT_ACC(iz - INT8_MIN >= 0);
8185
ALPAKA_ASSERT_ACC(iz - INT8_MIN < 256);
8286
izt[i] = iz - INT8_MIN;

0 commit comments

Comments
 (0)