Repository navigation
compiler: Map implicit ConditionalDimensions onto SubDomain dimensions - #3118
Open
sankalpsthakur wants to merge 1 commit into
Open
sankalpsthakur wants to merge 1 commit into
sankalpsthakur wants to merge 1 commit into
Conversation
An implicit ConditionalDimension defined over the Grid Dimensions (parent and/or condition) was left untouched by _make_dimension_map when the Eq carried a subdomain, while every access was lowered onto the SubDomain's SubDimensions. The resulting IterationSpace was [ix, y, iy], and guard() crashed looking up x in it with "ValueError: tuple.index(x): x not in tuple". Rebuild such ConditionalDimensions with their parent and condition mapped through the SubDomain's dimension_map, mirroring what is already done for subsampled Functions. Fixes devitocodes#2803 Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2803.
An
Eqwithsubdomain=and an implicitConditionalDimensionwhose parent and/or condition are defined on the Grid dimensions crashed at Operator build:Root cause
_make_dimension_map(devito/ir/equations/algorithms.py) maps the Grid dimensions onto the SubDomain's SubDimensions ({x: ix, y: iy}) and already rebuilds ConditionalDimensions found inFunction.dimensions(the SubGrid case). It did not handle the ConditionalDimensions inexpr.implicit_dims, so the implicit dimension keptparent=yand a condition onu(x, y)while all accesses were lowered ontoix/iy. For the issue's reproducer on the base commit, the Cluster reachingguard()(devito/ir/clusters/algorithms.py) hasEq(u[ix + 1, iy + 1], 7)with IterationSpace[ix, y, iy].guard()places the conditionGt(u(x, y), 0)by callingc.ispace.index()on each Dimension of the condition, andxis not in that space, which raises theValueError.Fix
After the existing SubGrid handling, each implicit
ConditionalDimensionwhose parent is a mapped Grid dimension, or whose condition references one, is rebuilt with its parent and condition mapped through the SubDomain'sdimension_map.uxreplacethen substitutes it in theEq'simplicit_dims, as it already does for other mapped dimensions. Agetattrguard is used because plain relationals have noimplicit_dims.Tests
TestSubDomain_w_condition::test_condition_w_subdomain_v3intests/test_subdomains.py: a 6x6 grid,ci = ConditionalDimension(parent=y, condition=Gt(u, 0)),Eq(u, 7, implicit_dims=ci, subdomain=grid.interior). It checks the data against numpy (interior cells withu > 0set to 7, boundary untouched) and the loop structure.ValueError: tuple.index(x): x not in tuple; with the change it passes.DEVITO_ARCH=clang DEVITO_LANGUAGE=C, no MPI):pytest -m "not parallel" tests/test_subdomains.py tests/test_dimension.py tests/test_ir.py tests/test_symbolics.py tests/test_buffering.py tests/test_operator.pygives 1073 passed, 2 xfailed, 1 failed. The failure istest_dimension.py::TestConditionalDimension::test_blocking_w_guard, which also fails when run on the base commit, with the same compile error (fatal error: 'omp.h' file not found) from Apple clang.ruff checkis clean on the changed files.flake8 --max-line-length 90with the ignore list from[tool.flake8]inpyproject.tomlpassed explicitly via--extend-ignoreis also clean; without that list flake8 reports pre-existing E275 warnings intests/test_subdomains.pythat are not on lines this change touches.AI/LLM disclosure
AI coding tools were used to help draft or modify code and this PR description. I reviewed the complete change, understand the reasoning, and ran the reported local tests before submitting.