-
Notifications
You must be signed in to change notification settings - Fork 23
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
Flatten and unflatten by reshaping when possible #154
Conversation
meshmode/dof_array.py
Outdated
# NOTE: arrays with one group are common enough and don't require any | ||
# concatenation to "flatten", but can just be reshaped | ||
if len(ary) == 1: | ||
return list(ary)[0].reshape(-1) |
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.
To be safe, I think it'd be useful to verify the memory layout using the strides here.
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.
I wanted to do something like that, but wasn't sure how it would interfere with the lazy stuff. Would adding an actx.np.reshape
and reusing this make more sense?
5479495
to
9146e48
Compare
1934be3
to
a235239
Compare
meshmode/dof_array.py
Outdated
if len(ary) == 1: | ||
ary0 = list(ary)[0] | ||
if ary0.flags.c_contiguous: | ||
return ary0.reshape(-1, order="C") | ||
elif ary0.flags.f_contiguous: | ||
return ary0.reshape(-1, order="F") | ||
else: | ||
# NOTE: array has unsupported strides, so we need to do a copy | ||
pass |
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 isn't correct. The existing array can be reshaped if and only if the strides are (itemsize*nunit_dofs_per_element, itemsize)
. (Note that subclassing array contexts might do weird things like introduce extra dimensions.)
Unsubscribing... @-mention or request review once it's ready for a look or needs attention. |
Co-authored-by: Andreas Klöckner <inform@tiker.net>
This has been graciously continued by @thomasgibson in #192. |
Is this sort of what you hand in mind in inducer/pytential#71 (comment)?
It seems to do the trick, i.e.
flatten
andunflatten
don't show up anywhere near the top of any profiling (for a single group mesh at least).