-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compiler: Add guards to prevent OOB when streaming buffers with ConditionalDimension #2150
Merged
FabioLuporini
merged 5 commits into
devitocodes:master
from
ccuetom:add-streaming-guards
Jul 7, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9c41f7c
compiler: Add guards to prevent OOB when streaming buffers with Condi…
ccuetom 7d41ca5
compiler: Update buffering tests to match new trees
ccuetom 67c69f8
compiler: Correct guards update in buffering
ccuetom 8d8fbcb
compiler: Fix line lengths
ccuetom 746afeb
compiler: Apply buffering guards to non-ConditionalDimension
ccuetom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -576,6 +576,34 @@ def test_streaming_multi_input(self, opt, ntmps): | |
|
||
assert np.all(grad.data == grad1.data) | ||
|
||
def test_streaming_multi_input_conddim_foward(self): | ||
nt = 10 | ||
grid = Grid(shape=(4, 4)) | ||
time_dim = grid.time_dim | ||
x, y = grid.dimensions | ||
|
||
factor = Constant(name='factor', value=2, dtype=np.int32) | ||
time_sub = ConditionalDimension(name="time_sub", parent=time_dim, factor=factor) | ||
|
||
u = TimeFunction(name='u', grid=grid, time_order=2, save=nt, time_dim=time_sub) | ||
v = TimeFunction(name='v', grid=grid) | ||
v1 = TimeFunction(name='v', grid=grid) | ||
|
||
for i in range(u.save): | ||
u.data[i, :] = i | ||
|
||
expr = u.dt2 + 3.*u.dt(x0=time_sub - time_sub.spacing) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI this is just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good to know - I adapted the code from the next test there |
||
|
||
eqns = [Eq(v.forward, v + expr + 1.)] | ||
|
||
op0 = Operator(eqns, opt=('noop', {'gpu-fit': u})) | ||
op1 = Operator(eqns, opt=('buffering', 'streaming', 'orchestrate')) | ||
|
||
op0.apply(time_M=nt, dt=.01) | ||
op1.apply(time_M=nt, dt=.01, v=v1) | ||
|
||
assert np.all(v.data == v1.data) | ||
|
||
def test_streaming_multi_input_conddim_backward(self): | ||
nt = 10 | ||
grid = Grid(shape=(4, 4)) | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what changed in the code since it seems to change existing tests not related to
init_to_host
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests also generate initialisation code that is affected by the addition of the guard. The loop:
becomes:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that what causes the bump from 3 to 4 iteration nests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the iteration nest before adding the guard:
and after adding the guard:
Iteration tree
IterationTree(<WithProperties[affine,parallel]::Iteration db0; (0, 0, 1)>,)
appears as a result. Not sure if this is expected or if you want me to probe into it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, it's OK!