-
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: Revamp data alignment #2296
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #2296 +/- ##
==========================================
- Coverage 86.74% 86.69% -0.05%
==========================================
Files 229 229
Lines 42905 42895 -10
Branches 7957 7952 -5
==========================================
- Hits 37217 37188 -29
- Misses 5012 5024 +12
- Partials 676 683 +7 ☔ View full report in Codecov by Sentry. |
Number of items of type `dtype` that can be transferred in a single | ||
memory transaction. | ||
""" | ||
assert self.max_mem_trans_nbytes % np.dtype(dtype).itemsize == 0 |
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.
Would it be worth raising an exception with a message here if this assertion is False
? Not sure how easily a user could bump into this, but could imagine it being quite cryptic to a novice user if they did
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.
== 0
?
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.
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.
Some minor comments but looks good.
Number of items of type `dtype` that can be transferred in a single | ||
memory transaction. | ||
""" | ||
assert self.max_mem_trans_nbytes % np.dtype(dtype).itemsize == 0 |
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.
== 0
?
devito/data/allocators.py
Outdated
padleft, padright = padding | ||
except TypeError: | ||
padleft, padright = padding, padding | ||
if not isinstance(padleft, int) and not isinstance(padright, int): |
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.
Note: we need to get rid of all those isinstance(x, int)
and switch to our is_integer, so many places break when you end up with a numpy int instead
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.
ok fixing
devito/data/allocators.py
Outdated
# is copied, you should assign the new shape to the shape attribute | ||
# of the array: | ||
array.shape = shape | ||
ndarray = array # At this point it's interpreted as an ndarray |
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 this line really needed
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.
nah, dropping
@@ -624,7 +624,8 @@ def _prepare_arguments(self, autotune=None, **kwargs): | |||
|
|||
# Sanity check | |||
for p in self.parameters: | |||
p._arg_check(args, self._dspace[p], am=self._access_modes.get(p)) | |||
p._arg_check(args, self._dspace[p], am=self._access_modes.get(p), | |||
**kwargs) |
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.
?
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.
Gonna be needed in PRO soon.
I also had a change in OSS while developing this branch, but then I dropped it. I left the **kwargs because I will need it in an upcoming branch.
If you think about it, it makes a lot of sense -- there's a lot of symbolic properties we might want to check they're honored before signing off on the override; properties we aren't checking today
devito/types/array.py
Outdated
elif isinstance(padding, tuple) and len(padding) == self.ndim: | ||
return tuple((0, i) if isinstance(i, int) else i for i in padding) | ||
padding = tuple((0, i) if isinstance(i, int) else i for i in padding) |
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_integer
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.
why right-padding only?
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.
that's all we need for data alignment, I'm yet to find a use case for left-padding, I doubt it exists but 🤷
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.
OK switching to is_integer
|
||
elif isinstance(space_order, tuple) and len(space_order) == 2: | ||
_, space_halo = space_order | ||
if not isinstance(space_halo, tuple) or \ |
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.
can't be just an int
to be same left/right?
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.
unfortunately not, think about shifted derivatives and you may have Functions requiring 4 points on the left and 3 on the right
15e40e9
to
18aebdc
Compare
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
def test_w_halo_custom(self): | ||
grid = Grid(shape=(4, 4)) | ||
|
||
# Custom halo with not enougn entries raises an exception |
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.
small typo "enough"
6957a26
to
adc93fc
Compare
08d4410
to
e58dc53
Compare
Sorry about the branch name -- it's misleading to an extent
Note that one test is being dropped because I've removed a micro-optimization pass that was just legacy, rarely (if ever) used, and marginally (if any) impactful, all while being a massive PITA to maintain (basically everything revolving around the so called "ROUNDABLE" Property)
fixes #1579