AMICI icon indicating copy to clipboard operation
AMICI copied to clipboard

Use SUNMatMatvec instead of reimplementation in SUNMatrixWrapper::multiply

Open dweindl opened this issue 6 years ago • 6 comments

... may be more optimized already.

dweindl avatar Oct 25 '19 09:10 dweindl

That one should have ben fixed by now (in #858), right?

paulstapor avatar May 06 '20 12:05 paulstapor

Don't see any use of SUNMatMatvec there, so I would guess not ...? multiple for sparse matrices still uses our own implementation and for dense uses dgemv, which is fine-ish but could indeed also be replaced by SUNMatMatvec.

FFroehlich avatar May 06 '20 19:05 FFroehlich

Hm... haven't thought about that. This issue was about for the dwdp-code, before it was sparsified, but shouldn't necessary any more now. However, I didn't think about using SUNMatMatvec in a more general context so far... Yet, dgemv is BLAS, which is computation-time-wise very optimized... Not sure, whether SUNMatMatvec is faster (think it isn't), in any case it would be a more consistent.

Currently, I would only see a use of SUNMatMatvec if we can remove the BLAS dependency this way... What do think: Is removing BLAS desirable at all?

paulstapor avatar May 06 '20 20:05 paulstapor

dgemm is still used in model.cpp in several places, so the "dependency" wouldn't go away. Removing the explicit linking of BLAS would certainly be nice as the respective code to make everything work on different platforms is a bit nasty, but I don't think thats achievable at the moment.

Pretty sure this was never about dwdp and always about https://github.com/ICB-DCM/AMICI/blob/390305f98c96ea505cf52884991774e7dfefdeff/src/sundials_matrix_wrapper.cpp#L209

FFroehlich avatar May 06 '20 21:05 FFroehlich

Okay, then we postpone this one here, as currently, there is nothing to be done.

paulstapor avatar May 06 '20 21:05 paulstapor

Of course there is something to be done, the code I linked is still in place and could be replaced by SUNMatMatvec.

FFroehlich avatar May 06 '20 21:05 FFroehlich

Doesn't make much sense (anymore?). For dense matrices, we use dgemv which is as good as it gets. For most other cases we'd have to construct temporary NVectors, as many of the inputs are std::vector or span. So changing that would really improve anything. Also SUNMatMatvec computes y = Ax + b, whereas we mostly want y+= Ax + b. Closing.

dweindl avatar Feb 24 '23 17:02 dweindl