|
| 1 | +.. SPDX-FileCopyrightText: 2023 Intel Corporation |
| 2 | +.. |
| 3 | +.. SPDX-License-Identifier: CC-BY-4.0 |
| 4 | +
|
| 5 | +.. _onemkl_sparse_optimize_gemm: |
| 6 | + |
| 7 | +optimize_gemm |
| 8 | +============= |
| 9 | + |
| 10 | +Performs internal optimizations for oneapi::mkl::sparse::gemm by analyzing |
| 11 | +the matrix structure. |
| 12 | + |
| 13 | +.. rubric:: Description and Assumptions |
| 14 | + |
| 15 | +The oneapi::mkl::sparse::optimize_gemm routine analyzes matrix structure |
| 16 | +and performs optimizations. Optimized data is then stored in |
| 17 | +the handle. |
| 18 | + |
| 19 | +In contrast to other optimization routines in Sparse BLAS domain |
| 20 | +which are done solely based on the sparse matrix pattern, |
| 21 | +two versions of the ``sparse::optimize_gemm`` routine are provided for preparing different |
| 22 | +optimizations for ``sparse::gemm`` routine. In particular, if the shape |
| 23 | +of the dense matrix right hand side, :math:`B`, is unknown or widely varying in |
| 24 | +subsequent calls to ``sparse::gemm`` then a user might reasonably |
| 25 | +only wish to perform optimizations for ``:sparse::gemm`` with respect |
| 26 | +to the sparse matrix structure. However, if one or more particular shapes of :math:`B` |
| 27 | +is available, then each :math:`B` shape can be provided as an additional hint |
| 28 | +along with the sparse matrix pattern in the call to ``sparse::optimize_gemm``. This |
| 29 | +second version of the API with :math:`B` shape should be callable one or |
| 30 | +more times and may allow libraries to provide more targeted performance |
| 31 | +optimizations. |
| 32 | + |
| 33 | +.. _onemkl_sparse_optimize_gemm_A: |
| 34 | + |
| 35 | +optimize_gemm (based on Sparse Matrix) |
| 36 | +-------------------------------------- |
| 37 | + |
| 38 | +.. rubric:: Syntax |
| 39 | + |
| 40 | +.. code-block:: cpp |
| 41 | +
|
| 42 | + namespace oneapi::mkl::sparse { |
| 43 | +
|
| 44 | + sycl::event optimize_gemm (sycl::queue &queue, |
| 45 | + oneapi::mkl::transpose transpose_A, |
| 46 | + oneapi::mkl::sparse::matrix_handle_t A_handle, |
| 47 | + const std::vector<sycl::event> &dependencies = {}); |
| 48 | +
|
| 49 | + } |
| 50 | +
|
| 51 | +.. container:: section |
| 52 | + |
| 53 | + .. rubric:: Input Parameters |
| 54 | + |
| 55 | + queue |
| 56 | + Specifies the SYCL command queue which will be used for SYCL |
| 57 | + kernels execution. |
| 58 | + |
| 59 | + |
| 60 | + transpose_A |
| 61 | + Specifies operation ``op()`` on input matrix :math:`A`. The possible options |
| 62 | + are described in :ref:`onemkl_enum_transpose` enum class. |
| 63 | + |
| 64 | + |
| 65 | + A_handle |
| 66 | + Handle to object containing sparse matrix and other internal |
| 67 | + data. Created using the |
| 68 | + oneapi::mkl::sparse::set_csr_data routine. |
| 69 | + |
| 70 | + |
| 71 | + dependencies |
| 72 | + List of events that oneapi::mkl::sparse::optimize_gemm routine depends on. |
| 73 | + |
| 74 | + |
| 75 | +.. container:: section |
| 76 | + |
| 77 | + .. rubric:: Output Parameters |
| 78 | + :class: sectiontitle |
| 79 | + |
| 80 | + handle |
| 81 | + Handle might be updated with some internal optimized data by this routine. |
| 82 | + |
| 83 | +.. container:: section |
| 84 | + |
| 85 | + .. rubric:: Throws |
| 86 | + :class: sectiontitle |
| 87 | + |
| 88 | + This routine shall throw the following exceptions if the associated condition is detected. |
| 89 | + An implementation may throw additional implementation-specific exception(s) |
| 90 | + in case of error conditions not covered here. |
| 91 | + |
| 92 | + | :ref:`oneapi::mkl::computation_error<onemkl_exception_computation_error>` |
| 93 | + | :ref:`oneapi::mkl::device_bad_alloc<onemkl_exception_device_bad_alloc>` |
| 94 | + | :ref:`oneapi::mkl::host_bad_alloc<onemkl_exception_host_bad_alloc>` |
| 95 | + | :ref:`oneapi::mkl::invalid_argument<onemkl_exception_invalid_argument>` |
| 96 | + | :ref:`oneapi::mkl::unimplemented<onemkl_exception_unimplemented>` |
| 97 | + | :ref:`oneapi::mkl::uninitialized<onemkl_exception_uninitialized>` |
| 98 | + | :ref:`oneapi::mkl::unsupported_device<onemkl_exception_unsupported_device>` |
| 99 | +
|
| 100 | +.. container:: section |
| 101 | + |
| 102 | + .. rubric:: Return Values |
| 103 | + :class: sectiontitle |
| 104 | + |
| 105 | + Output event that can be waited upon or added as a |
| 106 | + dependency for the completion of optimize_gemm routine. |
| 107 | + |
| 108 | + |
| 109 | +.. _onemkl_sparse_optimize_gemm_AB: |
| 110 | + |
| 111 | +optimize_gemm (based on Both Input Matrices) |
| 112 | +-------------------------------------------- |
| 113 | + |
| 114 | +.. rubric:: Syntax |
| 115 | + |
| 116 | +.. code-block:: cpp |
| 117 | +
|
| 118 | + namespace oneapi::mkl::sparse { |
| 119 | +
|
| 120 | + sycl::event optimize_gemm (sycl::queue &queue, |
| 121 | + oneapi::mkl::transpose transpose_A, |
| 122 | + oneapi::mkl::transpose transpose_B, |
| 123 | + oneapi::mkl::layout dense_matrix_layout, |
| 124 | + const std::int64_t columns, |
| 125 | + oneapi::mkl::sparse::matrix_handle_t A_handle, |
| 126 | + const std::vector<sycl::event> &dependencies = {}); |
| 127 | +
|
| 128 | + } |
| 129 | +
|
| 130 | +.. container:: section |
| 131 | + |
| 132 | + .. rubric:: Input Parameters |
| 133 | + |
| 134 | + queue |
| 135 | + Specifies the SYCL command queue which will be used for SYCL |
| 136 | + kernels execution. |
| 137 | + |
| 138 | + |
| 139 | + transpose_A |
| 140 | + Specifies operation ``op()`` on input matrix :math:`A`. The possible options |
| 141 | + are described in :ref:`onemkl_enum_transpose` enum class. |
| 142 | + |
| 143 | + |
| 144 | + transpose_B |
| 145 | + Specifies operation ``op()`` on input matrix :math:`B`. The possible options |
| 146 | + are described in :ref:`onemkl_enum_transpose` enum class. |
| 147 | + |
| 148 | + |
| 149 | + dense_matrix_layout |
| 150 | + Specifies the storage scheme in memory for the dense matrices. Note that this layout applies to both :math:`B` and :math:`C` dense matrices. |
| 151 | + The possible options are described in :ref:`onemkl_enum_layout` enum class. |
| 152 | + |
| 153 | + |
| 154 | + columns |
| 155 | + Number of columns of matrix :math:`C`. |
| 156 | + |
| 157 | + |
| 158 | + handle |
| 159 | + Handle to object containing sparse matrix and other internal |
| 160 | + data. Created using the |
| 161 | + oneapi::mkl::sparse::set_csr_data routine. |
| 162 | + |
| 163 | + |
| 164 | + dependencies |
| 165 | + List of events that oneapi::mkl::sparse::optimize_gemm routine depends on. |
| 166 | + |
| 167 | + |
| 168 | +.. container:: section |
| 169 | + |
| 170 | + .. rubric:: Output Parameters |
| 171 | + :class: sectiontitle |
| 172 | + |
| 173 | + handle |
| 174 | + Handle might be updated with some internal optimized data by this routine. |
| 175 | + |
| 176 | +.. container:: section |
| 177 | + |
| 178 | + .. rubric:: Throws |
| 179 | + :class: sectiontitle |
| 180 | + |
| 181 | + This routine shall throw the following exceptions if the associated condition is detected. |
| 182 | + An implementation may throw additional implementation-specific exception(s) |
| 183 | + in case of error conditions not covered here. |
| 184 | + |
| 185 | + | :ref:`oneapi::mkl::computation_error<onemkl_exception_computation_error>` |
| 186 | + | :ref:`oneapi::mkl::device_bad_alloc<onemkl_exception_device_bad_alloc>` |
| 187 | + | :ref:`oneapi::mkl::host_bad_alloc<onemkl_exception_host_bad_alloc>` |
| 188 | + | :ref:`oneapi::mkl::invalid_argument<onemkl_exception_invalid_argument>` |
| 189 | + | :ref:`oneapi::mkl::unimplemented<onemkl_exception_unimplemented>` |
| 190 | + | :ref:`oneapi::mkl::uninitialized<onemkl_exception_uninitialized>` |
| 191 | + | :ref:`oneapi::mkl::unsupported_device<onemkl_exception_unsupported_device>` |
| 192 | +
|
| 193 | +.. container:: section |
| 194 | + |
| 195 | + .. rubric:: Return Values |
| 196 | + :class: sectiontitle |
| 197 | + |
| 198 | + Output event that can be waited upon or added as a |
| 199 | + dependency for the completion of optimize_gemm routine. |
| 200 | + |
| 201 | + |
| 202 | +.. container:: familylinks |
| 203 | + |
| 204 | + |
| 205 | + .. container:: parentlink |
| 206 | + |
| 207 | + |
| 208 | + **Parent topic:** :ref:`onemkl_spblas` |
0 commit comments