Repository navigation
compiler: Preserve compilation invariants under symbol renaming - #3084
FabioLuporini wants to merge 19 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3084 +/- ##
==========================================
+ Coverage 84.28% 84.46% +0.17%
==========================================
Files 258 260 +2
Lines 57469 58349 +880
Branches 4914 4956 +42
==========================================
+ Hits 48439 49282 +843
- Misses 8206 8245 +39
+ Partials 824 822 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
| self.reserved.update(i.name for e in exprs for i in e.free_symbols) | ||
|
|
||
| # Before indexification, a Function's free symbols omit its own name | ||
| self.reserved.update(i.name for i in retrieve_functions(exprs)) |
Retrieve Functions uniquely when reserving names, share the default uxreplace traversal through an explicit helper, and remove the unneeded Operator name from the input-name collision test. Keep the CSE position map to avoid repeated linear scans of exprs. In a comparison of the actual topological sort with 128 independent CTemps, including map construction, cached lookup took 39 ms versus 1255 ms for list.index. Add a comment explaining the cached lookup. Validation: focused C/OpenMP regressions (64 passed, 1 xfailed) and C++/OpenMP regressions (62 passed, 1 xfailed). The full CPU audit found separate numerical failures already present before the rebase.
7a1eb98 to
0325dd2
Compare
|
|
||
| def __init__(self, settings=None): | ||
| super().__init__(settings) | ||
| self._order = self.order |
Stably place numeric offsets last in commutative integer sums. This emits bx_size - 1 without sorting symbolic operands by name or changing floating-point summation order. Preserve opaque noncommutative expressions. Cover positive and negative offsets with 32- and 64-bit integers and mixed floating-point addends. Refresh two stale floating-point code-display lines in the MPI overview, keeping notebook source and comparison rules unchanged. Validation: both MPI notebooks pass all 35 cell checks on a private four-rank cluster; affected C/OpenMP compiler tests pass 554 cases, and C++/OpenMP symbolic/IET tests pass 192 cases.
|
|
||
| def __init__(self, settings=None): | ||
| super().__init__(settings) | ||
| self._order = self.order |
|
|
||
|
|
||
| @_uxreplace_dispatch.register(dict) | ||
| @_uxreplace_dispatch.register(frozendict) |
There was a problem hiding this comment.
This dispatcher currently turns a frozendict into a dict. You need to add a cast at the end to make sure it's the correct type.
| @_uxreplace_handle.register(UnevalAdd) | ||
| @_uxreplace_handle.register(UnevalMul) |
There was a problem hiding this comment.
Why not register UnevalMixin instead of having multiple registrations here?
Choose emitted Add/Mul order at the existing freezing boundary, using capture-avoiding definition-order comparison symbols for local Temps. Preserve original operands and groups through replacement, serialization and printing. Remove the per-node printer setting mutation and integer result-type formatting workaround. Keep frozen sums grouped and preserve factor order during negative coefficient extraction. Retain ordinary symbolic display, refresh generated notebook output, and avoid fixed operand positions in the visitor regression. Preserve immutable mapping types during symbolic reconstruction, and explain why the concrete frozen Add/Mul dispatch registrations are required by MRO.
Restore recursive unevaluation without comparison symbols or operand sorting. Keep ordinary Add/Mul printing and avoid new parentheses around nested sums. Preserve the earlier scoped substitution and reconstruction fixes. Extract numeric factor signs locally in the Devito printer, including signs outside the leading factor and products containing only minus-one factors. Cover pure freezing, equal operand instances and canonical emitted code; bring tutorial snapshots back to ordinary printing. Validate CPU/C++ symbolic and numerical cases, 91 strict notebook checks, CUDA naming/pickling and the reported CUDA/OpenACC compilation failures. The existing min-storage and bitcomp precision failures remain unchanged in scope; no numerical tolerances are relaxed.
Document that SymPy calls the standalone _keep_coeff helper, so UnevalMul cannot override its reconstruction. Explain why Devito extracts signs before delegating instead of patching SymPy or copying its multiplication printer. Comment only; Python syntax trees are identical. Ruff and diff checks pass.
Generated temporary names can affect CSE scheduling, while symbolic substitutions can reorder lowered arithmetic or leave stale references in auxiliary metadata. Application identifiers such as r0 can also collide with compiler-generated temporaries.
This PR addresses these issues and provides a final IET customization point for backend naming passes: