Skip to content

compiler: Fix buffer stride runtime mismatch#2950

Open
mloubout wants to merge 3 commits into
mainfrom
fix-buffer-stride-runtime-mismatch
Open

compiler: Fix buffer stride runtime mismatch#2950
mloubout wants to merge 3 commits into
mainfrom
fix-buffer-stride-runtime-mismatch

Conversation

@mloubout

Copy link
Copy Markdown
Contributor

Make sure mapped array use symbolic padding so that it always matches the runtime mapped function and can safely reuse the Function's strydes.

@mloubout mloubout added compiler bug-C bug in the generated code labels Jun 17, 2026
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.39130% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.36%. Comparing base (52dddd9) to head (ecfa240).

Files with missing lines Patch % Lines
devito/types/array.py 93.54% 1 Missing and 1 partial ⚠️
devito/types/dense.py 33.33% 1 Missing and 1 partial ⚠️
devito/mpi/routines.py 0.00% 1 Missing ⚠️
devito/passes/clusters/buffering.py 50.00% 1 Missing ⚠️
tests/test_mpi.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2950      +/-   ##
==========================================
- Coverage   82.85%   79.36%   -3.50%     
==========================================
  Files         249      249              
  Lines       52279    52268      -11     
  Branches     4503     4499       -4     
==========================================
- Hits        43318    41483    -1835     
- Misses       8188     9976    +1788     
- Partials      773      809      +36     
Flag Coverage Δ
pytest-gpu-aomp-amdgpuX ?
pytest-gpu-gcc- 78.21% <92.39%> (-0.01%) ⬇️
pytest-gpu-icx- 78.15% <92.39%> (+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.

@mloubout mloubout force-pushed the fix-buffer-stride-runtime-mismatch branch 2 times, most recently from dd74d3c to 87857e3 Compare June 18, 2026 02:50
Comment thread devito/passes/iet/linearization.py Outdated
pad_key = f.__padding_dtype__
else:
pad_key = None
pad_key = f.__padding_dtype__ if d is f.dimensions[-1] else None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random thought: do we need a dimensions_padded property rather than just [-1]? thinking about what we recently doing in PRO with all those "special" Arrays.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point yes would be good to have

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imho since we're at it, I'd add it now and simply make it return -1 for now. I could use it in PRO too in a few places

Comment thread devito/types/array.py Outdated
Comment thread devito/types/array.py Outdated
padding = kwargs.get('padding')
if padding is None:
padding = ((0, 0),)*self.ndim
if self.is_autopaddable:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so yes

@FabioLuporini FabioLuporini left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some questions, but it's a great catch, and a great cleanup too

@EdCaunt EdCaunt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending Fabio's comments

@mloubout mloubout force-pushed the fix-buffer-stride-runtime-mismatch branch 6 times, most recently from e561c21 to 0f670a5 Compare June 19, 2026 00:35
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@FabioLuporini FabioLuporini changed the title Fix buffer stride runtime mismatch compiler: Fix buffer stride runtime mismatch Jun 19, 2026
Comment thread devito/passes/clusters/buffering.py Outdated
assert len(buffers) == 1, "Unexpected form of multi-level buffering"
buffer, = buffers
xd = buffer.indices[dim]
# The new buffer is fed by `buffer`, so it inherits its padding

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"# The new buffer is fed by buffer"

nitpicking, not entirely clear imho

Comment thread devito/types/array.py

@FabioLuporini FabioLuporini left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some minor comments. Uncontroversial , looks like a great cleanup and long due

Comment thread devito/types/basic.py
def __padding_setup__(self, padding=None, **kwargs):
padding = tuple(padding or ((0, 0),)*self.ndim)
def __padding_setup__(self, **kwargs):
# `padding=` is never honored: derived from policy to avoid stride

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth emitting a deprecation warning here if a user does specify padding?

Comment thread tests/test_data.py
@@ -325,7 +325,7 @@ class TestMetaData:

def test_wo_halo_wo_padding(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: is the wo_padding part of this test name now redundant?

@mloubout mloubout force-pushed the fix-buffer-stride-runtime-mismatch branch 2 times, most recently from 745fbb5 to 94e11ea Compare June 19, 2026 11:57
@mloubout mloubout force-pushed the fix-buffer-stride-runtime-mismatch branch from 94e11ea to ecfa240 Compare June 19, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-C bug in the generated code compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants