Skip to content

compiler: Fix three guard bugs exposed by buffering - #3061

Draft
ggorman wants to merge 3 commits into
mainfrom
fix-buffering-guards
Draft

ggorman wants to merge 3 commits into
mainfrom
fix-buffering-guards

Conversation

@ggorman

@ggorman ggorman commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Three guard bugs that buffering exposes, each with a single-writer test against opt='noop':

  1. GuardFactorNe was an equality. It inherited CondEq ahead of CondNe through GuardFactor, so negating a subsampling guard reproduced the guard: one equation under Not(GuardFactor(ct)) with factor 2 printed (time)%(ctf) == 0 and wrote f = [1, 0, 3, 0] instead of [0, 2, 0, 4].
  2. if (false) was emitted. A condition SymPy folds to false (e.g. time < 0) printed if (false), which is not C99 without stdbool.h: a compile error.
  3. {time: true} guards. time >= 0 folds to true and gave a Cluster a guard distinct from no guard, so buffering created one buffer per "guard" for equivalent accesses.

Tests: test_dimension.py::TestConditionalDimension::test_negated_factor_condition, ::test_false_condition, test_buffering.py::test_true_condition_single_buffer. Each fails with only its commit's source change reverted.

First of three stacked PRs: this one, then #3062 (copy-back skip rule) and #3063 (stale reads and lost writes).

🤖 Generated with Claude Code

ggorman and others added 3 commits October 16, 2026 10:49
GuardFactorNe inherited CondEq through GuardFactor ahead of CondNe, so it
was an equality and printed `==`. Negating a subsampling guard thus
reproduced the guard itself, selecting the timesteps on the subsampled
grid instead of those off it
A condition SymPy folds to `false`, e.g. `time < 0`, was printed as
`if (false)`, which is not C99 without `stdbool.h` and failed to compile
A condition such as `time >= 0` folds to `true` (`time` is nonnegative)
and gave a Cluster the guard {time: true}, distinct from no guard.
Buffering then created one buffer per guard for equivalent accesses
@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.87234% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 84.24%. Comparing base (2707ac9) to head (38e0aa4).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
devito/passes/iet/languages/C.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3061      +/-   ##
==========================================
+ Coverage   84.23%   84.24%   +0.01%     
==========================================
  Files         258      258              
  Lines       57070    57112      +42     
  Branches     4874     4875       +1     
==========================================
+ Hits        48072    48115      +43     
  Misses       8170     8170              
+ Partials      828      827       -1     
Flag Coverage Δ
pytest-gpu-aomp-amdgpuX 68.51% <75.00%> (-0.01%) ⬇️
pytest-gpu-gcc- 79.03% <97.87%> (+0.02%) ⬆️
pytest-gpu-icx- 78.93% <97.87%> (+0.01%) ⬆️
pytest-gpu-nvc-nvidiaX 69.08% <75.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant