Skip to content
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

Merged
merged 23 commits into from
Jan 30, 2024
Merged

compiler: Revamp data alignment #2296

merged 23 commits into from
Jan 30, 2024

Conversation

FabioLuporini
Copy link
Contributor

@FabioLuporini FabioLuporini commented Jan 16, 2024

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

Copy link

codecov bot commented Jan 16, 2024

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (735eaa5) 86.74% compared to head (e58dc53) 86.69%.

Files Patch % Lines
devito/types/basic.py 87.87% 2 Missing and 2 partials ⚠️
devito/types/dense.py 78.94% 1 Missing and 3 partials ⚠️
devito/ir/clusters/algorithms.py 66.66% 1 Missing and 1 partial ⚠️
devito/logger.py 50.00% 1 Missing ⚠️
devito/passes/iet/engine.py 80.00% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

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
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

== 0 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@EdCaunt
No, because we developers write these classes and upon testing a new one we would be thrown the assert exception right away if the case

@mloubout yes, == 0, the memory transaction nbytes is always a multiple of 2, just like a C base type size

Copy link
Contributor

@mloubout mloubout left a 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
Copy link
Contributor

Choose a reason for hiding this comment

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

== 0 ?

padleft, padright = padding
except TypeError:
padleft, padright = padding, padding
if not isinstance(padleft, int) and not isinstance(padright, int):
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok fixing

# 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
Copy link
Contributor

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

Copy link
Contributor Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Contributor Author

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

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

is_integer

Copy link
Contributor

Choose a reason for hiding this comment

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

why right-padding only?

Copy link
Contributor Author

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 🤷

Copy link
Contributor Author

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 \
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

devito/types/dense.py Show resolved Hide resolved
tests/test_data.py Outdated Show resolved Hide resolved
def test_w_halo_custom(self):
grid = Grid(shape=(4, 4))

# Custom halo with not enougn entries raises an exception
Copy link
Contributor

Choose a reason for hiding this comment

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

small typo "enough"

@FabioLuporini FabioLuporini merged commit 8bb140d into master Jan 30, 2024
31 checks passed
@FabioLuporini FabioLuporini deleted the enhance-halo-setup branch January 30, 2024 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drop deprecation of padding parameter
4 participants