-
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][spblas] Update sparse blas API #522
Conversation
Update sparse blas API to better support other backends.
source/elements/oneMKL/source/domains/spblas/operations/spsv.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/destroy_sparse_matrix.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/set_matrix_property.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/set_matrix_property.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/set_matrix_property.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/supported-types.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/sparse_linear_algebra.inc.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/create_coo_matrix.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/create_coo_matrix.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/format-descriptions.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/format-descriptions.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/operations/spmm.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/operations/spmv.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/operations/spmv.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/operations/spsv.rst
Outdated
Show resolved
Hide resolved
Can you share your motivation for introducing the |
@andrewtbarker, both cuSPARSE and rocSPARSE have introduced "generic APIs" in the last few years. These contain (likely lightweight) wrappers over dense matrices. For example, see section 6.4. Dense Matrix APIs of cuSPARSE documentation. Mainly, the wrapper stores While I agree that the dense BLAS domain does not have such wrappers over dense matrices, the APIs in the sparse domain look cleaner with these wrappers. Without these wrappers, implementations of the oneAPI specification that dispatch to cuSPARSE/rocSPARSE APIs in the backend must repeatedly create and destroy the dense matrix wrapper object any and every time their API is called. The BLAS domain is fortunately well-standardized, so adding |
@gajanan-choudhary Thanks for your explanation, that makes a lot of sense. My only remaining concern would be to make sure that the actual data in the |
We will want to have constructors that can take an
using whatever our internal representation is to construct an mdspan from our internal matrix representation, since that is the direction of C++ for dense linear algebra (whenever we start supporting mdspans :) ) ... likewise an of course it might be that we need to return a slightly more complicated mdspan with the layout and user defined strides, but that is the idea, that it is easily interpreted as an mdspan, so it can be immediately plugged into any other function that uses mdspans. These really could be thought of as a dense_matrix_view_t or dense_vector_view_t which are lightweight and non-owning ... so maybe we want to reconsider our name "handle" (C style name) to switch over to "view" which is C++ style name indicating it is a wrapper object that is lightweight and non-owning... |
Co-authored-by: HJA Bird <[email protected]>
Co-authored-by: HJA Bird <[email protected]>
source/elements/oneMKL/source/domains/sparse_linear_algebra.inc.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/sparse_linear_algebra.inc.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/sparse_linear_algebra.inc.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/destroy_sparse_matrix.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/create_coo_matrix.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/create_coo_matrix.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/create_coo_matrix.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/create_coo_matrix.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/create_coo_matrix.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/create_coo_matrix.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/create_dense_matrix.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/create_dense_matrix.rst
Outdated
Show resolved
Hide resolved
source/elements/oneMKL/source/domains/spblas/data_types/destroy_dense_matrix.rst
Outdated
Show resolved
Hide resolved
| For COO this guarantees that that the row indices are sorted in | ||
ascending order. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need column indices to also be sorted within the row sets for COO format?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a question for @gajanan-choudhary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, column indices should also be sorted. In Excel speak, that's "Sort by rowptr
then by colind
". If we were okay with COO column indices not being sorted, we wouldn't have a sorted
property for CSR
matrices. If we have to deal with unsorted COO column indices some day, we can pick a new enum name and add it in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I clarified this in 669a4e7
I have reverted a modification on |
source/elements/oneMKL/source/domains/spblas/operations/spsv.rst
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few unresolved threads, but I'm going ahead and adding my approval. I think we are in a decent shape and very close to merging in this PR.
I would suggest keeping this PR open for a while, at least till all review comments are resolved. @Rbiessy can continue working on an implementation expecting no major changes going forward unless big glaring mistakes pop up, which I don't foresee having done multiple passes of reviews for this PR. If there are any mistakes or things missed out, we will have time till whenever the next release of the oneAPI specification is created.
@rscohn2, please make a note that the next oneAPI version, whenever that is, will need a major version change to 2.x once this PR is merged in.
Great work here, @Rbiessy. Thank you everyone for your reviews, it took us a long time and a lot of effort to get to these spec changes! Cheers!
I added clarifications to the description of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work, putting all this together! I approve of this pull request!
Thank you @spencerpatty and thanks for the reviews! |
it appears that all build checks have passed, whenever @gajanan-choudhary and @Rbiessy decide it is time to merge, let me know, and I will pull the trigger :) |
Thank you @spencerpatty this is ready to be merged as far as I am concerned! |
Feel free to merge this, @spencerpatty. |
Update the sparse blas API to better support other sparse backends.
This is a large change to the existing sparse API. Most notable changes are:
gemv
,symv
andtrmv
tospmv
operation;gemm
is renamed tospmm
;trsv
is renamed tospsv
.gemvdot
as there didn't seem to be enough use-cases nor support in other backends.*_buffer_size
functions.I have rendered the spec in html and verified it looks sane.
@gajanan-choudhary and @spencerpatty FYI.