]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Workaround rocm 5.7 compiler bug in debug mode when evaluating an if condition
authorBruno Turcksin <bruno.turcksin@gmail.com>
Fri, 22 Nov 2024 21:10:37 +0000 (16:10 -0500)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Tue, 3 Dec 2024 02:46:18 +0000 (21:46 -0500)
source/base/polynomials_piecewise.cc

index 0514f334b22586bc1d728f1e95410fc1c8a333e4..67e96a0fabf16e7c9c936496f9c0d6a3da00b904 100644 (file)
@@ -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;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.