Skip to content

Commit 6136da2

Browse files
committed
sparse/gemv: fix deprecated set_csr_data and unused nnz warning
The oneMKL 2025-2 sparse BLAS API deprecated the old 8-argument set_csr_data(queue, handle, nrows, ncols, index_base, row_ptr, col_ind, values, deps) overload in favour of a new signature that takes the sparse matrix handle as `spmat` and adds an explicit `nnz` argument: set_csr_data(queue, spmat, nrows, ncols, nnz, index_base, row_ptr, col_ind, values, deps) Fixes: - Replace old set_csr_data call with the new nnz-aware signature - Silences the resulting -Wunused-parameter warning on `nnz` (now used) - No functional change; all other logic is unchanged
1 parent 7bc86c9 commit 6136da2

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

dpnp/backend/extensions/sparse/gemv.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,31 +108,33 @@ gemv_impl(sycl::queue &exec_q,
108108
std::stringstream error_msg;
109109
bool is_exception_caught = false;
110110

111-
mkl_sparse::matrix_handle_t handle = nullptr;
111+
mkl_sparse::matrix_handle_t spmat = nullptr;
112112
sycl::event gemv_ev;
113113

114114
try {
115-
mkl_sparse::init_matrix_handle(&handle);
115+
mkl_sparse::init_matrix_handle(&spmat);
116116

117+
// oneMKL 2025-2 API: set_csr_data now requires explicit nnz and uses
118+
// `spmat` nomenclature. The old form without nnz is deprecated.
117119
auto ev_set = mkl_sparse::set_csr_data(
118-
exec_q, handle,
119-
num_rows, num_cols,
120+
exec_q, spmat,
121+
num_rows, num_cols, nnz,
120122
oneapi::mkl::index_base::zero,
121123
const_cast<Ti *>(row_ptr),
122124
const_cast<Ti *>(col_ind),
123125
const_cast<Tv *>(values),
124126
depends);
125127

126128
auto ev_opt = mkl_sparse::optimize_gemv(
127-
exec_q, mkl_trans, handle, {ev_set});
129+
exec_q, mkl_trans, spmat, {ev_set});
128130

129131
gemv_ev = mkl_sparse::gemv(
130132
exec_q, mkl_trans,
131-
alpha, handle,
133+
alpha, spmat,
132134
x, beta, y,
133135
{ev_opt});
134136

135-
mkl_sparse::release_matrix_handle(exec_q, &handle, {gemv_ev});
137+
mkl_sparse::release_matrix_handle(exec_q, &spmat, {gemv_ev});
136138

137139
} catch (oneapi::mkl::exception const &e) {
138140
error_msg << "Unexpected MKL exception caught during sparse_gemv() "
@@ -145,8 +147,8 @@ gemv_impl(sycl::queue &exec_q,
145147
}
146148

147149
if (is_exception_caught) {
148-
if (handle != nullptr)
149-
mkl_sparse::release_matrix_handle(exec_q, &handle, {});
150+
if (spmat != nullptr)
151+
mkl_sparse::release_matrix_handle(exec_q, &spmat, {});
150152
throw std::runtime_error(error_msg.str());
151153
}
152154

@@ -210,7 +212,7 @@ sparse_gemv(sycl::queue &exec_q,
210212
"sparse_gemv: trans must be 0 (N), 1 (T), or 2 (C)");
211213
}
212214

213-
// 6. Dispatch table lookup — replaces the explicit if/else chain
215+
// 6. Dispatch table lookup
214216
auto array_types = dpctl_td_ns::usm_ndarray_types();
215217
const int val_id = array_types.typenum_to_lookup_id(values.get_typenum());
216218
const int idx_id = array_types.typenum_to_lookup_id(row_ptr.get_typenum());
@@ -237,7 +239,6 @@ sparse_gemv(sycl::queue &exec_q,
237239

238240
// ---------------------------------------------------------------------------
239241
// Factory and dispatch table initialisation
240-
// Mirrors blas/gemm.cpp: GemmContigFactory -> GemvContigFactory
241242
// ---------------------------------------------------------------------------
242243

243244
template <typename fnT, typename Tv, typename Ti>

0 commit comments

Comments
 (0)