-
Notifications
You must be signed in to change notification settings - Fork 10
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
Limit the lifetime of the matrix handle to MKLSparse call #52
Conversation
since in some calls trans is also supplied for e.g. B
also adjust their name to match official MKLSparse API
6c06277
to
c7ecd45
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #52 +/- ##
==========================================
+ Coverage 24.86% 32.98% +8.12%
==========================================
Files 7 7
Lines 1693 1258 -435
==========================================
- Hits 421 415 -6
+ Misses 1272 843 -429 ☔ View full report in Codecov by Sentry. |
that needs a manual destroy() call, so that the lifetime of the matrix handle is limited to the wrapper call, and not extended until the GC removes MKLSparseMatrix add S sparse storage type parameter, so that it is automatically known by API calls that need it
c7ecd45
to
c3921b4
Compare
Looks like it doesn't fix #47, as the failure in x64-win is again in COO multiplication. |
Didn't I implemented a |
Exactly, but the finalizer is not called until GC, whereas we don't use MKLSparseMatrix anywhere outside of the "generic" wrapper |
But if you want to perform multiple sparse matrix - vector products like in a Krylov method, you don't want to recreate a |
Currently, MKLSparse does not support it anyway -- MKLSparseMatrix is only created within the generic wrapper, there is no support for passing MKLSparseMatrix to linear algebra methods. I agree that eventually MKLSparse should enable the usecases like you mentioned. |
Thank you @alyst! |
At the moment, the wrapper around the MKLSparse matrix handle,
MKLSparseMatrix
, is mutable, so the handle is destroyed during GC.So far,
MKLSparseMatrix
is created within generic SPBLAS wrapper and not passed outside. The unused handles accumulate until the next GC.What is problematic is that these MKLSparse handles refer to the SparseMatrixCSC arrays allocated by Julia.
These Julia arrays might be already freed at the time of
MKLSparseMatrix
GC, which may lead to undefined behavior (and it could be related to #47).In general, having many unused matrix handles between GC calls may degrade MKLSparse performance.
So this PR converts it to a struct, and the handle must be explicitly destroyed by
destroy(mtx)
call.At the moment the matrix handle is created within the "generic" wrapper and destroyed just after the library MKLSparse call.
Also, it adds
S
sparse matrix storage type parameter:MKLSparseMatrix{S}
.It helps with conversions and extracting data, as MKLSparse does not have API to report the storage type of the matrix handle, it just errors when the handle storage is passed to an incompatible function.
There's also a bit of housekeeping with the generic calls argument names: they are adjusted to match official MKLSparse API,
and since
B
matrices may also have trans descriptor (transB
), the trans-related methods are renamed to avoid confusion.