Skip to content

Commit

Permalink
Merge pull request ROCm#1353 from emankov/HIPIFY
Browse files Browse the repository at this point in the history
[HIPIFY][ROCm#674][rocSPARSE][feature] rocSPARSE support - Step 108 - `cusparseSpMV(_bufferSize)?` -> `rocsparse_spmv`
  • Loading branch information
emankov authored Feb 12, 2024
2 parents 579ee8b + f7af410 commit f40dcf6
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 30 deletions.
1 change: 1 addition & 0 deletions bin/hipify-perl
Original file line number Diff line number Diff line change
Expand Up @@ -2275,6 +2275,7 @@ sub rocSubstitutions {
subst("cusparseSpMM", "rocsparse_spmm", "library");
subst("cusparseSpMM_bufferSize", "rocsparse_spmm", "library");
subst("cusparseSpMV", "rocsparse_spmv", "library");
subst("cusparseSpMV_bufferSize", "rocsparse_spmv", "library");
subst("cusparseSpMatGetAttribute", "rocsparse_spmat_get_attribute", "library");
subst("cusparseSpMatGetFormat", "rocsparse_spmat_get_format", "library");
subst("cusparseSpMatGetIndexBase", "rocsparse_spmat_get_index_base", "library");
Expand Down
8 changes: 4 additions & 4 deletions docs/tables/CUSPARSE_API_supported_by_HIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -880,8 +880,8 @@
|`cusparseSpMMOp_destroyPlan`|11.5| | | | | | | | | |
|`cusparseSpMM_bufferSize`|10.1| |12.0| |`hipsparseSpMM_bufferSize`|4.2.0| |6.0.0| | |
|`cusparseSpMM_preprocess`|11.2| |12.0| |`hipsparseSpMM_preprocess`|4.5.0| |6.0.0| | |
|`cusparseSpMV`|10.2| |12.0| |`hipsparseSpMV`|4.1.0| |6.0.0| | |
|`cusparseSpMV_bufferSize`|10.2| |12.0| |`hipsparseSpMV_bufferSize`|4.1.0| |6.0.0| | |
|`cusparseSpMV`|10.1| |12.0| |`hipsparseSpMV`|4.1.0| |6.0.0| | |
|`cusparseSpMV_bufferSize`|10.1| |12.0| |`hipsparseSpMV_bufferSize`|4.1.0| |6.0.0| | |
|`cusparseSpMatGetAttribute`|11.3| |12.0| |`hipsparseSpMatGetAttribute`|4.5.0| |6.0.0| | |
|`cusparseSpMatGetFormat`|10.1| |12.0| |`hipsparseSpMatGetFormat`|4.1.0| |6.0.0| | |
|`cusparseSpMatGetIndexBase`|10.1| |12.0| |`hipsparseSpMatGetIndexBase`|4.1.0| |6.0.0| | |
Expand All @@ -904,8 +904,8 @@
|`cusparseSpSV_destroyDescr`|11.3| | | |`hipsparseSpSV_destroyDescr`|4.5.0| | | | |
|`cusparseSpSV_solve`|11.3| |12.0| |`hipsparseSpSV_solve`|4.5.0| |6.0.0| | |
|`cusparseSpSV_updateMatrix`|12.1| | | | | | | | | |
|`cusparseSpVV`|10.2| |12.0| |`hipsparseSpVV`|4.1.0| |6.0.0| | |
|`cusparseSpVV_bufferSize`|10.2| |12.0| |`hipsparseSpVV_bufferSize`|4.1.0| |6.0.0| | |
|`cusparseSpVV`|10.1| |12.0| |`hipsparseSpVV`|4.1.0| |6.0.0| | |
|`cusparseSpVV_bufferSize`|10.1| |12.0| |`hipsparseSpVV_bufferSize`|4.1.0| |6.0.0| | |
|`cusparseSpVecGet`|10.2| | | |`hipsparseSpVecGet`|4.1.0| | | | |
|`cusparseSpVecGetIndexBase`|10.2| |12.0| |`hipsparseSpVecGetIndexBase`|4.1.0| |6.0.0| | |
|`cusparseSpVecGetValues`|10.2| | | |`hipsparseSpVecGetValues`|4.1.0| | | | |
Expand Down
8 changes: 4 additions & 4 deletions docs/tables/CUSPARSE_API_supported_by_HIP_and_ROC.md
Original file line number Diff line number Diff line change
Expand Up @@ -880,8 +880,8 @@
|`cusparseSpMMOp_destroyPlan`|11.5| | | | | | | | | | | | | | | |
|`cusparseSpMM_bufferSize`|10.1| |12.0| |`hipsparseSpMM_bufferSize`|4.2.0| |6.0.0| | |`rocsparse_spmm`|4.2.0| |6.0.0| | |
|`cusparseSpMM_preprocess`|11.2| |12.0| |`hipsparseSpMM_preprocess`|4.5.0| |6.0.0| | | | | | | | |
|`cusparseSpMV`|10.2| |12.0| |`hipsparseSpMV`|4.1.0| |6.0.0| | |`rocsparse_spmv`|4.1.0| | | | |
|`cusparseSpMV_bufferSize`|10.2| |12.0| |`hipsparseSpMV_bufferSize`|4.1.0| |6.0.0| | | | | | | | |
|`cusparseSpMV`|10.1| |12.0| |`hipsparseSpMV`|4.1.0| |6.0.0| | |`rocsparse_spmv`|4.1.0| |6.0.0| | |
|`cusparseSpMV_bufferSize`|10.1| |12.0| |`hipsparseSpMV_bufferSize`|4.1.0| |6.0.0| | |`rocsparse_spmv`|4.1.0| |6.0.0| | |
|`cusparseSpMatGetAttribute`|11.3| |12.0| |`hipsparseSpMatGetAttribute`|4.5.0| |6.0.0| | |`rocsparse_spmat_get_attribute`|4.5.0| |6.0.0| | |
|`cusparseSpMatGetFormat`|10.1| |12.0| |`hipsparseSpMatGetFormat`|4.1.0| |6.0.0| | |`rocsparse_spmat_get_format`|4.1.0| |6.0.0| | |
|`cusparseSpMatGetIndexBase`|10.1| |12.0| |`hipsparseSpMatGetIndexBase`|4.1.0| |6.0.0| | |`rocsparse_spmat_get_index_base`|4.1.0| |6.0.0| | |
Expand All @@ -904,8 +904,8 @@
|`cusparseSpSV_destroyDescr`|11.3| | | |`hipsparseSpSV_destroyDescr`|4.5.0| | | | | | | | | | |
|`cusparseSpSV_solve`|11.3| |12.0| |`hipsparseSpSV_solve`|4.5.0| |6.0.0| | | | | | | | |
|`cusparseSpSV_updateMatrix`|12.1| | | | | | | | | | | | | | | |
|`cusparseSpVV`|10.2| |12.0| |`hipsparseSpVV`|4.1.0| |6.0.0| | | | | | | | |
|`cusparseSpVV_bufferSize`|10.2| |12.0| |`hipsparseSpVV_bufferSize`|4.1.0| |6.0.0| | |`rocsparse_spvv`|4.1.0| |6.0.0| | |
|`cusparseSpVV`|10.1| |12.0| |`hipsparseSpVV`|4.1.0| |6.0.0| | | | | | | | |
|`cusparseSpVV_bufferSize`|10.1| |12.0| |`hipsparseSpVV_bufferSize`|4.1.0| |6.0.0| | |`rocsparse_spvv`|4.1.0| |6.0.0| | |
|`cusparseSpVecGet`|10.2| | | |`hipsparseSpVecGet`|4.1.0| | | | |`rocsparse_spvec_get`|4.1.0| | | | |
|`cusparseSpVecGetIndexBase`|10.2| |12.0| |`hipsparseSpVecGetIndexBase`|4.1.0| |6.0.0| | |`rocsparse_spvec_get_index_base`|4.1.0| |6.0.0| | |
|`cusparseSpVecGetValues`|10.2| | | |`hipsparseSpVecGetValues`|4.1.0| | | | |`rocsparse_spvec_get_values`|4.1.0| | | | |
Expand Down
8 changes: 4 additions & 4 deletions docs/tables/CUSPARSE_API_supported_by_ROC.md
Original file line number Diff line number Diff line change
Expand Up @@ -880,8 +880,8 @@
|`cusparseSpMMOp_destroyPlan`|11.5| | | | | | | | | |
|`cusparseSpMM_bufferSize`|10.1| |12.0| |`rocsparse_spmm`|4.2.0| |6.0.0| | |
|`cusparseSpMM_preprocess`|11.2| |12.0| | | | | | | |
|`cusparseSpMV`|10.2| |12.0| |`rocsparse_spmv`|4.1.0| | | | |
|`cusparseSpMV_bufferSize`|10.2| |12.0| | | | | | | |
|`cusparseSpMV`|10.1| |12.0| |`rocsparse_spmv`|4.1.0| |6.0.0| | |
|`cusparseSpMV_bufferSize`|10.1| |12.0| |`rocsparse_spmv`|4.1.0| |6.0.0| | |
|`cusparseSpMatGetAttribute`|11.3| |12.0| |`rocsparse_spmat_get_attribute`|4.5.0| |6.0.0| | |
|`cusparseSpMatGetFormat`|10.1| |12.0| |`rocsparse_spmat_get_format`|4.1.0| |6.0.0| | |
|`cusparseSpMatGetIndexBase`|10.1| |12.0| |`rocsparse_spmat_get_index_base`|4.1.0| |6.0.0| | |
Expand All @@ -904,8 +904,8 @@
|`cusparseSpSV_destroyDescr`|11.3| | | | | | | | | |
|`cusparseSpSV_solve`|11.3| |12.0| | | | | | | |
|`cusparseSpSV_updateMatrix`|12.1| | | | | | | | | |
|`cusparseSpVV`|10.2| |12.0| | | | | | | |
|`cusparseSpVV_bufferSize`|10.2| |12.0| |`rocsparse_spvv`|4.1.0| |6.0.0| | |
|`cusparseSpVV`|10.1| |12.0| | | | | | | |
|`cusparseSpVV_bufferSize`|10.1| |12.0| |`rocsparse_spvv`|4.1.0| |6.0.0| | |
|`cusparseSpVecGet`|10.2| | | |`rocsparse_spvec_get`|4.1.0| | | | |
|`cusparseSpVecGetIndexBase`|10.2| |12.0| |`rocsparse_spvec_get_index_base`|4.1.0| |6.0.0| | |
|`cusparseSpVecGetValues`|10.2| | | |`rocsparse_spvec_get_values`|4.1.0| | | | |
Expand Down
15 changes: 8 additions & 7 deletions src/CUDA2HIP_SPARSE_API_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ const std::map<llvm::StringRef, hipCounter> CUDA_SPARSE_FUNCTION_MAP {

// Sparse Matrix * Vector Multiplication
{"cusparseSpMV", {"hipsparseSpMV", "rocsparse_spmv", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseSpMV_bufferSize", {"hipsparseSpMV_bufferSize", "", CONV_LIB_FUNC, API_SPARSE, 15, ROC_UNSUPPORTED}},
{"cusparseSpMV_bufferSize", {"hipsparseSpMV_bufferSize", "rocsparse_spmv", CONV_LIB_FUNC, API_SPARSE, 15}},

{"cusparseSparseToDense", {"hipsparseSparseToDense", "rocsparse_sparse_to_dense", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseSparseToDense_bufferSize", {"hipsparseSparseToDense_bufferSize", "rocsparse_sparse_to_dense", CONV_LIB_FUNC, API_SPARSE, 15}},
Expand Down Expand Up @@ -1164,12 +1164,12 @@ const std::map<llvm::StringRef, cudaAPIversions> CUDA_SPARSE_FUNCTION_VER_MAP {
{"cusparseDnVecGet", {CUDA_102, CUDA_0, CUDA_0 }},
{"cusparseDnVecGetValues", {CUDA_102, CUDA_0, CUDA_0 }},
{"cusparseDnVecSetValues", {CUDA_102, CUDA_0, CUDA_0 }},
{"cusparseSpMM", {CUDA_101, CUDA_0, CUDA_0 }},
{"cusparseSpMM_bufferSize", {CUDA_101, CUDA_0, CUDA_0 }},
{"cusparseSpVV", {CUDA_102, CUDA_0, CUDA_0 }},
{"cusparseSpVV_bufferSize", {CUDA_102, CUDA_0, CUDA_0 }},
{"cusparseSpMV", {CUDA_102, CUDA_0, CUDA_0 }},
{"cusparseSpMV_bufferSize", {CUDA_102, CUDA_0, CUDA_0 }},
{"cusparseSpMM", {CUDA_101, CUDA_0, CUDA_0 }}, // A: CUDA_VERSION 10010 C: CUSPARSE_VERSION 12000
{"cusparseSpMM_bufferSize", {CUDA_101, CUDA_0, CUDA_0 }}, // A: CUDA_VERSION 10010 C: CUSPARSE_VERSION 12000
{"cusparseSpVV", {CUDA_101, CUDA_0, CUDA_0 }}, // A: CUSPARSE_VERSION 10200 C: CUSPARSE_VERSION 12000
{"cusparseSpVV_bufferSize", {CUDA_101, CUDA_0, CUDA_0 }}, // A: CUSPARSE_VERSION 10200 C: CUSPARSE_VERSION 12000
{"cusparseSpMV", {CUDA_101, CUDA_0, CUDA_0 }}, // A: CUSPARSE_VERSION 10200 C: CUSPARSE_VERSION 12000
{"cusparseSpMV_bufferSize", {CUDA_101, CUDA_0, CUDA_0 }}, // A: CUSPARSE_VERSION 10200 C: CUSPARSE_VERSION 12000
{"cusparseSaxpyi", {CUDA_0, CUDA_110, CUDA_120}},
{"cusparseDaxpyi", {CUDA_0, CUDA_110, CUDA_120}},
{"cusparseCaxpyi", {CUDA_0, CUDA_110, CUDA_120}},
Expand Down Expand Up @@ -2539,6 +2539,7 @@ const std::map<llvm::StringRef, hipAPIChangedVersions> HIP_SPARSE_FUNCTION_CHANG
{"rocsparse_spmm", {HIP_6000}},
{"rocsparse_spsm", {HIP_6000}},
{"rocsparse_spvv", {HIP_6000}},
{"rocsparse_spmv", {HIP_6000}},
};

const std::map<unsigned int, llvm::StringRef> CUDA_SPARSE_API_SECTION_MAP {
Expand Down
29 changes: 28 additions & 1 deletion src/HipifyAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ const std::string sCusparseXcsrgeam2Nnz = "cusparseXcsrgeam2Nnz";
const std::string sCudaMallocHost = "cudaMallocHost";
const std::string sCusparseSpMM = "cusparseSpMM";
const std::string sCusparseSpVV_bufferSize = "cusparseSpVV_bufferSize";
const std::string sCusparseSpMV = "cusparseSpMV";
const std::string sCusparseSpMV_bufferSize = "cusparseSpMV_bufferSize";

// CUDA_OVERLOADED
const std::string sCudaEventCreate = "cudaEventCreate";
Expand Down Expand Up @@ -2072,6 +2074,29 @@ std::map<std::string, std::vector<ArgCastStruct>> FuncArgCasts {
}
}
},
{sCusparseSpMV_bufferSize,
{
{
{
{9, {e_add_const_argument, cw_None, "rocsparse_spmv_stage_buffer_size"}},
{11, {e_add_const_argument, cw_None, "nullptr"}},
},
true,
false
}
}
},
{sCusparseSpMV,
{
{
{
{9, {e_add_const_argument, cw_None, "rocsparse_spmv_stage_compute"}}
},
true,
false
}
}
},
};

void HipifyAction::RewriteString(StringRef s, clang::SourceLocation start) {
Expand Down Expand Up @@ -2936,7 +2961,9 @@ std::unique_ptr<clang::ASTConsumer> HipifyAction::CreateASTConsumer(clang::Compi
sCusparseXcsrgeam2Nnz,
sCudaMallocHost,
sCusparseSpMM,
sCusparseSpVV_bufferSize
sCusparseSpVV_bufferSize,
sCusparseSpMV,
sCusparseSpMV_bufferSize
)
)
)
Expand Down
3 changes: 0 additions & 3 deletions tests/unit_tests/synthetic/libraries/cusparse2hipsparse.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2066,19 +2066,16 @@ int main() {
// CHECK: status_t = hipsparseSpVV_bufferSize(handle_t, opX, spVecDescr_t, vecY, result, dataType, &bufferSize);
status_t = cusparseSpVV_bufferSize(handle_t, opX, spVecDescr_t, vecY, result, dataType, &bufferSize);

// TODO: Mark as C-Changed in 12.0.0
// CUDA: cusparseStatus_t CUSPARSEAPI cusparseSpVV(cusparseHandle_t handle, cusparseOperation_t opX, const cusparseSpVecDescr_t vecX, const cusparseDnVecDescr_t vecY, void* result, cudaDataType computeType, void* externalBuffer);
// HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseSpVV(hipsparseHandle_t handle, hipsparseOperation_t opX, hipsparseSpVecDescr_t vecX, hipsparseDnVecDescr_t vecY, void* result, hipDataType computeType, void* externalBuffer);
// CHECK: status_t = hipsparseSpVV(handle_t, opX, spVecDescr_t, vecY, result, dataType, tempBuffer);
status_t = cusparseSpVV(handle_t, opX, spVecDescr_t, vecY, result, dataType, tempBuffer);

// TODO: Mark as C-Changed in 12.0.0
// CUDA: cusparseStatus_t CUSPARSEAPI cusparseSpMV_bufferSize(cusparseHandle_t handle, cusparseOperation_t opA, const void* alpha, const cusparseSpMatDescr_t matA, const cusparseDnVecDescr_t vecX, const void* beta, const cusparseDnVecDescr_t vecY, cudaDataType computeType, cusparseSpMVAlg_t alg, size_t* bufferSize);
// HIP: hipsparseStatus_t hipsparseSpMV_bufferSize(hipsparseHandle_t handle, hipsparseOperation_t opA, const void* alpha, const hipsparseSpMatDescr_t matA, const hipsparseDnVecDescr_t vecX, const void* beta, const hipsparseDnVecDescr_t vecY, hipDataType computeType, hipsparseSpMVAlg_t alg, size_t* bufferSize);
// CHECK: status_t = hipsparseSpMV_bufferSize(handle_t, opA, alpha, spmatA, vecX, beta, vecY, dataType, spMVAlg_t, &bufferSize);
status_t = cusparseSpMV_bufferSize(handle_t, opA, alpha, spmatA, vecX, beta, vecY, dataType, spMVAlg_t, &bufferSize);

// TODO: Mark as C-Changed in 12.0.0
// CUDA: cusparseStatus_t CUSPARSEAPI cusparseSpMV(cusparseHandle_t handle, cusparseOperation_t opA, const void* alpha, const cusparseSpMatDescr_t matA, const cusparseDnVecDescr_t vecX, const void* beta, const cusparseDnVecDescr_t vecY, cudaDataType computeType, cusparseSpMVAlg_t alg, void* externalBuffer);
// HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseSpMV(hipsparseHandle_t handle, hipsparseOperation_t opA, const void* alpha, const hipsparseSpMatDescr_t matA, const hipsparseDnVecDescr_t vecX, const void* beta, const hipsparseDnVecDescr_t vecY, hipDataType computeType, hipsparseSpMVAlg_t alg, void* externalBuffer);
// CHECK: status_t = hipsparseSpMV(handle_t, opA, alpha, spmatA, vecX, beta, vecY, dataType, spMVAlg_t, tempBuffer);
Expand Down
7 changes: 1 addition & 6 deletions tests/unit_tests/synthetic/libraries/cusparse2rocsparse.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,7 @@ int main() {
cusparseStatus_t STATUS_NOT_SUPPORTED = CUSPARSE_STATUS_NOT_SUPPORTED;
#endif

#if (CUDA_VERSION >= 10020 && CUDA_VERSION < 11000 && !defined(_WIN32)) || CUDA_VERSION >= 11000
#if (CUDA_VERSION >= 10020 && CUSPARSE_VERSION >= 10200 && CUDA_VERSION < 11000 && !defined(_WIN32)) || CUDA_VERSION >= 11000
// CHECK: _rocsparse_spvec_descr *spVecDescr = nullptr;
// CHECK-NEXT: rocsparse_spvec_descr spVecDescr_t;
cusparseSpVecDescr *spVecDescr = nullptr;
Expand Down Expand Up @@ -1852,11 +1852,6 @@ int main() {
// CHECK: status_t = rocsparse_dnmat_set_values(dnMatDescr_t, values);
status_t = cusparseDnMatSetValues(dnMatDescr_t, values);

// CUDA: cusparseStatus_t CUSPARSEAPI cusparseSpMV(cusparseHandle_t handle, cusparseOperation_t opA, const void* alpha, cusparseConstSpMatDescr_t matA, cusparseConstDnVecDescr_t vecX, const void* beta, cusparseDnVecDescr_t vecY, cudaDataType computeType, cusparseSpMVAlg_t alg, void* externalBuffer);
// ROC: ROCSPARSE_EXPORT rocsparse_status rocsparse_spmv(rocsparse_handle handle, rocsparse_operation trans, const void* alpha, const rocsparse_spmat_descr mat, const rocsparse_dnvec_descr x, const void* beta, const rocsparse_dnvec_descr y, rocsparse_datatype compute_type, rocsparse_spmv_alg alg, size_t* buffer_size, void* temp_buffer);
// CHECK: status_t = rocsparse_spmv(handle_t, opA, alpha, spMatDescr_t, vecX, beta, vecY, dataType, spMVAlg_t, tempBuffer);
status_t = cusparseSpMV(handle_t, opA, alpha, spMatDescr_t, vecX, beta, vecY, dataType, spMVAlg_t, tempBuffer);

#if CUDA_VERSION < 12000
// CHECK: rocsparse_format FORMAT_COO_AOS = rocsparse_format_coo_aos;
cusparseFormat_t FORMAT_COO_AOS = CUSPARSE_FORMAT_COO_AOS;
Expand Down
20 changes: 19 additions & 1 deletion tests/unit_tests/synthetic/libraries/cusparse2rocsparse_12000.cu
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int main() {
cudaDataType dataType;
#endif

#if (CUDA_VERSION >= 10010 && CUDA_VERSION < 11000 && !defined(_WIN32)) || CUDA_VERSION >= 11000
#if (CUDA_VERSION >= 10010 && CUSPARSE_VERSION >= 10200 && CUDA_VERSION < 11000 && !defined(_WIN32)) || CUDA_VERSION >= 11000
// CHECK: rocsparse_spmat_descr spMatDescr_t, spmatA, spmatB, spmatC;
cusparseSpMatDescr_t spMatDescr_t, spmatA, spmatB, spmatC;

Expand All @@ -98,6 +98,14 @@ int main() {

// CHECK: rocsparse_spmm_alg spMMAlg_t;
cusparseSpMMAlg_t spMMAlg_t;

// CHECK: _rocsparse_dnvec_descr *dnVecDescr = nullptr;
// CHECK-NEXT: rocsparse_dnvec_descr dnVecDescr_t, vecX, vecY;
cusparseDnVecDescr *dnVecDescr = nullptr;
cusparseDnVecDescr_t dnVecDescr_t, vecX, vecY;

// CHECK: rocsparse_spmv_alg spMVAlg_t;
cusparseSpMVAlg_t spMVAlg_t;
#endif

#if CUDA_VERSION >= 11010 && CUSPARSE_VERSION >= 11300
Expand Down Expand Up @@ -179,6 +187,16 @@ int main() {
// ROC: ROCSPARSE_EXPORT rocsparse_status rocsparse_spvv(rocsparse_handle handle, rocsparse_operation trans, rocsparse_const_spvec_descr x, rocsparse_const_dnvec_descr y, void* result, rocsparse_datatype compute_type, size_t* buffer_size, void* temp_buffer);
// CHECK: status_t = rocsparse_spvv(handle_t, opX, constSpVecDescr, constDnVecDescr, result, dataType, &bufferSize, nullptr);
status_t = cusparseSpVV_bufferSize(handle_t, opX, constSpVecDescr, constDnVecDescr, result, dataType, &bufferSize);

// CUDA: cusparseStatus_t CUSPARSEAPI cusparseSpMV(cusparseHandle_t handle, cusparseOperation_t opA, const void* alpha, cusparseConstSpMatDescr_t matA, cusparseConstDnVecDescr_t vecX, const void* beta, cusparseDnVecDescr_t vecY, cudaDataType computeType, cusparseSpMVAlg_t alg, void* externalBuffer);
// ROC: ROCSPARSE_EXPORT rocsparse_status rocsparse_spmv(rocsparse_handle handle, rocsparse_operation trans, const void* alpha, rocsparse_const_spmat_descr mat, rocsparse_const_dnvec_descr x, const void* beta, const rocsparse_dnvec_descr y, rocsparse_datatype compute_type, rocsparse_spmv_alg alg, rocsparse_spmv_stage stage, size_t* buffer_size, void* temp_buffer);
// CHECK: status_t = rocsparse_spmv(handle_t, opA, alpha, constSpMatDescr, constDnVecDescr, beta, vecY, dataType, spMVAlg_t, rocsparse_spmv_stage_compute, tempBuffer);
status_t = cusparseSpMV(handle_t, opA, alpha, constSpMatDescr, constDnVecDescr, beta, vecY, dataType, spMVAlg_t, tempBuffer);

// CUDA: cusparseStatus_t CUSPARSEAPI cusparseSpMV_bufferSize(cusparseHandle_t handle, cusparseOperation_t opA, const void* alpha, cusparseConstSpMatDescr_t matA, cusparseConstDnVecDescr_t vecX, const void* beta, cusparseDnVecDescr_t vecY, cudaDataType computeType, cusparseSpMVAlg_t alg, size_t* bufferSize);
// ROC: ROCSPARSE_EXPORT rocsparse_status rocsparse_spmv(rocsparse_handle handle, rocsparse_operation trans, const void* alpha, rocsparse_const_spmat_descr mat, rocsparse_const_dnvec_descr x, const void* beta, const rocsparse_dnvec_descr y, rocsparse_datatype compute_type, rocsparse_spmv_alg alg, rocsparse_spmv_stage stage, size_t* buffer_size, void* temp_buffer);
// CHECK: status_t = rocsparse_spmv(handle_t, opA, alpha, constSpMatDescr, constDnVecDescr, beta, vecY, dataType, spMVAlg_t, rocsparse_spmv_stage_buffer_size, &bufferSize, nullptr);
status_t = cusparseSpMV_bufferSize(handle_t, opA, alpha, constSpMatDescr, constDnVecDescr, beta, vecY, dataType, spMVAlg_t, &bufferSize);
#endif

return 0;
Expand Down

0 comments on commit f40dcf6

Please sign in to comment.