Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing small bug in CUSPARSE spmm w/ CUDA 12.2 #2117

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions cpp/include/raft/sparse/linalg/spmm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,19 @@ void spmm(raft::resources const& handle,
{
bool is_row_major = detail::is_row_major(y, z);

auto z_tmp = raft::make_device_matrix<ValueType, IndexType>(handle, z.extent(0), z.extent(1));
auto z_tmp_view = raft::make_device_strided_matrix_view<ValueType, IndexType, LayoutPolicyZ>(
z_tmp.data_handle(), z.extent(0), z.extent(1), is_row_major ? z.stride(0) : z.stride(1));

Copy link
Collaborator

@trxcllnt trxcllnt Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also need to copy z into z_tmp, since it's an in/out buffer in cuSparse?

Suggested change
raft::copy(
z_tmp_view.data_handle(), z.data_handle(), z.size(), raft::resource::get_cuda_stream(handle));

auto descr_x = detail::create_descriptor(x);
auto descr_y = detail::create_descriptor(y);
auto descr_z = detail::create_descriptor(z);
auto descr_z = detail::create_descriptor(z_tmp_view);

detail::spmm(handle, trans_x, trans_y, is_row_major, alpha, descr_x, descr_y, beta, descr_z);

raft::copy(
z.data_handle(), z_tmp.data_handle(), z_tmp.size(), raft::resource::get_cuda_stream(handle));

RAFT_CUSPARSE_TRY_NO_THROW(cusparseDestroySpMat(descr_x));
RAFT_CUSPARSE_TRY_NO_THROW(cusparseDestroyDnMat(descr_y));
RAFT_CUSPARSE_TRY_NO_THROW(cusparseDestroyDnMat(descr_z));
Expand All @@ -76,4 +83,4 @@ void spmm(raft::resources const& handle,
} // end namespace sparse
} // end namespace raft

#endif
#endif
Loading