-
Notifications
You must be signed in to change notification settings - Fork 130
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
SUNMatScaleAdd_Sparse
has time complexity O(M*N)
#253
Comments
Thanks for noting this. Indeed this is because the current implementation support a very general case. Perhaps we can add an option (controlled with a Set function) to use less general, but faster implementations of |
I think I have a general solution that avoids these scaling issues, at least for |
Modify element traversal in SUNMatScaleAddI_Sparse to scale O(NNZ) instead of O(M*N) Related issue LLNL#253 Signed-off-by: phannebohm <phannebohm@fh-bielefeld.de>
SUNMatScaleAdd_Sparse
scales like O(M*N)SUNMatScaleAdd_Sparse
hase time complexity O(M*N)
SUNMatScaleAdd_Sparse
hase time complexity O(M*N)SUNMatScaleAdd_Sparse
has time complexity O(M*N)
Closed by #257. |
As the title says, adding two sparse matrices scales badly. I believe the problem are loops like the sparsity pattern overlap check here:
sundials/src/sunmatrix/sparse/sunmatrix_sparse.c
Lines 827 to 832 in 7c31824
Just filling the work array
w
with zeros takes M*N operations. This happens in a few places inside this function withw
andx
. If I replace the for loops with calls tomemset
I save a significant amount of computation time (maybe 75% on my machine, don't trust that number though). However it still scales badly. I would expect addition to scale like O(NNZ) instead.On a side note, for my particular use case (OpenModelica/OpenModelica#10178) I can take a modified version of$A + c I$ . This scales linearly as expected. Perhaps this function could be useful for other people.
SUNMatScaleAddI_Sparse
, I call itSUNMatScaleIAdd_Sparse
where the result isThe text was updated successfully, but these errors were encountered: