You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/elements/oneMKL/source/architecture/api_design.inc.rst
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -232,6 +232,32 @@ Each enumeration value comes with two names: A single-character name (the tradit
232
232
- Index arrays for an input matrix are provided using one-based (Fortran style) index values. That is, indices start at 1.
233
233
234
234
235
+
.. _onemkl_enum_layout:
236
+
237
+
.. rubric:: layout
238
+
:name: layout
239
+
:class: sectiontitle
240
+
241
+
The ``layout`` type specifies how a dense matrix ``A`` with leading dimension ``lda`` is stored as one dimensional array in memory.
242
+
The layouts are traditionally provided in one of two forms: C/C++-style using ``row_major`` layout,
243
+
or Fortran-style using ``column_major`` layout. The ``layout`` type can take the following values:
244
+
245
+
.. container:: tablenoborder
246
+
247
+
.. list-table::
248
+
:header-rows: 1
249
+
250
+
* - Short Name
251
+
- Long Name
252
+
- Description
253
+
* - ``layout::R``
254
+
- ``layout::row_major``
255
+
- For row major layout, the elements of each row of a dense matrix ``A`` are contiguous in memory while the elements of each column are at distance ``lda`` from the element in the same column and the previous row.
256
+
* - ``layout::C``
257
+
- ``layout::col_major``
258
+
- For column major layout, the elements of each column a dense matrix ``A`` are contiguous in memory while the elements of each row are at distance ``lda`` from the element in the same row and the previous column.
259
+
260
+
235
261
.. note::
236
262
:ref:`onemkl_appendix` may contain other API design decisions or recommendations that may be of use to the general developer of oneMKL, but which may not necessarily be part of the oneMKL specification.
C \leftarrow\alpha\cdot\text{op}(A) \cdot\text{op}(B) + \beta\cdot C
20
20
21
-
where :math:`\alpha` and :math:`\beta` are scalars, :math:`B` and :math:`C` are dense matrices and :math:`A` is a sparse matrix. Dense matrix storage is in row-major format. Sparse matrix formats are compressed sparse row (CSR) formats.
21
+
where :math:`\alpha` and :math:`\beta` are scalars, :math:`A` is a sparse matrix, :math:`B` and :math:`C` are dense matrices, :math:`\text{op}()` is a matrix modifier for :math:`A` and :math:`B` using the following description:
and :math:`\text{op}(A)` is an ``m``-by-``k`` matrix , :math:`\text{op}(B)` is an ``k``-by-``columns`` matrix, and :math:`C` is an ``m``-by-``columns`` matrix.
29
+
30
+
Dense matrix storage is in either row-major or column-major format. Sparse matrix formats are compressed sparse row (CSR) formats.
22
31
23
32
24
33
.. _onemkl_sparse_gemm_buffer:
@@ -33,7 +42,9 @@ gemm (Buffer version)
33
42
namespace oneapi::mkl::sparse {
34
43
35
44
void gemm (sycl::queue &queue,
36
-
oneapi::mkl::transpose transpose_val,
45
+
oneapi::mkl::layout dense_matrix_layout,
46
+
oneapi::mkl::transpose transpose_A,
47
+
oneapi::mkl::transpose transpose_B,
37
48
const fp alpha,
38
49
oneapi::mkl::sparse::matrix_handle_t A_handle,
39
50
sycl::buffer<fp, 1> &B,
@@ -56,8 +67,18 @@ gemm (Buffer version)
56
67
kernels execution.
57
68
58
69
59
-
transpose_val
60
-
Specifies operation ``op()`` on input matrix. The possible options
70
+
dense_matrix_layout
71
+
Specifies the storage scheme in memory for the dense matrices. Note that this layout applies to both :math:`B` and :math:`C` dense matrices.
72
+
The possible options are described in :ref:`onemkl_enum_layout` enum class.
73
+
74
+
75
+
transpose_A
76
+
Specifies operation ``op()`` on input matrix :math:`A`. The possible options
77
+
are described in :ref:`onemkl_enum_transpose` enum class.
78
+
79
+
80
+
transpose_B
81
+
Specifies operation ``op()`` on input matrix :math:`B`. The possible options
61
82
are described in :ref:`onemkl_enum_transpose` enum class.
62
83
63
84
@@ -70,26 +91,57 @@ gemm (Buffer version)
70
91
71
92
72
93
B
73
-
The dense matrix in the sparse-dense matrix product. A one dimensional SYCL memory object containing an array of size at least ``cols*ldb``, where ``cols`` = the number of columns of matrix :math:`op(A)`.
94
+
The input dense matrix :math:`B` in the sparse matrix-dense matrix product. :math:`B` is a one dimensional SYCL memory object containing an array of size:
95
+
96
+
.. list-table::
97
+
:header-rows: 1
98
+
99
+
* -
100
+
- ``B`` not transposed
101
+
- ``B`` transposed
102
+
* - Row major
103
+
- ``B`` is an ``k``-by-``columns`` matrix so must have size at least ``k``\ \*\ ``ldb``.
104
+
- ``B`` is an ``columns``-by-``k`` matrix so must have size at least ``columns``\ \*\ ``ldb``
105
+
* - Column major
106
+
- ``B`` is an ``k``-by-``columns`` matrix so must have size at least ``ldb``\ \*\ ``columns``.
107
+
- ``B`` is an ``columns``-by-``k`` matrix so must have size at least ``ldb``\ \*\ ``k``
108
+
109
+
See :ref:`matrix-storage` for more details.
110
+
74
111
75
112
columns
76
-
Number of columns of matrix,:math:`C`.
113
+
Number of columns of matrix :math:`C`.
77
114
78
115
79
116
ldb
80
-
Specifies the leading dimension of matrix, :math:`B`. Should be greater than or equal to the number of columns of :math:`B` which is ``columns``.
117
+
Specifies the leading dimension of matrix :math:`B`. It must be positive.
118
+
119
+
.. list-table::
120
+
:header-rows: 1
121
+
122
+
* -
123
+
- ``B`` not transposed
124
+
- ``B`` transposed
125
+
* - Row major
126
+
- ``ldb`` must be at least ``columns``.
127
+
- ``ldb`` must be at least ``k``.
128
+
* - Column major
129
+
- ``ldb`` must be at least ``k``.
130
+
- ``ldb`` must be at least ``columns``.
81
131
82
132
83
133
beta
84
134
Specifies the scalar ``beta``.
85
135
86
136
87
137
C
88
-
The dense matrix input/output array. A one-dimensional SYCL memory object containing an array of size at least ``rows*ldc``, where ``rows`` = the number of rows
89
-
of matrix :math:`op(A)`.
138
+
The dense matrix input/output array. A one-dimensional SYCL memory object containing an array of size at least ``m``\ \*\ ``ldc`` if row_major layout is used to store dense matrices
139
+
or at least ``ldc``\ \*\ ``columns`` if column_major layout is used to store dense matrices.
140
+
90
141
91
142
ldc
92
-
Specifies the leading dimension of matrix :math:`C` . Must be greater than or equal to the number of columns of :math:`C` which is ``columns``.
143
+
Specifies the leading dimension of matrix :math:`C`.
144
+
Must be positive and at least ``columns`` if row major layout is used to store dense matrices or at least ``m`` if column major layout is used to store dense matrices.
93
145
94
146
95
147
.. container:: section
@@ -130,7 +182,9 @@ gemm (USM version)
130
182
namespace oneapi::mkl::sparse {
131
183
132
184
sycl::event gemm (sycl::queue &queue,
133
-
oneapi::mkl::transpose transpose_val,
185
+
oneapi::mkl::layout dense_matrix_layout,
186
+
oneapi::mkl::transpose transpose_A,
187
+
oneapi::mkl::transpose transpose_B,
134
188
const fp alpha,
135
189
oneapi::mkl::sparse::matrix_handle_t A_handle,
136
190
const fp *B,
@@ -153,34 +207,80 @@ gemm (USM version)
153
207
kernels execution.
154
208
155
209
156
-
transpose_val
157
-
Specifies operation ``op()`` on input matrix. The possible options
210
+
dense_matrix_layout
211
+
Specifies the storage scheme in memory for the dense matrices. Note that this layout applies to both :math:`B` and :math:`C` dense matrices.
212
+
The possible options are described in :ref:`onemkl_enum_layout` enum class.
213
+
214
+
215
+
transpose_A
216
+
Specifies operation ``op()`` on input matrix :math:`A`. The possible options
158
217
are described in :ref:`onemkl_enum_transpose` enum class.
159
218
219
+
220
+
transpose_B
221
+
Specifies operation ``op()`` on input matrix :math:`B`. The possible options
222
+
are described in :ref:`onemkl_enum_transpose` enum class.
223
+
224
+
160
225
alpha
161
226
Specifies the scalar :math:`\alpha`.
162
227
228
+
163
229
A_handle
164
230
Handle to object containing sparse matrix, :math:`A`. Created using the oneapi::mkl::sparse::set_csr_data routine.
165
231
232
+
166
233
B
167
-
The dense matrix in the sparse-dense matrix product. A device accessible USM object containing an array of size at least ``cols*ldb``, where ``cols`` = the number of columns of matrix :math:`op(A)`.
234
+
The dense matrix in the sparse-dense matrix product. A device accessible USM object containing an array of size:
235
+
236
+
.. list-table::
237
+
:header-rows: 1
238
+
239
+
* -
240
+
- ``B`` not transposed
241
+
- ``B`` transposed
242
+
* - Row major
243
+
- ``B`` is an ``k``-by-``columns`` matrix so must have size at least ``k``\ \*\ ``ldb``.
244
+
- ``B`` is an ``columns``-by-``k`` matrix so must have size at least ``columns``\ \*\ ``ldb``
245
+
* - Column major
246
+
- ``B`` is an ``k``-by-``columns`` matrix so must have size at least ``ldb``\ \*\ ``columns``.
247
+
- ``B`` is an ``columns``-by-``k`` matrix so must have size at least ``ldb``\ \*\ ``k``
248
+
249
+
See :ref:`matrix-storage` for more details.
250
+
168
251
169
252
columns
170
253
Number of columns of matrix :math:`C`.
171
254
255
+
172
256
ldb
173
-
Specifies the leading dimension of matrix :math:`B`. Should be greater than or equal to the number of columns of :math:`B`.
257
+
Specifies the leading dimension of matrix :math:`B`. It must be positive.
258
+
259
+
.. list-table::
260
+
:header-rows: 1
261
+
262
+
* -
263
+
- ``B`` not transposed
264
+
- ``B`` transposed
265
+
* - Row major
266
+
- ``ldb`` must be at least ``columns``.
267
+
- ``ldb`` must be at least ``k``.
268
+
* - Column major
269
+
- ``ldb`` must be at least ``k``.
270
+
- ``ldb`` must be at least ``columns``.
271
+
174
272
175
273
beta
176
274
Specifies the scalar ``beta``.
177
275
276
+
178
277
C
179
-
The dense matrix input/output array. A device accessible USM object containing an array of size at least ``rows*ldc``, where ``rows`` = the number of rows
180
-
of matrix :math:`op(A)`.
278
+
The dense matrix input/output array. A device accessible USM object containing an array of size at least ``m``\ \*\``ldc`` if row_major layout is used to store dense matrices
279
+
or at least ``ldc``\ \*\ ``columns`` if column_major layout is used to store dense matrices.
181
280
182
281
ldc
183
-
Specifies the leading dimension of matrix :math:`C` . Must be greater than or equal to ``columns``.
282
+
Specifies the leading dimension of matrix :math:`C`.
283
+
Must be positive and at least ``columns`` if row major layout is used to store dense matrices or at least ``m`` if column major layout is used to store dense matrices.
184
284
185
285
dependencies
186
286
List of events that oneapi::mkl::sparse::gemm routine depends on.
0 commit comments