You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JIT: compile kernels with -fno-math-errno, so gcc can merge repeated sqrt/pow/exp calls #834
The JIT compiles its pointwise kernels at -O3 -g0 with the platform's compiler. gcc defaults to -fmath-errno: sqrt, pow and exp may set errno, so gcc treats each call as having a side effect. It cannot merge repeated calls with the same argument, and it cannot inline sqrt without a fallback call. An expanded constitutive law repeats the same call many times, once in each place a named quantity appears. Apple clang never sets errno (the Darwin maths library does not), so kernels built on macOS do not pay this cost and kernels built on Linux do. Our kernels never read errno.
Measurement
Linux, the environment's conda-forge gcc 14.3, 2× Xeon Gold 6240R, on a machine loaded by other jobs (the times are noisy; the ratios repeat). The -fmath-errno effect is the cost of the law's pointwise callbacks per quadrature point in one Jacobian assembly, measured by swapping in a constant viscosity on the same mesh and state (scripts/sessions/jit_graph/assembly_split.py on feature/jit-graph-codegen):
With and without the flag, the assembled residual and Jacobian at a fixed state, the solutions, the residual histories and the nonlinear and linear iteration counts are bit-identical, on both fixtures. The generated C does not change.
Proposal
Always pass -fno-math-errno, alongside -std=c99, so that it is kept when UW3_JIT_CFLAGS replaces the optimisation flags. The flags are written into the generated setup.py, which is part of the JIT cache key, so every cached module recompiles once after the change.
Found while measuring the JIT graph route (#823, tier 2).
Fixed by #835 (merged to development, 76bafe4): the JIT's default compile flags are now -O3 -g0 -fno-math-errno; UW3_JIT_CFLAGS replaces them (-std=c99 stays).
Reopened under the issue rule of 2026-10-11 (PR #839): an issue whose fix has merged to development stays open, labelled fixed-in-development, and closes when the fix is released to main. Fixed by #835 (76bafe4).
Activity
Merge pull request #835 from underworldcode/feature/jit-fno-math-errno
lmoresi commentedon Oct 10, 2026
Fixed by #835 (merged to development, 76bafe4): the JIT's default compile flags are now
-O3 -g0 -fno-math-errno;UW3_JIT_CFLAGSreplaces them (-std=c99stays).lmoresi commentedon Oct 10, 2026
Reopened under the issue rule of 2026-10-11 (PR #839): an issue whose fix has merged to
developmentstays open, labelledfixed-in-development, and closes when the fix is released tomain. Fixed by #835 (76bafe4).JIT: always compile kernels with -fno-math-errno (underworldcode#834)
Review fixes for underworldcode#834: the flag is a default UW3_JIT_CF…