-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Faster cumsum & cumprod. Fixes #7342. #7359
Conversation
That was fast! 👏 🍸 |
@timholy You probably want a special path for cases where |
I agree with exporting |
Yes, we should probably export |
I'm never in favor of the |
If only the code without |
Well, this PR makes cumsum 10x faster. The |
Right, once we have a faster gc the EDIT: Of course, the bigger benefit in principle arises with SharedArrays or mmapped arrays---the ! form provides a natural mechanism to exploit parallelism or do things that might otherwise exhaust your memory. Though currently we lack a good framework for automatically generating |
True enough. Not as important as for reductions, because you still have to access each element again to store the result, but it does save one array-access per element. See if this is better (~20% additional speedup for |
I understand that we don't want too many |
@timholy I am happy with the latest commit. This fix comes amazingly fast! |
@JeffBezanson I don't think that exporting matters. Even if something is not exported, but is widely used, it is just as difficult to take it away. I am hoping we will get things to be fast enough so that we can at least unexport the |
Also, in a perverse way, now that this is 10x faster, it is all the more important to have the |
Faster cumsum & cumprod. Fixes #7342.
I'm confused, what's the motivation behind not liking the in-place versions of functions? Unless there are plans afoot to somehow make them unnecessary for performance, in which case I don't understand how that would be possible. A standardized mechanism for doing things in-place by default and automating the copying definitions would be good, of course. |
Well if you switch to array view semantics instead of copy be default then the in place method performance difference will likely be less dramatic. It is still nice to have an escape hatch if you don't want the overhead of creating even a lightweight view object. |
@jakebolewski I am afraid that I don't see how the array views are relevant to the discussions here. Even with array views, you still need inplace functions to avoid creating temporary arrays. |
I definitely think they should be exported – these are quite useful.
|
I'm biased by Matlab to prefer a default of 1 but don't have a strong feeling about it for the multidimensional case. For the vector case, however, having to explicitly specify dim 1 is just annoying. |
Yes, you're right about handling vectors. To me that's by far the strongest argument in favor of defaulting to 1 for all arrays. |
Should we export
cumsum!
andcumprod!
?Note if you include the
copy
operation that would have been needed in #7342 (comment), this implementation is actually a little faster because it only needs to make one pass through the data rather than two.