Skip to content

improve: sharper Verrou dd_line attribution (source filter, function scope, -fno-inline)#1437

Merged
sbryngelson merged 3 commits into
MFlowCode:masterfrom
sbryngelson:improve/verrou-attribution
May 14, 2026
Merged

improve: sharper Verrou dd_line attribution (source filter, function scope, -fno-inline)#1437
sbryngelson merged 3 commits into
MFlowCode:masterfrom
sbryngelson:improve/verrou-attribution

Conversation

@sbryngelson
Copy link
Copy Markdown
Member

@sbryngelson sbryngelson commented May 13, 2026

Summary

Verrou dd_line sometimes reports loop boundaries (end do, #:endfor, $:END_GPU_PARALLEL_LOOP) or inlined-function call sites instead of the actual arithmetic responsible for FP instability. Three targeted fixes:

  • Source-line content filter (_CONTROL_FLOW_RE / _is_arithmetic_loc): after dd_line produces its rddmin_summary, each reported location is checked against the actual .fpp source line. Pure control-flow delimiters that share DWARF debug info with the preceding arithmetic (loop boundaries, fypp directive closers, blank/comment lines) are dropped with a diagnostic note.

  • Restrict dd_line scope to dd_sym functions (restrict_syms in _write_dd_run_sh / _run_dd_line): when dd_sym has already identified the responsible functions, the generated dd_line_run.sh embeds --source-function=<sym> flags so Verrou only perturbs FP operations inside those functions. This prevents the bisection from landing on #:for-template lines shared across loop iterations or code inlined from unrelated callees.

  • FFLAGS=-fno-inline in fp-stability.yml: prevents gfortran from inlining small helpers (e.g. s_compute_speed_of_sound) into their callers. Without this, DWARF attributes the inlined ops to the caller's loop header line rather than the callee's actual arithmetic.

Test plan

  • ./mfc.sh precheck passes (enforced by pre-commit hook — already verified locally)
  • fp-stability.yml CI run passes with the new build flag
  • Verify on the next FP-stability CI run that dd_line results point to arithmetic lines (assignments, expressions) rather than end do or #:endfor boundaries

…function scoping

Three changes to reduce spurious dd_line reports pointing at do-loop
boundaries, #:endfor lines, or inlined-function call sites:

1. _CONTROL_FLOW_RE + _is_arithmetic_loc: post-filter dd_line results
   by reading the actual source line; skip pure control-flow delimiters
   (end do, end if, #:endfor, $:END_GPU_PARALLEL_LOOP, etc.) that share
   DWARF info with the preceding arithmetic due to template expansion or
   inlining.

2. restrict_syms in _write_dd_run_sh / _run_dd_line: when dd_sym has
   already identified responsible functions, dd_line_run.sh embeds
   --source-function=<sym> flags so Verrou only perturbs FP ops inside
   those functions, narrowing the bisection space.

3. FFLAGS=-fno-inline in fp-stability.yml: prevents gfortran from
   inlining small helpers into their callers, so DWARF correctly
   attributes arithmetic to the callee source line rather than the
   caller loop header.
@sbryngelson sbryngelson force-pushed the improve/verrou-attribution branch from 3671682 to 7bbeab7 Compare May 13, 2026 22:39
dd_run.sh never forwarded the VERROU_EXCLUDE and VERROU_SOURCE env vars
injected by verrou_dd_sym and verrou_dd_line respectively. Without these,
dd_sym perturbs all functions uniformly (over-inclusive results) and
dd_line cannot narrow to individual source lines.

Also fix _parse_rddmin_syms: it was returning every non-empty line
including the 'ddmin0: Fail Ratio...' metadata lines. These got embedded
literally as --source-function flags (not a valid Verrou flag), crashing
the dd_line reference run and producing an empty rddmin_summary.

Remove the broken restrict_syms / --source-function approach entirely.
Verrou's own bisection protocol handles scope restriction via env vars.

Also exclude fp-stability-logs/ from typos and gitignore since Verrou
generates files containing 'unamed_filename_verrou' (its internal token).
…e patterns

The _CONTROL_FLOW_RE filter was only applied to dd_line results; the
cancellation check was passing its locs through unfiltered, producing
subroutine declarations, else-if branches, and loop headers in the step
summary alongside real arithmetic sites.

Changes:
- Apply _is_arithmetic_loc filter to cancellation_locs in
  _run_cancellation_check; log how many control-flow boundaries skipped.
- Extend _CONTROL_FLOW_RE to also catch:
    - else / else if (...) then branches
    - subroutine declarations (recursive/pure/elemental variants)
@sbryngelson sbryngelson marked this pull request as ready for review May 14, 2026 00:57
@qodo-code-review
Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@sbryngelson sbryngelson merged commit 1139cc4 into MFlowCode:master May 14, 2026
40 of 70 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.00%. Comparing base (b40c0bf) to head (bb15d3a).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1437   +/-   ##
=======================================
  Coverage   65.00%   65.00%           
=======================================
  Files          72       72           
  Lines       18810    18810           
  Branches     1553     1553           
=======================================
  Hits        12227    12227           
  Misses       5615     5615           
  Partials      968      968           

☔ View full report in Codecov by Sentry.
📢 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.

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