-
-
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
WIP: use mutating matrix multiplication in eigs #7907
Conversation
Thanks for tackling this. This is much needed! |
Does using |
Yes it would. I was just doing a lot of pointer work in some code of mine, where I will fix this if I complete this PR. I guess there is no need to hurry with this, i.e. it will be a 0.4 thing, together with |
Yes, definitely 0.4. Main things are this performance enhancement, operator functions instead of matrix inputs, and then |
2ef98c5
to
0388647
Compare
@Jutho Do you think this PR should be updated to use SubArrays or should we merge it as is? I am assuming the performance difference is notable. |
This is far from finished. If I have some time, I will try to finish it, but it will probably not be until next week. |
I believe that with the recent subarray work and indexing operators defaulting to views, this should no longer be necessary. |
Correct. |
Although, with the current implementation, every matrix vector multiplication will still allocate a new vector for the result (but no longer for the input, which is obtained by indexing into a larger array), and only then copy it to the correct position. So there would still be the benefit of using |
I see - |
Some |
This is on my todo list. I'll make some time for this after I have finished the improved |
I was wondering exactly the same thing myself about the new GC. Perhaps it is worth setting up some performance benchmarks, which will otherwise be good to have too - before doing a whole bunch of work here. |
For this problem, I see almost the same time and memory allocation: Julia 0.3: 28 seconds (5.4GB allocated)
Octave took 24 seconds, but I am not sure if Julia and octave are running the same number of iterations, and are comparable. |
closing in favor of #16294 |
Currently, the arpack wrapper of eigs allocates way too much memory. Firstly, no mutating methods are used, so every matrix multiplication creates (allocates) a new output, which is then copied to the position requested by Arpack. Secondly, for every new matrix multiplication, a new inputvector
x=workd[load_idx]
is created (allocated). So that is two vector allocations per matrix multiplication, both of which could be avoided. The second one will automatically go away when indexing creates a view. The first one requires to switch to mutating methods whenever possible (e.g. whenever defined for the type of A).This is a work in progress, since so far only the standard mode is covered (i.e. no shift-invert, no generalised eigenvalue problems, so this will fail the tests). Also, I currently use
pointer
andpointer_to_array
to create a view, but a simpleslice
would probably have been ok.