From b145c9549806207a27aac499b1110f7e3810d5e6 Mon Sep 17 00:00:00 2001 From: Bruno Turcksin Date: Fri, 22 Nov 2024 16:10:37 -0500 Subject: [PATCH] Workaround rocm 5.7 compiler bug in debug mode when evaluating an if condition --- source/base/polynomials_piecewise.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/base/polynomials_piecewise.cc b/source/base/polynomials_piecewise.cc index 0514f334b2..67e96a0fab 100644 --- a/source/base/polynomials_piecewise.cc +++ b/source/base/polynomials_piecewise.cc @@ -139,7 +139,16 @@ namespace Polynomials else { const double offset = step * interval; - if (x < offset || x > offset + step) + // ROCm 5.7 throw a floating point exception in debug when trying to + // evaluate (x < offset && x > offset + step). Separating the + // conditions fixes the issue. + if (x < offset) + { + for (unsigned int k = 0; k <= n_derivatives; ++k) + values[k] = 0; + return; + } + else if (x > offset + step) { for (unsigned int k = 0; k <= n_derivatives; ++k) values[k] = 0; -- 2.39.5