-
Notifications
You must be signed in to change notification settings - Fork 116
[oneMKL][spblas] Update sparse blas API #522
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
Merged
Merged
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
8b413e1
[oneMKL][spblas] Update sparse blas API
Rbiessy 3e5c258
Reword high level sparse_blas domain page
Rbiessy 0b92a22
Fix set_dense_vector_data alignment
Rbiessy ce62ad3
Rename template types to dataType and indexType
Rbiessy 52a3a6e
Add comma
Rbiessy c272e3f
Capitalize acronym
Rbiessy e6811a4
Remove /
Rbiessy 96bee85
Clarify non-zero entries
Rbiessy 2545e7b
Add requirements on workspace alignment
Rbiessy 6db7514
Clarify alpha and beta type
Rbiessy fda672d
Do not italicise T and H
Rbiessy 2b00cf5
Reword and format spsv description
Rbiessy c863160
Reorder operations alphabetically
Rbiessy 8a8f675
Replace occurences of sparse_matrix_handle_t with matrix_handle_t
Rbiessy 13825be
Reword sparse_linear_algebra paragraph
Rbiessy c61ff7e
Avoid variable names in high level create_* functions description
Rbiessy 13dd2e5
Clarify that container sizes are minimum sizes
Rbiessy ad83d1c
Clarify requirements on the COO and CSR sizes
Rbiessy b7037b5
Document that using smaller USM pointer is undefined behavior
Rbiessy 4db05aa
Remove onemkl_exception_device_bad_alloc from create_* and set_*_data…
Rbiessy 90c4cec
Fix matrix_view todo
Rbiessy 0942926
Fix diagonal property description
Rbiessy dd541fe
Use bitmask for matrix properties
Rbiessy 4b66461
Keep sparse_linear_algebra vague
Rbiessy 81b8be5
Restrict workspace from being sub-buffers
Rbiessy 652bfe7
Add no_optimize_alg and remove algorithms tables
Rbiessy c22684f
Remove trailing commas
Rbiessy 02013d5
Make destroy and release functions aynchronous
Rbiessy b4c2a46
Update sorted description
Rbiessy 0f7c767
Remove restriction on create_*_matrix to support multiple calls with …
Rbiessy 15139cc
Make uplo_view description match with diag_view
Rbiessy 7c34155
Rephrase operation descriptions
Rbiessy 3ab3c5e
Clarifications on workspace
Rbiessy 1cbd268
Clarify temp_buffer_size is the minimum workspace size
Rbiessy d0393b1
Minor fixes and rewording
Rbiessy 4128a65
Rename create_* and destroy_* functions to init_* and release_*
Rbiessy ed39695
More rewording regarding nnz
Rbiessy 32e43ff
Make alpha and beta const
Rbiessy 15ec0e5
Clarify that optimize functions can reset the descriptor's data
Rbiessy 16ed109
Remove references from buffers
Rbiessy 9a422f6
Merge branch 'main' into romain/sparse_api
Rbiessy 1060c7a
Clarify container types must be consistent
Rbiessy 51e4068
Clarify restrictions to reset handles' data
Rbiessy ebc779c
Add comment on COO performance
Rbiessy 7247b6d
Clarify matrix_properties are hints
Rbiessy 38dbaef
Fix typos
Rbiessy ac1b223
Add note on operations' descriptor
Rbiessy 1292ad6
Revert to set_matrix_property
Rbiessy e279fa3
Specify that dependencies and events may be unused for buffers
Rbiessy 669a4e7
Clarify sorted property for COO format
Rbiessy 8f94f4d
Add more notes on the purpose of the operation descriptors
Rbiessy 1c236f7
Disallow changing sparse matrices before calling gemm or gemv
Rbiessy 62bbc6e
Fix warning
Rbiessy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
source/elements/oneMKL/source/domains/spblas/data_types/data_handles.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
.. SPDX-FileCopyrightText: 2024 Intel Corporation | ||
.. | ||
.. SPDX-License-Identifier: CC-BY-4.0 | ||
|
||
.. _onemkl_sparse_data_handles: | ||
|
||
Data handles | ||
============ | ||
|
||
.. _onemkl_sparse_dense_vector_handle: | ||
|
||
Dense vector handle | ||
------------------- | ||
|
||
.. rubric:: Definition | ||
|
||
.. code-block:: cpp | ||
|
||
namespace oneapi::mkl::sparse { | ||
|
||
struct dense_vector_handle; | ||
using dense_vector_handle_t = dense_vector_handle*; | ||
|
||
} | ||
|
||
.. container:: section | ||
|
||
.. rubric:: Description | ||
|
||
Defines ``dense_vector_handle_t`` as an opaque pointer to the incomplete type | ||
``dense_vector_handle``. Each backend may provide a different | ||
implementation of the type ``dense_vector_handle``. | ||
|
||
See related functions: | ||
|
||
- :ref:`onemkl_sparse_init_dense_vector` | ||
- :ref:`onemkl_sparse_set_dense_vector_data` | ||
- :ref:`onemkl_sparse_release_dense_vector` | ||
|
||
.. _onemkl_sparse_dense_matrix_handle: | ||
|
||
Dense matrix handle | ||
------------------- | ||
|
||
.. rubric:: Definition | ||
|
||
.. code-block:: cpp | ||
|
||
namespace oneapi::mkl::sparse { | ||
|
||
struct dense_matrix_handle; | ||
using dense_matrix_handle_t = dense_matrix_handle*; | ||
|
||
} | ||
|
||
.. container:: section | ||
|
||
.. rubric:: Description | ||
|
||
Defines ``dense_matrix_handle_t`` as an opaque pointer to the incomplete type | ||
``dense_matrix_handle``. Each backend may provide a different | ||
implementation of the type ``dense_matrix_handle``. | ||
|
||
See related functions: | ||
|
||
- :ref:`onemkl_sparse_init_dense_matrix` | ||
- :ref:`onemkl_sparse_set_dense_matrix_data` | ||
- :ref:`onemkl_sparse_release_dense_matrix` | ||
|
||
.. _onemkl_sparse_matrix_handle: | ||
|
||
Sparse matrix handle | ||
-------------------- | ||
|
||
.. rubric:: Definition | ||
|
||
.. code-block:: cpp | ||
|
||
namespace oneapi::mkl::sparse { | ||
|
||
struct matrix_handle; | ||
using matrix_handle_t = matrix_handle*; | ||
|
||
} | ||
|
||
.. container:: section | ||
|
||
.. rubric:: Description | ||
|
||
Defines ``matrix_handle_t`` as an opaque pointer to the incomplete type | ||
``matrix_handle``. Each backend may provide a different | ||
implementation of the type ``matrix_handle``. | ||
|
||
See related functions: | ||
|
||
- :ref:`onemkl_sparse_init_coo_matrix` | ||
- :ref:`onemkl_sparse_init_csr_matrix` | ||
- :ref:`onemkl_sparse_set_coo_matrix_data` | ||
- :ref:`onemkl_sparse_set_csr_matrix_data` | ||
- :ref:`onemkl_sparse_set_matrix_property` | ||
- :ref:`onemkl_sparse_release_sparse_matrix` | ||
|
||
See a description of the supported :ref:`sparse formats<onemkl_sparse_format_descriptions>`. | ||
|
||
.. toctree:: | ||
:hidden: | ||
|
||
init_dense_vector | ||
init_dense_matrix | ||
init_coo_matrix | ||
init_csr_matrix | ||
release_dense_vector | ||
release_dense_matrix | ||
release_sparse_matrix | ||
set_dense_vector_data | ||
set_dense_matrix_data | ||
set_coo_matrix_data | ||
set_csr_matrix_data | ||
set_matrix_property | ||
format-descriptions | ||
|
||
**Parent topic:** :ref:`onemkl_spblas` |
155 changes: 155 additions & 0 deletions
155
source/elements/oneMKL/source/domains/spblas/data_types/format-descriptions.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
.. SPDX-FileCopyrightText: 2024 Intel Corporation | ||
.. | ||
.. SPDX-License-Identifier: CC-BY-4.0 | ||
|
||
.. _onemkl_sparse_format_descriptions: | ||
|
||
Sparse storage formats | ||
Rbiessy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
====================== | ||
|
||
There are a variety of matrix storage formats available for representing sparse | ||
matrices. Two popular formats are the coordinate (COO) format, and the | ||
Compressed Sparse Row (CSR) format. | ||
|
||
In this specification, "non-zero" elements or "non-zero" entries refer to | ||
explicitly defined elements or entries which may take any value supported by the | ||
the `:ref:data type<onemkl_sparse_supported_types>`. Undefined elements or | ||
entries are implicitly zeros. | ||
|
||
.. container:: section | ||
|
||
.. _onemkl_sparse_coo: | ||
|
||
.. rubric:: COO | ||
|
||
The COO format is the simplest sparse matrix format, represented by three | ||
arrays, ``row_ind``, ``col_ind`` and ``val``, and an ``index`` parameter. The | ||
``i``-th defined element in the sparse matrix is represented by its row | ||
index, column index, and value, that is, (``row_ind[i]``, ``col_ind[i]``, | ||
``val[i]``). The entries need not be in a sorted order, though performance of | ||
Sparse BLAS operations may be improved if they are sorted in some logical | ||
way, for instance by row index and then column index subordinate to each row | ||
set. | ||
|
||
.. container:: tablenoborder | ||
|
||
.. list-table:: | ||
|
||
* - num_rows | ||
- Number of rows in the sparse matrix. | ||
* - num_cols | ||
- Number of columns in the sparse matrix. | ||
* - nnz | ||
- Number of non-zero entries in the sparse matrix. This is also the | ||
length of the ``row_ind``, ``col_ind`` and ``val`` arrays. | ||
* - index | ||
- Parameter that is used to specify whether the matrix has zero or | ||
one-based indexing. | ||
* - val | ||
- An array of length ``nnz`` that contains the non-zero elements of | ||
the sparse matrix not necessarily in any sorted order. | ||
* - row_ind | ||
- An integer array of length ``nnz``. Contains row indices for | ||
non-zero elements stored in the ``val`` array such that | ||
``row_ind[i]`` is the row number (using zero- or one-based | ||
indexing) of the element of the sparse matrix stored in ``val[i]``. | ||
* - col_ind | ||
- An integer array of length ``nnz``. Contains column indices for | ||
non-zero elements stored in the ``val`` array such that | ||
``col_ind[i]`` is the column number (using zero- or one-based | ||
indexing) of the element of the sparse matrix stored in ``val[i]``. | ||
|
||
A sparse matrix can be represented in a COO format in a following way (assuming | ||
one-based indexing): | ||
|
||
.. math:: | ||
A = \left(\begin{matrix} | ||
1 & 0 & 2\\ | ||
0 & -1 & 4\\ | ||
3 & 0 & 0\\ | ||
\end{matrix}\right) | ||
|
||
+------------+------------------------------------------------------------+ | ||
| num_rows | 3 | | ||
+------------+------------------------------------------------------------+ | ||
| num_cols | 3 | | ||
+------------+------------------------------------------------------------+ | ||
| nnz | 5 | | ||
+------------+------------------------------------------------------------+ | ||
| index | 1 | | ||
+------------+------------+-----------+-----------+-----------+-----------+ | ||
| row_ind | 1 | 1 | 2 | 2 | 3 | | ||
+------------+------------+-----------+-----------+-----------+-----------+ | ||
| col_ind | 1 | 3 | 2 | 3 | 1 | | ||
+------------+------------+-----------+-----------+-----------+-----------+ | ||
| val | 1 | 2 | -1 | 4 | 3 | | ||
+------------+------------+-----------+-----------+-----------+-----------+ | ||
|
||
.. container:: section | ||
|
||
.. _onemkl_sparse_csr: | ||
|
||
.. rubric:: CSR | ||
|
||
The CSR format is one of the most popular sparse matrix storage formats, | ||
represented by three arrays, ``row_ptr``, ``col_ind`` and ``val``, and an | ||
``index`` parameter. | ||
|
||
.. container:: tablenoborder | ||
|
||
.. list-table:: | ||
|
||
* - num_rows | ||
- Number of rows in the sparse matrix. | ||
* - num_cols | ||
- Number of columns in the sparse matrix. | ||
* - nnz | ||
- Number of non-zero entries in the sparse matrix. This is also the | ||
length of the ``col_ind`` and ``val`` arrays. | ||
* - index | ||
- Parameter that is used to specify whether the matrix has zero or | ||
one-based indexing. | ||
* - val | ||
- An array of length ``nnz`` that contains the non-zero elements of | ||
the sparse matrix stored row by row. | ||
* - col_ind | ||
- An integer array of length ``nnz``. Contains column indices for | ||
non-zero elements stored in the ``val`` array such that | ||
``col_ind[i]`` is the column number (using zero- or one-based | ||
indexing) of the element of the sparse matrix stored in ``val[i]``. | ||
* - row_ptr | ||
- An integer array of size equal to ``num_rows + 1``. Element ``j`` | ||
of this integer array gives the position of the element in the | ||
``val`` array that is first non-zero element in a row ``j`` of | ||
``A``. Note that this position is equal to ``row_ptr[j] - index``. | ||
Last element of the ``row_ptr`` array (``row_ptr[num_rows]``) | ||
stores the sum of, number of non-zero elements and ``index`` | ||
(``nnz + index``). | ||
|
||
A sparse matrix can be represented in a CSR format in a following way (assuming | ||
zero-based indexing): | ||
|
||
.. math:: | ||
A = \left(\begin{matrix} | ||
1 & 0 & 2\\ | ||
0 & -1 & 4\\ | ||
3 & 0 & 0\\ | ||
\end{matrix}\right) | ||
|
||
+------------+------------------------------------------------------------+ | ||
| num_rows | 3 | | ||
+------------+------------------------------------------------------------+ | ||
| num_cols | 3 | | ||
+------------+------------------------------------------------------------+ | ||
| nnz | 5 | | ||
+------------+------------------------------------------------------------+ | ||
| index | 0 | | ||
+------------+------------+-----------+-----------+-----------+-----------+ | ||
| row_ptr | 0 | 2 | 4 | 5 | | | ||
+------------+------------+-----------+-----------+-----------+-----------+ | ||
| col_ind | 0 | 2 | 1 | 2 | 0 | | ||
+------------+------------+-----------+-----------+-----------+-----------+ | ||
| val | 1 | 2 | -1 | 4 | 3 | | ||
+------------+------------+-----------+-----------+-----------+-----------+ | ||
|
||
**Parent topic:** :ref:`onemkl_sparse_data_handles` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.