-
-
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
slow SubMatrix copy #3098
Comments
In the case of arrays, on my 64-bit linux (x86_64) I get slightly better performance from copy! than loopcopy! (0.25s vs 0.31s). But by-and-large I replicate your findings. The problem seems to come from I'll also note that one can do vastly better with subarrays:
Test:
Images.jl uses some of these tricks, although I haven't yet profiled to see if they are working as expected. |
(Basically, subarrays need the kind of love that I gave array.jl long ago. A variant of |
On a slightly orthogonal but not completely unrelated note, there has been the proposal of making array indexing return views. That has benefits of greatly reducing copying and GC, and also removes the need to use subarrays in many cases. Now that we can do stuff like |
Definitely related. I even started working on something like that within the first few days of the merging of immutable types, but got bit by challenges stemming from the need for better inlining. I haven't looked recently. |
@ViralBShah: I thought that those views would be subarrays themselves? In my view, producing array views will increase the need to be able to deal with subarrays/strided arrays. Also, it should be straightforward to get machinery such as what I propose for fast |
Thanks @timholy for your nice fastcopy!() example. That clears up some mysteries for me. But yes, you are right, SubArray could definitely benefit from some more attention. I've just logged two more issues involving subarray. See #3114 and JuliaLang/LinearAlgebra.jl#14. |
Have there been any updates on the creation of submatrix views? I am experimenting with using Julia in a linear algebra course that I'm teaching and would find it very helpful for providing high-performance code samples for factorizations. |
Can we close this with the new SubArrays, or should we wait for the updates to getindex and such? |
We've actually had a fast |
For comparison to
copy!
, define:Create regular and strided source and destination matrices:
Time
loopcopy!
vscopy!
. Timings below are for 32-bit windows, but behaviour on 64-bit linux is similar:OK, very close, but for SubMatrix source:
copy!
is much slower. Similarly:Counterexample:
The text was updated successfully, but these errors were encountered: