Skip to content

Commit e635a6a

Browse files
authored
[oneMKL][spblas] Restrict features not supported by any backends (#542)
* Require same types for all handles * Clarify when should the data be available on device * Clarify the behavior of calling functions in the wrong order * Clarify when exceptions are thrown
1 parent 616f2e7 commit e635a6a

File tree

8 files changed

+65
-39
lines changed

8 files changed

+65
-39
lines changed

source/elements/oneMKL/source/domains/spblas/data_types/set_coo_matrix_data.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ set_coo_matrix_data (Buffer version)
5252
.. rubric:: Template parameters
5353

5454
dataType
55-
See :ref:`supported template types<onemkl_sparse_supported_types>`. Can be
56-
a different type than what was used when creating the ``matrix_handle_t``.
55+
See :ref:`supported template types<onemkl_sparse_supported_types>`. Must
56+
be the same type as was used when creating the ``matrix_handle_t``.
5757

5858
indexType
59-
See :ref:`supported template types<onemkl_sparse_supported_types>`. Can be
60-
a different type than what was used when creating the ``matrix_handle_t``.
59+
See :ref:`supported template types<onemkl_sparse_supported_types>`. Must
60+
be the same type as was used when creating the ``matrix_handle_t``.
6161

6262
.. container:: section
6363

@@ -150,12 +150,12 @@ set_coo_matrix_data (USM version)
150150
.. rubric:: Template parameters
151151

152152
dataType
153-
See :ref:`supported template types<onemkl_sparse_supported_types>`. Can be
154-
a different type than what was used when creating the ``matrix_handle_t``.
153+
See :ref:`supported template types<onemkl_sparse_supported_types>`. Must
154+
be the same type as was used when creating the ``matrix_handle_t``.
155155

156156
indexType
157-
See :ref:`supported template types<onemkl_sparse_supported_types>`. Can be
158-
a different type than what was used when creating the ``matrix_handle_t``.
157+
See :ref:`supported template types<onemkl_sparse_supported_types>`. Must
158+
be the same type as was used when creating the ``matrix_handle_t``.
159159

160160
.. container:: section
161161

source/elements/oneMKL/source/domains/spblas/data_types/set_csr_matrix_data.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ set_csr_matrix_data (Buffer version)
5252
.. rubric:: Template parameters
5353

5454
dataType
55-
See :ref:`supported template types<onemkl_sparse_supported_types>`. Can be
56-
a different type than what was used when creating the ``matrix_handle_t``.
55+
See :ref:`supported template types<onemkl_sparse_supported_types>`. Must
56+
be the same type as was used when creating the ``matrix_handle_t``.
5757

5858
indexType
59-
See :ref:`supported template types<onemkl_sparse_supported_types>`. Can be
60-
a different type than what was used when creating the ``matrix_handle_t``.
59+
See :ref:`supported template types<onemkl_sparse_supported_types>`. Must
60+
be the same type as was used when creating the ``matrix_handle_t``.
6161

6262
.. container:: section
6363

@@ -149,12 +149,12 @@ set_csr_matrix_data (USM version)
149149
.. rubric:: Template parameters
150150

151151
dataType
152-
See :ref:`supported template types<onemkl_sparse_supported_types>`. Can be
153-
a different type than what was used when creating the ``matrix_handle_t``.
152+
See :ref:`supported template types<onemkl_sparse_supported_types>`. Must
153+
be the same type as was used when creating the ``matrix_handle_t``.
154154

155155
indexType
156-
See :ref:`supported template types<onemkl_sparse_supported_types>`. Can be
157-
a different type than what was used when creating the ``matrix_handle_t``.
156+
See :ref:`supported template types<onemkl_sparse_supported_types>`. Must
157+
be the same type as was used when creating the ``matrix_handle_t``.
158158

159159
.. container:: section
160160

source/elements/oneMKL/source/domains/spblas/data_types/set_dense_matrix_data.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ set_dense_matrix_data (Buffer version)
5050
.. rubric:: Template parameters
5151

5252
dataType
53-
See :ref:`supported template types<onemkl_sparse_supported_types>`. Can be
54-
a different type than what was used when creating the
55-
``dense_matrix_handle_t``.
53+
See :ref:`supported template types<onemkl_sparse_supported_types>`. Must
54+
be the same type as was used when creating the ``dense_matrix_handle_t``.
5655

5756
.. container:: section
5857

@@ -123,9 +122,8 @@ set_dense_matrix_data (USM version)
123122
.. rubric:: Template parameters
124123

125124
dataType
126-
See :ref:`supported template types<onemkl_sparse_supported_types>`. Can be
127-
a different type than what was used when creating the
128-
``dense_matrix_handle_t``.
125+
See :ref:`supported template types<onemkl_sparse_supported_types>`. Must
126+
be the same type as was used when creating the ``dense_matrix_handle_t``.
129127

130128
.. container:: section
131129

source/elements/oneMKL/source/domains/spblas/data_types/set_dense_vector_data.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@ set_dense_vector_data (Buffer version)
4747
.. rubric:: Template parameters
4848

4949
dataType
50-
See :ref:`supported template types<onemkl_sparse_supported_types>`. Can be
51-
a different type than what was used when creating the
52-
``dense_vector_handle_t``.
50+
See :ref:`supported template types<onemkl_sparse_supported_types>`. Must
51+
be the same type as was used when creating the ``dense_vector_handle_t``.
5352

5453
.. container:: section
5554

@@ -105,9 +104,8 @@ set_dense_vector_data (USM version)
105104
.. rubric:: Template parameters
106105

107106
dataType
108-
See :ref:`supported template types<onemkl_sparse_supported_types>`. Can be
109-
a different type than what was used when creating the
110-
``dense_vector_handle_t``.
107+
See :ref:`supported template types<onemkl_sparse_supported_types>`. Must
108+
be the same type as was used when creating the ``dense_vector_handle_t``.
111109

112110
.. container:: section
113111

source/elements/oneMKL/source/domains/spblas/matrix_view.rst

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,8 @@ matrix_view
8484
See :ref:`onemkl_sparse_matrix_descriptor`, :ref:`onemkl_enum_uplo` and
8585
:ref:`onemkl_enum_diag` for a description of the members.
8686

87-
The ``uplo_view`` member is ignored if ``type_view`` is ``general`` or
88-
``diagonal``.
89-
90-
The ``diag_view`` member is ignored if ``type_view`` is ``general``.
87+
Each operation documents which combination of ``type_view``, ``uplo_view``
88+
and ``diag_view`` are valid.
9189

9290
.. rubric:: Syntax
9391

@@ -124,7 +122,4 @@ matrix_view
124122
the other members are initialized to the same value as the default
125123
constructor.
126124

127-
If the ``matrix_desc`` is ``diagonal``, ``diag_view`` is initialized to
128-
``diag::unit``.
129-
130125
**Parent topic:** :ref:`onemkl_spblas`

source/elements/oneMKL/source/domains/spblas/operations/spmm.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,19 @@ spmm
273273
before ``spmm`` with the same arguments. ``spmm`` can then be called
274274
multiple times. Calling ``spmm_optimize`` on the same descriptor can reset
275275
some of the descriptor's data such as the ``workspace``.
276+
- In the general case, not calling the functions in the order specified above
277+
is undefined behavior. Not calling ``spmm_buffer_size`` or
278+
``spmm_optimize`` at least once with a given descriptor will throw an
279+
:ref:`oneapi::mkl::uninitialized<onemkl_exception_uninitialized>`
280+
exception. Calling ``spmm`` with arguments not matching ``spmm_optimize``
281+
will throw an
282+
:ref:`oneapi::mkl::invalid_argument<onemkl_exception_invalid_argument>`
283+
exception, unless stated otherwise.
276284
- The data of the dense handles ``B_handle`` and ``C_handle`` and the scalars
277285
``alpha`` and ``beta`` can be reset before each call to ``spmm``. Changing
278286
the data of the sparse handle ``A_handle`` is undefined behavior.
287+
- The data must be available on the device when calling ``spmm_optimize`` by
288+
using event dependencies if needed.
279289
- ``spmm_optimize`` and ``spmm`` are asynchronous.
280290
- The algorithm defaults to ``spmm_alg::default_alg`` if a backend does not
281291
support the provided algorithm.
@@ -305,7 +315,9 @@ spmm
305315

306316
A_view
307317
Specifies which part of the handle should be read as described by
308-
:ref:`onemkl_sparse_matrix_view`.
318+
:ref:`onemkl_sparse_matrix_view`. The ``type_view`` field must be
319+
``matrix_descr::general`` and the ``uplo_view`` and ``diag_view`` fields
320+
are ignored.
309321

310322
A_handle
311323
Sparse matrix handle object representing :math:`A`.

source/elements/oneMKL/source/domains/spblas/operations/spmv.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,19 @@ spmv
267267
before ``spmv`` with the same arguments. ``spmv`` can then be called
268268
multiple times. Calling ``spmv_optimize`` on the same descriptor can reset
269269
some of the descriptor's data such as the ``workspace``.
270+
- In the general case, not calling the functions in the order specified above
271+
is undefined behavior. Not calling ``spmv_buffer_size`` or
272+
``spmv_optimize`` at least once with a given descriptor will throw an
273+
:ref:`oneapi::mkl::uninitialized<onemkl_exception_uninitialized>`
274+
exception. Calling ``spmv`` with arguments not matching ``spmv_optimize``
275+
will throw an
276+
:ref:`oneapi::mkl::invalid_argument<onemkl_exception_invalid_argument>`
277+
exception, unless stated otherwise.
270278
- The data of the dense handles ``x_handle`` and ``y_handle`` and the scalars
271279
``alpha`` and ``beta`` can be reset before each call to ``spmv``. Changing
272280
the data of the sparse handle ``A_handle`` is undefined behavior.
281+
- The data must be available on the device when calling ``spmv_optimize`` by
282+
using event dependencies if needed.
273283
- ``spmv_optimize`` and ``spmv`` are asynchronous.
274284
- The algorithm defaults to ``spmv_alg::default_alg`` if a backend does not
275285
support the provided algorithm.
@@ -295,7 +305,9 @@ spmv
295305

296306
A_view
297307
Specifies which part of the handle should be read as described by
298-
:ref:`onemkl_sparse_matrix_view`.
308+
:ref:`onemkl_sparse_matrix_view`. The ``type_view`` field cannot be
309+
``matrix_descr::diagonal``. The ``diag_view`` field can be ``diag::unit``
310+
if and only if ``type_view`` is ``matrix_descr::triangular``.
299311

300312
A_handle
301313
Sparse matrix handle object representing :math:`A`.

source/elements/oneMKL/source/domains/spblas/operations/spsv.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,19 @@ spsv
258258
before ``spsv`` with the same arguments. ``spsv`` can then be called
259259
multiple times. Calling ``spsv_optimize`` on the same descriptor can reset
260260
some of the descriptor's data such as the ``workspace``.
261+
- In the general case, not calling the functions in the order specified above
262+
is undefined behavior. Not calling ``spsv_buffer_size`` or
263+
``spsv_optimize`` at least once with a given descriptor will throw an
264+
:ref:`oneapi::mkl::uninitialized<onemkl_exception_uninitialized>`
265+
exception. Calling ``spsv`` with arguments not matching ``spsv_optimize``
266+
will throw an
267+
:ref:`oneapi::mkl::invalid_argument<onemkl_exception_invalid_argument>`
268+
exception, unless stated otherwise.
261269
- The data of the dense handle ``x_handle`` and scalar ``alpha`` can be reset
262270
before each call to ``spsv``. Changing the data of the sparse handle
263271
``A_handle`` is undefined behavior.
272+
- The data must be available on the device when calling ``spsv_optimize`` by
273+
using event dependencies if needed.
264274
- ``spsv_optimize`` and ``spsv`` are asynchronous.
265275
- The algorithm defaults to ``spsv_alg::default_alg`` if a backend does not
266276
support the provided algorithm.
@@ -283,8 +293,9 @@ spsv
283293

284294
A_view
285295
Specifies which part of the handle should be read as described by
286-
:ref:`onemkl_sparse_matrix_view`. ``A_view.type_view`` must be
287-
``matrix_descr::triangular`` or ``matrix_descr::diagonal``.
296+
:ref:`onemkl_sparse_matrix_view`. The ``type_view`` field must be
297+
``matrix_descr::triangular``. The ``diag_view`` field can be
298+
``diag::nonunit`` or ``diag::unit``.
288299

289300
A_handle
290301
Sparse matrix handle object representing :math:`A`.

0 commit comments

Comments
 (0)