-
Notifications
You must be signed in to change notification settings - Fork 400
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
[WIP] Add implementation to forward linear iterators in strided views #2797
base: master
Are you sure you want to change the base?
[WIP] Add implementation to forward linear iterators in strided views #2797
Conversation
@JohanMabille I'm trying to forward linear iterators where possible but I think the implementations expect steppers in certain places and there are some subtle differences I haven't figured out yet. I thought it was weird that the linear methods on the strided view actually return xiterators of steppers rather than linear iterators as the interface would suggest. Test bench from issue #2734 Without Changes: With changes results in: The implementation is super rough but I wanted to show you the basic idea. I ran into a pesky issue with reshaped views that resulted in my having to force a fallback to the old implementation. Might need some help there but the performance improvements speak for themselves. |
Can a linear assignment be used when the inner stride is not one? It seems like the linear iterators increment by one but when doing conversion from row major to column major the strides between adjacent elements are non-unity. |
bdde934
to
b4f7e3d
Compare
This issue here was trying to iterate on the object like a column major when the internal storage is row major. That requires a stepper... In these cases the implementation falls back to a stepper even though the underlying expression might be linearly iterable. |
b4f7e3d
to
2d268ad
Compare
2d268ad
to
7935a69
Compare
See benchmark code below:
|
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.
Thanks a lot for tackling this! I think the linear / not linear iteration was supposed to be handled in the flat_storage_adaptor but we probably missed some cases.
I wonder if it would make sense to merge the new linear_flat_expression_adaptor
with the existing flat_expression_adaptor
. This would put the reponsibility of choosing between the linear iterator and the regular one in the flat adaptor rather than in the strided_view. Also It would probably benefit other classes using the flat_expression adaptor.
@@ -75,6 +76,52 @@ namespace xt | |||
size_type m_size; | |||
}; | |||
|
|||
template <class CT, layout_type L> | |||
class linear_flat_expression_adaptor : public flat_expression_adaptor<CT, L> |
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 inheriting from flat_expression_adaptor
here? It does not seem that you reuse anything from 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.
@JohanMabille I only implemented the linear iterator methods for the new class. linear_flat_expression_adaptor
relies on inheriting the implementation of flat_expression_adaptor
for calls made to methods such as cbegin
.
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.
@JohanMabille what do you think? Should I implement this differently?
@JohanMabille I debated that as well. Let me play around with the logic and see if I can make this work without modifying the |
9f834af
to
7935a69
Compare
@JohanMabille combining them became difficult because the uvector implementation doesn't have the linear_iterator interface. The begin and end methods are linear iterators but the interface is not consistent. I'm not sure if this is intentional or not. |
Checklist
Description