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

Add cusparseSpMV_preprocess to cusparse wrapper #2384

Merged
merged 7 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions cpp/include/raft/core/cusparse_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
// (i.e., before including this header)
//
#define CUDA_VER_10_1_UP (CUDART_VERSION >= 10100)
#define CUDA_VER_12_4_UP (CUDART_VERSION >= 12040)
lowener marked this conversation as resolved.
Show resolved Hide resolved

namespace raft {

Expand Down
28 changes: 28 additions & 0 deletions cpp/include/raft/sparse/detail/cusparse_wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,34 @@ inline cusparseStatus_t cusparsespmv(cusparseHandle_t handle,
CUSPARSE_CHECK(cusparseSetStream(handle, stream));
return cusparseSpMV(handle, opA, alpha, matA, vecX, beta, vecY, CUDA_R_64F, alg, externalBuffer);
}
// cusparseSpMV_preprocess is only available starting CUDA 12.4
#if CUDA_VER_12_4_UP
template <
typename T,
typename std::enable_if_t<std::is_same_v<T, float> || std::is_same_v<T, double>>* = nullptr>
cusparseStatus_t cusparsespmv_preprocess(cusparseHandle_t handle,
cusparseOperation_t opA,
const T* alpha,
const cusparseSpMatDescr_t matA,
const cusparseDnVecDescr_t vecX,
const T* beta,
const cusparseDnVecDescr_t vecY,
cusparseSpMVAlg_t alg,
T* externalBuffer,
cudaStream_t stream)
{
auto constexpr float_type = []() constexpr {
if constexpr (std::is_same_v<T, float>) {
return CUDA_R_32F;
} else if constexpr (std::is_same_v<T, double>) {
return CUDA_R_64F;
}
}();
CUSPARSE_CHECK(cusparseSetStream(handle, stream));
return cusparseSpMV_preprocess(
handle, opA, alpha, matA, vecX, beta, vecY, float_type, alg, externalBuffer);
}
#endif
/** @} */
#else
/**
Expand Down
Loading