-
Notifications
You must be signed in to change notification settings - Fork 110
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
oneMKL functions taking multiple buffers and their aliasing/overlapping #464
Comments
So, according to this reply in the intel onemkl forum, it is not allowed. But I got that information quite randomly, and only for the intel's onemkl. Still not sure how it should work, and where to find that information. |
@jakub-homola Thanks for the question. It is hard to answer for all oneMKL since each domain might have different requirements/restrictions. I pinged @spencerpatty for your question on sparse::trsv. For BLAS side, it is ok to pass the same buffer for input and output - like matrix C in GEMM. Regarding overlap or alias questions, I am pinging @petercad. |
Hi @jakub-homola, thanks for raising this issue! You're right, the spec should explain which arguments (if any) are allowed to alias. For (non-sparse) BLAS routines, no overlap is allowed between an output matrix/vector and any other matrix/vector arguments. This is the standard convention for BLAS, but we should spell that out. I had meant to add that to the spec but forgot, so thanks for the reminder :) We'll take care of that. |
Hi @jakub-homola this is an interesting question. So the TRSV operation is solving (lets focus on lower solve) for y in the system "L * y = x". You are asking if x and y can be the same array. That is, you are asking if you can triangular solve for y in "L * y = y". To me, mathematically this operation no longer makes sense if L is not an identity matrix or y is not an eigenvector corresponding to an eigenvalue lambda = 1 to begin with. Practically, you could put the same array into the function as x and y and it might do something, but lets think a bit about what it might actually be doing... The traditional CSR matrix sparse TRSV (L = rowptr, colind, vals CSR arrays and an extra invDiag array) algorithm is a variant (adding parallelism respecting the L sparsity pattern) of the following steps
or more simply thinking in 2D dense matrix terms
so it looks like if x[i] is being implicitly updated when we change y[i], then maybe it actually does nothing to affect the end result (y output) for this algorithm... so maybe it turns out ok in this particular case. In general, we don't envision the input/output matrices or vectors being the same array or overlapped in sparse BLAS either. We should spell it out as well in our documentation. |
I updated my previous response with a better answer, but updates don't get sent out with notice, so I am triggering a notice with this comment, in case it helps :) |
Hi, Anyway, thanks everyone for the info that the arrays cannot alias/overlap/be the same. Looking forward to the spec/documentation update. |
Hi,
can we pass the same buffer as input and output argument of oneMKL functions? Is "buffer aliasing" allowed?
E.g. the function
oneapi::mkl::sparse::trsv
. It takes multiple buffers as arguments, namely the input right-hand-side vector and the output solution vector. Can I pass the same buffer for both of these arguments? (mimicking theoneapi::mkl::blas::row_major::trsv
behaviour, where there is just one argument for that) (experimentally tested with intel onemkl and it works, but don't know if it is a guarantee).In general, can buffers passed to oneMKL functions overlap, alias, or be the same? I could not find any information about this in the spec (https://spec.oneapi.io/versions/1.2-rev-1/elements/oneMKL/source/domains/spblas/trsv.html and other pages on that site). Is it specified somewhere?
This might also apply to other one* libraries, but I am not familiar with them.
Thanks,
Jakub
The text was updated successfully, but these errors were encountered: