Skip to content

Fix floating-point traps found by the checked CPU build - #2516

Open
sbryngelson wants to merge 2 commits into
MFlowCode:masterfrom
sbryngelson:fix-runtime-traps
Open

sbryngelson wants to merge 2 commits into
MFlowCode:masterfrom
sbryngelson:fix-runtime-traps

Conversation

@sbryngelson

@sbryngelson sbryngelson commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Part of #2510. The checked CPU build (#2447) stops some of the suite's tests on a floating-point exception. This fixes the ones that are MFC's, and builds the AMD flang check at -O0 so the optimiser's speculated divisions stop counting as traps.

Source fixes

None of these changes a golden file; most remove NaN or Inf computed in cells or faces whose results are never used.

  • m_variables_conversion.fpp: alpha_K = alpha_K/sum normalised the whole dummy, which AMD flang without case optimisation declares with 3 elements, more than a 2-fluid caller passes. Now alpha_K(1:num_fluids). A real out-of-bounds write; 52 tests trapped here.
  • m_time_steppers.fpp:
  • m_particles_EL.fpp: the Lagrange drag computes the fluid temperature (dividing by cv) only when a Sutherland constant needs it; the validator already requires cv > 0 then.
  • m_rhs.fpp:
    • the viscous face states start zeroed. With weno_Re_flux, the gradient's two outermost ghost cells are computed from faces the reconstruction never writes (±1.5e202 in 2A6136EF), and the WENO pass over the gradient overflowed on them;
    • mpp_lim with bubbles skips the volume-fraction renormalisation in ghost cells whose fractions sum to zero (unfilled before the first boundary fill).
  • m_ibm.fpp (s_ibm_correct_state): drop the hypoelastic mixture call that read an unset shear-modulus array for a G_K nothing used; the same pattern Fix the floating-point traps the debug build hits in 8 AMR tests #2438 removed from s_compute_cell_state.
  • m_rhs.fpp (s_body_faces_take_cell_states): before the Riemann solve, a face between two body cells takes its cells' own states. Only body cells see that face, and s_zero_rhs_at_body discards their RHS, but WENO across a thin injecting body undershot to a negative density there.

Build and CI

  • cmake/GPU.cmake: the AMD flang checked CPU build is -O0. At -O1 this flang evaluates divisions guarded by an if before the test (seen in the machine code of m_chemistry.fpp and m_particles_EL.fpp), and it accepts no flag that forbids it. This took the count from 84 to 18 tests.
  • checks.yml: at -O0 the suite takes about 2 h, over the job's 1.5 h SLURM limit, so the weekly AMD job builds every variant once and runs two shards side by side.
  • troubleshooting.md: the flags table says -O0.

Fixed elsewhere

Testing

On Frontier, AMD flang checked CPU build at -O0, rebased on master 5eadc8fa7 (with #2515 and #2517): all 16 tests that trapped pass, against unchanged golden files.

Tests Trap Fixed by
E5ACA113 mpp_lim bubbles this PR
AA36F5D2, BA59123E, 8DDB767E hypoelastic IBM this PR
2A6136EF, 304DAF95, 5304E59F, A582B270, D3CF92B5 viscous WENO this PR
39A3B369, B317404C, E5B66084 injecting body this PR
5334FF40, D7E7DE04 moment of inertia #2514
07C33719, 09623DE3 cylindrical axis #2515

./mfc.sh precheck passes.

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Claude Code Review

Head SHA: 646cb70

No review was produced. Claude ran but wrote no review (Claude step: failure). Run and transcript: https://github.com/MFlowCode/MFC/actions/runs/45871204398

@sbryngelson

Copy link
Copy Markdown
Member Author

Closing for now; the remaining traps from #2510 will go in the same PR.

@sbryngelson sbryngelson reopened this Nov 26, 2026
@sbryngelson
sbryngelson force-pushed the fix-runtime-traps branch 2 times, most recently from 86bacd4 to 9c6a927 Compare November 26, 2026 18:03
@codecov

codecov Bot commented Nov 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.60%. Comparing base (c158eee) to head (9c6a927).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/simulation/m_rhs.fpp 78.94% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2516   +/-   ##
=======================================
  Coverage   66.59%   66.60%           
=======================================
  Files         112      112           
  Lines       31558    31572   +14     
  Branches     4856     4858    +2     
=======================================
+ Hits        21015    21027   +12     
  Misses       6561     6561           
- Partials     3982     3984    +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

sbryngelson added a commit that referenced this pull request Nov 26, 2026
…submitting a copy (#2523)

A timed-out sbatch can still queue the job. retry_sbatch then submitted it again, and on
Phoenix both copies of shard 1 ran in the same checkout and deleted each other's test inputs
(75 failures in #2516's gpu-acc run). Before retrying, look for a pending or running job of
ours with the same name, from this directory, submitted since the first attempt.
- alpha_K normalisation touches only the fluids (it wrote past a 2-fluid caller's array with AMD flang).
- Adaptive-dt Euler bubbles convert the interior only before the first RHS.
- Lagrange drag computes the fluid temperature only when Sutherland needs it.
- Acceleration probe time levels start zeroed.
- Viscous face states start zeroed: the gradient's outer ghost cells read faces the reconstruction never writes.
- s_ibm_correct_state: drop the hypoelastic mixture call that read an unset shear modulus for an unused result.
- mpp_lim bubbles: skip the renormalisation in ghost cells whose fractions sum to zero before the first fill.
- AMD flang checked CPU build at -O0; the weekly job builds once and runs two shards.
… traps)

At a face whose two cells are both inside a body, the reconstructed states are replaced by the cells' own, in one
loop in m_rhs before the Riemann solver. Only body cells see such a face and s_zero_rhs_at_body discards their RHS,
but WENO across a two-cell sliver gave a negative density there (MFlowCode#2510, 39A3B369, B317404C, E5B66084).
@github-actions

Copy link
Copy Markdown

Lines of Code

File Lines Diff
src/simulation/m_rhs.fpp 2213 +32
src/simulation/m_ibm.fpp 4435 -8
src/simulation/m_time_steppers.fpp 1052 -2
Directory Lines Diff
simulation 42792 +22
total 62848 +22

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant