Skip to content

Commit 057d192

Browse files
[oneMKL][SpBLAS] Add nnz arg to oneapi::mkl::sparse::set_csr_data() API (#512)
* [oneMKL][SpBLAS] Add `nnz` arg to `oneapi::mkl::sparse::set_csr_data()` API * [oneMKL][SpBLAS] Add `const`-ness to `nrows`, `ncols`, `nnz` args in `set_csr_data`
1 parent 6653e2f commit 057d192

File tree

2 files changed

+55
-35
lines changed

2 files changed

+55
-35
lines changed

source/elements/oneMKL/source/domains/spblas/format-descriptions.rst

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,28 @@ Sparse storage formats
2323

2424
.. list-table::
2525

26-
* - num_rows
26+
* - nrows
2727
- Number of rows in the sparse matrix.
28-
* - num_cols
28+
* - ncols
2929
- Number of columns in the sparse matrix.
30+
* - nnz
31+
- Number of non-zero entries in the sparse matrix (which may include explicit zeros).
32+
This is also the length of the *col_ind* and *val* arrays.
3033
* - index
3134
- Parameter that is used to specify whether the matrix has zero or one-based indexing.
3235
* - val
33-
- An array that contains the non-zero elements of the sparse matrix stored row by row.
36+
- An array of length ``nnz`` that contains the non-zero elements of the sparse matrix
37+
stored row by row.
3438
* - col_ind
35-
- An integer array of column indices for non-zero elements stored in the *val* array,
36-
such that *col_ind[i]* is the column number (using zero- or one-based indexing) of the
37-
element of the sparse matrix stored in *val[i]*.
39+
- An integer array of length ``nnz``. Contains column indices for non-zero elements
40+
stored in the *val* array such that *col_ind[i]* is the column number (using zero-
41+
or one-based indexing) of the element of the sparse matrix stored in *val[i]*.
3842
* - row_ptr
39-
- An integer array of size equal to ``num_rows + 1``. Element j of this integer array
43+
- An integer array of size equal to ``nrows + 1``. Element j of this integer array
4044
gives the position of the element in the *val* array that is first non-zero element in a
4145
row j of A. Note that this position is equal to *row_ptr[j] - index*. Last element of
42-
the *row_ptr* array (*row_ptr[num_rows]*) stores the sum of,
43-
number of nonzero elements and *index*(number of nonzero elements + *index*).
46+
the *row_ptr* array (*row_ptr[nrows]*) stores the sum of,
47+
number of nonzero elements and *index* (*nnz* + *index*).
4448

4549

4650
A sparse matrix can be represented in a CSR format in a following way (assuming zero-based indexing):
@@ -54,9 +58,11 @@ A sparse matrix can be represented in a CSR format in a following way (assuming
5458
5559
5660
+------------+------------------------------------------------------------+
57-
| num_rows | 3 |
61+
| nrows | 3 |
5862
+------------+------------------------------------------------------------+
59-
| num_cols | 3 |
63+
| ncols | 3 |
64+
+------------+------------------------------------------------------------+
65+
| nnz | 5 |
6066
+------------+------------------------------------------------------------+
6167
| index | 0 |
6268
+------------+------------+-----------+-----------+-----------+-----------+
@@ -74,4 +80,4 @@ A sparse matrix can be represented in a CSR format in a following way (assuming
7480
.. container:: parentlink
7581

7682

77-
**Parent topic:** :ref:`onemkl_spblas`
83+
**Parent topic:** :ref:`onemkl_spblas`

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

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Takes a matrix handle and the input CSR matrix arrays and fills the internal CSR
1515
Refer to :ref:`onemkl_sparse_supported_types` for a
1616
list of supported ``<fp>`` and ``<intType>``.
1717
The mkl::sparse::set_csr_data routine takes a matrix handle
18-
for a sparse matrix of dimensions *num_rows* -by- *num_cols*
18+
for a sparse matrix of dimensions *nrows* -by- *ncols*
1919
represented in the CSR format, and fills the internal
2020
CSR data structure.
2121

@@ -33,8 +33,9 @@ set_csr_data (Buffer version)
3333
3434
void set_csr_data (sycl::queue &queue,
3535
oneapi::mkl::sparse::matrix_handle_t handle,
36-
intType num_rows,
37-
intType num_cols,
36+
const intType nrows,
37+
const intType ncols,
38+
const intType nnz,
3839
oneapi::mkl::index_base index,
3940
sycl::buffer<intType, 1> &row_ptr,
4041
sycl::buffer<intType, 1> &col_ind,
@@ -54,14 +55,19 @@ set_csr_data (Buffer version)
5455
data for subsequent DPC++ Sparse BLAS operations.
5556

5657

57-
num_rows
58+
nrows
5859
Number of rows of the input matrix .
5960

6061

61-
num_cols
62+
ncols
6263
Number of columns of the input matrix .
6364

6465

66+
nnz
67+
Number of non-zero entries in the matrix (which may include explicit
68+
zeros).
69+
70+
6571
index
6672
Indicates how input arrays are indexed.
6773
The possible options are
@@ -70,21 +76,22 @@ set_csr_data (Buffer version)
7076

7177
row_ptr
7278
SYCL memory object containing an array of length
73-
``num_rows+1``. Refer to :ref:`onemkl_sparse_csr` format
79+
``nrows+1``. Refer to :ref:`onemkl_sparse_csr` format
7480
for detailed description of ``row_ptr``.
7581

7682

7783
col_ind
78-
SYCL memory object which stores an array containing the
79-
column indices in ``index``-based numbering.
84+
SYCL memory object which stores an array of length ``nnz``
85+
containing the column indices in ``index``-based numbering.
8086
Refer to :ref:`onemkl_sparse_csr` format for detailed
8187
description of ``col_ind``.
8288

8389

8490
val
85-
SYCL memory object which stores an array containing
86-
non-zero elements of the input matrix. Refer to
87-
:ref:`onemkl_sparse_csr` format for detailed description of ``val``.
91+
SYCL memory object which stores an array of length ``nnz``
92+
containing non-zero elements (and possibly explicit zeros) of the
93+
input matrix. Refer to :ref:`onemkl_sparse_csr` format for detailed
94+
description of ``val``.
8895

8996

9097
.. container:: section
@@ -128,8 +135,9 @@ set_csr_data (USM version)
128135
129136
sycl::event set_csr_data (sycl::queue &queue,
130137
oneapi::mkl::sparse::matrix_handle_t handle,
131-
intType num_rows,
132-
intType num_cols,
138+
const intType nrows,
139+
const intType ncols,
140+
const intType nnz,
133141
oneapi::mkl::index_base index,
134142
intType *row_ptr,
135143
intType *col_ind,
@@ -150,12 +158,17 @@ set_csr_data (USM version)
150158
data for subsequent DPC++ Sparse BLAS operations.
151159

152160

153-
num_rows
154-
Number of rows of the input matrix .
161+
nrows
162+
Number of rows of the input matrix.
155163

156164

157-
num_cols
158-
Number of columns of the input matrix .
165+
ncols
166+
Number of columns of the input matrix.
167+
168+
169+
nnz
170+
Number of non-zero entries in the matrix (which may include explicit
171+
zeros).
159172

160173

161174
index
@@ -166,21 +179,22 @@ set_csr_data (USM version)
166179

167180
row_ptr
168181
USM object containing an array of length
169-
``num_rows+1``. Refer to :ref:`onemkl_sparse_csr` format for
182+
``nrows+1``. Refer to :ref:`onemkl_sparse_csr` format for
170183
detailed description of ``row_ptr``
171184

172185

173186
col_ind
174-
USM object which stores an array containing the
175-
column indices in ``index``-based numbering.
187+
USM object which stores an array of length ``nnz``
188+
containing the column indices in ``index``-based numbering.
176189
Refer to :ref:`onemkl_sparse_csr` format for detailed
177190
description of ``col_ind``
178191

179192

180193
val
181-
USM object which stores an array containing
182-
non-zero elements of the input matrix. Refer to
183-
:ref:`onemkl_sparse_csr` format for detailed description of ``val``
194+
USM object which stores an array of length ``nnz``
195+
containing non-zero elements (and possibly explicit zeros) of the
196+
input matrix. Refer to :ref:`onemkl_sparse_csr` format for
197+
detailed description of ``val``
184198

185199
dependencies
186200
A vector of type const std::vector<sycl::event> & containing the list of events

0 commit comments

Comments
 (0)