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

use rocsparse_spmv_ex for rocm >= 5.4.0 #1701

Merged
merged 1 commit into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions sparse/src/KokkosSparse_Utils_rocsparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define _KOKKOSKERNELS_SPARSEUTILS_ROCSPARSE_HPP

#ifdef KOKKOSKERNELS_ENABLE_TPL_ROCSPARSE
#include <rocm_version.h>
#include "rocsparse/rocsparse.h"

namespace KokkosSparse {
Expand Down Expand Up @@ -164,6 +165,9 @@ struct kokkos_to_rocsparse_type<Kokkos::complex<double>> {
using type = rocsparse_double_complex;
};

#define KOKKOSSPARSE_IMPL_ROCM_VERSION \
ROCM_VERSION_MAJOR * 10000 + ROCM_VERSION_MINOR * 100 + ROCM_VERSION_PATCH

} // namespace Impl

} // namespace KokkosSparse
Expand Down
18 changes: 15 additions & 3 deletions sparse/tpls/KokkosSparse_spmv_tpl_spec_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ KOKKOSSPARSE_SPMV_CUSPARSE(Kokkos::complex<float>, int64_t, size_t,
// rocSPARSE
#if defined(KOKKOSKERNELS_ENABLE_TPL_ROCSPARSE)
#include <rocsparse/rocsparse.h>
#include <rocm_version.h>
#include "KokkosSparse_Utils_rocsparse.hpp"

namespace KokkosSparse {
Expand Down Expand Up @@ -421,13 +422,24 @@ void spmv_rocsparse(const KokkosKernels::Experimental::Controls& controls,
else if (algName == "merge")
alg = rocsparse_spmv_alg_csr_stream;
}
KOKKOS_ROCSPARSE_SAFE_CALL_IMPL(
rocsparse_spmv(handle, myRocsparseOperation, &alpha, Aspmat, vecX, &beta,
vecY, compute_type, alg, &buffer_size, tmp_buffer));

#if KOKKOSSPARSE_IMPL_ROCM_VERSION >= 50400
KOKKOS_ROCSPARSE_SAFE_CALL_IMPL(rocsparse_spmv_ex(
handle, myRocsparseOperation, &alpha, Aspmat, vecX, &beta, vecY,
compute_type, alg, rocsparse_spmv_stage_auto, &buffer_size, tmp_buffer));
KOKKOS_IMPL_HIP_SAFE_CALL(hipMalloc(&tmp_buffer, buffer_size));
KOKKOS_ROCSPARSE_SAFE_CALL_IMPL(rocsparse_spmv_ex(
handle, myRocsparseOperation, &alpha, Aspmat, vecX, &beta, vecY,
compute_type, alg, rocsparse_spmv_stage_auto, &buffer_size, tmp_buffer));
#else
KOKKOS_ROCSPARSE_SAFE_CALL_IMPL(
rocsparse_spmv(handle, myRocsparseOperation, &alpha, Aspmat, vecX, &beta,
vecY, compute_type, alg, &buffer_size, tmp_buffer));
KOKKOS_IMPL_HIP_SAFE_CALL(hipMalloc(&tmp_buffer, buffer_size));
KOKKOS_ROCSPARSE_SAFE_CALL_IMPL(rocsparse_spmv_ex(
handle, myRocsparseOperation, &alpha, Aspmat, vecX, &beta, vecY,
compute_type, alg, &buffer_size, tmp_buffer));
#endif
KOKKOS_IMPL_HIP_SAFE_CALL(hipFree(tmp_buffer));

KOKKOS_ROCSPARSE_SAFE_CALL_IMPL(rocsparse_destroy_dnvec_descr(vecY));
Expand Down