Skip to content

Commit

Permalink
Merge pull request ROCm#1252 from emankov/HIPIFY
Browse files Browse the repository at this point in the history
[HIPIFY][ROCm#674][rocSPARSE][6.0.0][feature] rocSPARSE support - Step 81 - Functions (SpVec, Management)
  • Loading branch information
emankov authored Jan 1, 2024
2 parents 84037f6 + d3a4685 commit 78a016d
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 35 deletions.
5 changes: 5 additions & 0 deletions bin/hipify-perl
Original file line number Diff line number Diff line change
Expand Up @@ -2326,6 +2326,8 @@ sub rocSubstitutions {
subst("cusparseChybmv", "rocsparse_chybmv", "library");
subst("cusparseCnnz", "rocsparse_cnnz", "library");
subst("cusparseCnnz_compress", "rocsparse_cnnz_compress", "library");
subst("cusparseConstSpVecGet", "rocsparse_const_spvec_get", "library");
subst("cusparseConstSpVecGetValues", "rocsparse_const_spvec_get_values", "library");
subst("cusparseCooAoSGet", "rocsparse_coo_aos_get", "library");
subst("cusparseCooGet", "rocsparse_coo_get", "library");
subst("cusparseCooSetPointers", "rocsparse_coo_set_pointers", "library");
Expand All @@ -2334,6 +2336,7 @@ sub rocSubstitutions {
subst("cusparseCreate", "rocsparse_create_handle", "library");
subst("cusparseCreateBlockedEll", "rocsparse_create_bell_descr", "library");
subst("cusparseCreateColorInfo", "rocsparse_create_color_info", "library");
subst("cusparseCreateConstSpVec", "rocsparse_create_const_spvec_descr", "library");
subst("cusparseCreateCoo", "rocsparse_create_coo_descr", "library");
subst("cusparseCreateCooAoS", "rocsparse_create_coo_aos_descr", "library");
subst("cusparseCreateCsc", "rocsparse_create_csc_descr", "library");
Expand Down Expand Up @@ -2448,6 +2451,8 @@ sub rocSubstitutions {
subst("cusparseDroti", "rocsparse_droti", "library");
subst("cusparseDsctr", "rocsparse_dsctr", "library");
subst("cusparseGather", "rocsparse_gather", "library");
subst("cusparseGetErrorName", "rocsparse_get_status_name", "library");
subst("cusparseGetErrorString", "rocsparse_get_status_description", "library");
subst("cusparseGetMatDiagType", "rocsparse_get_mat_diag_type", "library");
subst("cusparseGetMatFillMode", "rocsparse_get_mat_fill_mode", "library");
subst("cusparseGetMatIndexBase", "rocsparse_get_mat_index_base", "library");
Expand Down
14 changes: 7 additions & 7 deletions docs/tables/CUSPARSE_API_supported_by_HIP_and_ROC.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@
|:--|:-:|:-:|:-:|:-:|:--|:-:|:-:|:-:|:-:|:-:|:--|:-:|:-:|:-:|:-:|:-:|
|`cusparseCreate`| | | | |`hipsparseCreate`|1.9.2| | | | |`rocsparse_create_handle`|1.9.0| | | | |
|`cusparseDestroy`| | | | |`hipsparseDestroy`|1.9.2| | | | |`rocsparse_destroy_handle`|1.9.0| | | | |
|`cusparseGetErrorName`|10.2| | | |`hipsparseGetErrorName`|6.0.0| | | | | | | | | | |
|`cusparseGetErrorString`|10.2| | | |`hipsparseGetErrorString`|6.0.0| | | | | | | | | | |
|`cusparseGetErrorName`|10.2| | | |`hipsparseGetErrorName`|6.0.0| | | | |`rocsparse_get_status_name`|6.0.0| | | | |
|`cusparseGetErrorString`|10.2| | | |`hipsparseGetErrorString`|6.0.0| | | | |`rocsparse_get_status_description`|6.0.0| | | | |
|`cusparseGetPointerMode`| | | | |`hipsparseGetPointerMode`|1.9.2| | | | |`rocsparse_get_pointer_mode`|1.9.0| | | | |
|`cusparseGetStream`|8.0| | | |`hipsparseGetStream`|1.9.2| | | | |`rocsparse_get_stream`|1.9.0| | | | |
|`cusparseGetVersion`| | | | |`hipsparseGetVersion`|1.9.2| | | | |`rocsparse_get_version`|1.9.0| | | | |
Expand Down Expand Up @@ -810,8 +810,8 @@
|`cusparseConstDnVecGet`|12.0| | | |`hipsparseConstDnVecGet`|6.0.0| | | | | | | | | | |
|`cusparseConstDnVecGetValues`|12.0| | | |`hipsparseConstDnVecGetValues`|6.0.0| | | | | | | | | | |
|`cusparseConstSpMatGetValues`|12.0| | | |`hipsparseConstSpMatGetValues`|6.0.0| | | | | | | | | | |
|`cusparseConstSpVecGet`|12.0| | | |`hipsparseConstSpVecGet`|6.0.0| | | | | | | | | | |
|`cusparseConstSpVecGetValues`|12.0| | | |`hipsparseConstSpVecGetValues`|6.0.0| | | | | | | | | | |
|`cusparseConstSpVecGet`|12.0| | | |`hipsparseConstSpVecGet`|6.0.0| | | | |`rocsparse_const_spvec_get`|6.0.0| | | | |
|`cusparseConstSpVecGetValues`|12.0| | | |`hipsparseConstSpVecGetValues`|6.0.0| | | | |`rocsparse_const_spvec_get_values`|6.0.0| | | | |
|`cusparseConstrainedGeMM`|10.2|11.2| |12.0| | | | | | | | | | | | |
|`cusparseConstrainedGeMM_bufferSize`|10.2|11.2| |12.0| | | | | | | | | | | | |
|`cusparseCooAoSGet`|10.2|11.2| |12.0|`hipsparseCooAoSGet`|4.1.0| | | | |`rocsparse_coo_aos_get`|4.1.0| | | | |
Expand All @@ -828,7 +828,7 @@
|`cusparseCreateConstDnMat`|12.0| | | |`hipsparseCreateConstDnMat`|6.0.0| | | | | | | | | | |
|`cusparseCreateConstDnVec`|12.0| | | |`hipsparseCreateConstDnVec`|6.0.0| | | | | | | | | | |
|`cusparseCreateConstSlicedEll`|12.1| | | | | | | | | | | | | | | |
|`cusparseCreateConstSpVec`|12.0| | | |`hipsparseCreateConstSpVec`|6.0.0| | | | | | | | | | |
|`cusparseCreateConstSpVec`|12.0| | | |`hipsparseCreateConstSpVec`|6.0.0| | | | |`rocsparse_create_const_spvec_descr`|6.0.0| | | | |
|`cusparseCreateCoo`|10.1| | | |`hipsparseCreateCoo`|4.1.0| | | | |`rocsparse_create_coo_descr`|4.1.0| | | | |
|`cusparseCreateCooAoS`|10.2|11.2| |12.0|`hipsparseCreateCooAoS`|4.1.0| | | | |`rocsparse_create_coo_aos_descr`|4.1.0| | | | |
|`cusparseCreateCsc`|11.1| | | |`hipsparseCreateCsc`|4.2.0| | | | |`rocsparse_create_csc_descr`|4.1.0| | | | |
Expand All @@ -848,7 +848,7 @@
|`cusparseDestroyDnMat`|10.1| |12.0| |`hipsparseDestroyDnMat`|4.2.0| |6.0.0| | |`rocsparse_destroy_dnmat_descr`|4.1.0| | | | |
|`cusparseDestroyDnVec`|10.2| |12.0| |`hipsparseDestroyDnVec`|4.1.0| |6.0.0| | |`rocsparse_destroy_dnvec_descr`|4.1.0| | | | |
|`cusparseDestroySpMat`|10.1| |12.0| |`hipsparseDestroySpMat`|4.1.0| |6.0.0| | |`rocsparse_destroy_spmat_descr`|4.1.0| | | | |
|`cusparseDestroySpVec`|10.2| |12.0| |`hipsparseDestroySpVec`|4.1.0| |6.0.0| | |`rocsparse_destroy_spvec_descr`|4.1.0| | | | |
|`cusparseDestroySpVec`|10.2| |12.0| |`hipsparseDestroySpVec`|4.1.0| |6.0.0| | |`rocsparse_destroy_spvec_descr`|4.1.0| |6.0.0| | |
|`cusparseDnMatGet`|10.1| | | |`hipsparseDnMatGet`|4.2.0| | | | |`rocsparse_dnmat_get`|4.1.0| | | | |
|`cusparseDnMatGetStridedBatch`|10.1| |12.0| |`hipsparseDnMatGetStridedBatch`|5.2.0| |6.0.0| | |`rocsparse_dnmat_get_strided_batch`|5.2.0| | | | |
|`cusparseDnMatGetValues`|10.2| | | |`hipsparseDnMatGetValues`|4.2.0| | | | |`rocsparse_dnmat_get_values`|4.1.0| | | | |
Expand Down Expand Up @@ -907,7 +907,7 @@
|`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| | | | | | | | |
|`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| | | | |
|`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| | | | |
|`cusparseSpVecSetValues`|10.2| | | |`hipsparseSpVecSetValues`|4.1.0| | | | |`rocsparse_spvec_set_values`|4.1.0| | | | |
|`cusparseSparseToDense`|11.1| |12.0| |`hipsparseSparseToDense`|4.2.0| |6.0.0| | | | | | | | |
Expand Down
14 changes: 7 additions & 7 deletions docs/tables/CUSPARSE_API_supported_by_ROC.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@
|:--|:-:|:-:|:-:|:-:|:--|:-:|:-:|:-:|:-:|:-:|
|`cusparseCreate`| | | | |`rocsparse_create_handle`|1.9.0| | | | |
|`cusparseDestroy`| | | | |`rocsparse_destroy_handle`|1.9.0| | | | |
|`cusparseGetErrorName`|10.2| | | | | | | | | |
|`cusparseGetErrorString`|10.2| | | | | | | | | |
|`cusparseGetErrorName`|10.2| | | |`rocsparse_get_status_name`|6.0.0| | | | |
|`cusparseGetErrorString`|10.2| | | |`rocsparse_get_status_description`|6.0.0| | | | |
|`cusparseGetPointerMode`| | | | |`rocsparse_get_pointer_mode`|1.9.0| | | | |
|`cusparseGetStream`|8.0| | | |`rocsparse_get_stream`|1.9.0| | | | |
|`cusparseGetVersion`| | | | |`rocsparse_get_version`|1.9.0| | | | |
Expand Down Expand Up @@ -810,8 +810,8 @@
|`cusparseConstDnVecGet`|12.0| | | | | | | | | |
|`cusparseConstDnVecGetValues`|12.0| | | | | | | | | |
|`cusparseConstSpMatGetValues`|12.0| | | | | | | | | |
|`cusparseConstSpVecGet`|12.0| | | | | | | | | |
|`cusparseConstSpVecGetValues`|12.0| | | | | | | | | |
|`cusparseConstSpVecGet`|12.0| | | |`rocsparse_const_spvec_get`|6.0.0| | | | |
|`cusparseConstSpVecGetValues`|12.0| | | |`rocsparse_const_spvec_get_values`|6.0.0| | | | |
|`cusparseConstrainedGeMM`|10.2|11.2| |12.0| | | | | | |
|`cusparseConstrainedGeMM_bufferSize`|10.2|11.2| |12.0| | | | | | |
|`cusparseCooAoSGet`|10.2|11.2| |12.0|`rocsparse_coo_aos_get`|4.1.0| | | | |
Expand All @@ -828,7 +828,7 @@
|`cusparseCreateConstDnMat`|12.0| | | | | | | | | |
|`cusparseCreateConstDnVec`|12.0| | | | | | | | | |
|`cusparseCreateConstSlicedEll`|12.1| | | | | | | | | |
|`cusparseCreateConstSpVec`|12.0| | | | | | | | | |
|`cusparseCreateConstSpVec`|12.0| | | |`rocsparse_create_const_spvec_descr`|6.0.0| | | | |
|`cusparseCreateCoo`|10.1| | | |`rocsparse_create_coo_descr`|4.1.0| | | | |
|`cusparseCreateCooAoS`|10.2|11.2| |12.0|`rocsparse_create_coo_aos_descr`|4.1.0| | | | |
|`cusparseCreateCsc`|11.1| | | |`rocsparse_create_csc_descr`|4.1.0| | | | |
Expand All @@ -848,7 +848,7 @@
|`cusparseDestroyDnMat`|10.1| |12.0| |`rocsparse_destroy_dnmat_descr`|4.1.0| | | | |
|`cusparseDestroyDnVec`|10.2| |12.0| |`rocsparse_destroy_dnvec_descr`|4.1.0| | | | |
|`cusparseDestroySpMat`|10.1| |12.0| |`rocsparse_destroy_spmat_descr`|4.1.0| | | | |
|`cusparseDestroySpVec`|10.2| |12.0| |`rocsparse_destroy_spvec_descr`|4.1.0| | | | |
|`cusparseDestroySpVec`|10.2| |12.0| |`rocsparse_destroy_spvec_descr`|4.1.0| |6.0.0| | |
|`cusparseDnMatGet`|10.1| | | |`rocsparse_dnmat_get`|4.1.0| | | | |
|`cusparseDnMatGetStridedBatch`|10.1| |12.0| |`rocsparse_dnmat_get_strided_batch`|5.2.0| | | | |
|`cusparseDnMatGetValues`|10.2| | | |`rocsparse_dnmat_get_values`|4.1.0| | | | |
Expand Down Expand Up @@ -907,7 +907,7 @@
|`cusparseSpVV`|10.2| |12.0| | | | | | | |
|`cusparseSpVV_bufferSize`|10.2| |12.0| | | | | | | |
|`cusparseSpVecGet`|10.2| | | |`rocsparse_spvec_get`|4.1.0| | | | |
|`cusparseSpVecGetIndexBase`|10.2| |12.0| |`rocsparse_spvec_get_index_base`|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| | | | |
|`cusparseSpVecSetValues`|10.2| | | |`rocsparse_spvec_set_values`|4.1.0| | | | |
|`cusparseSparseToDense`|11.1| |12.0| | | | | | | |
Expand Down
18 changes: 13 additions & 5 deletions src/CUDA2HIP_SPARSE_API_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const std::map<llvm::StringRef, hipCounter> CUDA_SPARSE_FUNCTION_MAP {
{"cusparseSetPointerMode", {"hipsparseSetPointerMode", "rocsparse_set_pointer_mode", CONV_LIB_FUNC, API_SPARSE, 5}},
{"cusparseSetStream", {"hipsparseSetStream", "rocsparse_set_stream", CONV_LIB_FUNC, API_SPARSE, 5}},
{"cusparseGetStream", {"hipsparseGetStream", "rocsparse_get_stream", CONV_LIB_FUNC, API_SPARSE, 5}},
{"cusparseGetErrorName", {"hipsparseGetErrorName", "", CONV_LIB_FUNC, API_SPARSE, 5, ROC_UNSUPPORTED}},
{"cusparseGetErrorString", {"hipsparseGetErrorString", "", CONV_LIB_FUNC, API_SPARSE, 5, ROC_UNSUPPORTED}},
{"cusparseGetErrorName", {"hipsparseGetErrorName", "rocsparse_get_status_name", CONV_LIB_FUNC, API_SPARSE, 5}},
{"cusparseGetErrorString", {"hipsparseGetErrorString", "rocsparse_get_status_description", CONV_LIB_FUNC, API_SPARSE, 5}},

// 6. cuSPARSE Logging
{"cusparseLoggerSetCallback", {"hipsparseLoggerSetCallback", "", CONV_LIB_FUNC, API_SPARSE, 6, UNSUPPORTED}},
Expand Down Expand Up @@ -778,13 +778,13 @@ const std::map<llvm::StringRef, hipCounter> CUDA_SPARSE_FUNCTION_MAP {
{"cusparseCreateConstSlicedEll", {"hipsparseCreateConstSlicedEll", "", CONV_LIB_FUNC, API_SPARSE, 15, UNSUPPORTED}},
// Sparse Vector descriptor
{"cusparseCreateSpVec", {"hipsparseCreateSpVec", "rocsparse_create_spvec_descr", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseCreateConstSpVec", {"hipsparseCreateConstSpVec", "", CONV_LIB_FUNC, API_SPARSE, 15, ROC_UNSUPPORTED}},
{"cusparseCreateConstSpVec", {"hipsparseCreateConstSpVec", "rocsparse_create_const_spvec_descr", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseDestroySpVec", {"hipsparseDestroySpVec", "rocsparse_destroy_spvec_descr", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseSpVecGet", {"hipsparseSpVecGet", "rocsparse_spvec_get", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseConstSpVecGet", {"hipsparseConstSpVecGet", "", CONV_LIB_FUNC, API_SPARSE, 15, ROC_UNSUPPORTED}},
{"cusparseConstSpVecGet", {"hipsparseConstSpVecGet", "rocsparse_const_spvec_get", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseSpVecGetIndexBase", {"hipsparseSpVecGetIndexBase", "rocsparse_spvec_get_index_base", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseSpVecGetValues", {"hipsparseSpVecGetValues", "rocsparse_spvec_get_values", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseConstSpVecGetValues", {"hipsparseConstSpVecGetValues", "", CONV_LIB_FUNC, API_SPARSE, 15, ROC_UNSUPPORTED}},
{"cusparseConstSpVecGetValues", {"hipsparseConstSpVecGetValues", "rocsparse_const_spvec_get_values", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseSpVecSetValues", {"hipsparseSpVecSetValues", "rocsparse_spvec_set_values", CONV_LIB_FUNC, API_SPARSE, 15}},

// Generic Dense API helper functions
Expand Down Expand Up @@ -2389,6 +2389,11 @@ const std::map<llvm::StringRef, hipAPIversions> HIP_SPARSE_FUNCTION_VER_MAP {
{"rocsparse_daxpyi", {HIP_1090, HIP_0, HIP_0 }},
{"rocsparse_caxpyi", {HIP_1090, HIP_0, HIP_0 }},
{"rocsparse_zaxpyi", {HIP_1090, HIP_0, HIP_0 }},
{"rocsparse_get_status_name", {HIP_6000, HIP_0, HIP_0 }},
{"rocsparse_get_status_description", {HIP_6000, HIP_0, HIP_0 }},
{"rocsparse_create_const_spvec_descr", {HIP_6000, HIP_0, HIP_0 }},
{"rocsparse_const_spvec_get", {HIP_6000, HIP_0, HIP_0 }},
{"rocsparse_const_spvec_get_values", {HIP_6000, HIP_0, HIP_0 }},
};

const std::map<llvm::StringRef, cudaAPIChangedVersions> CUDA_SPARSE_FUNCTION_CHANGED_VER_MAP {
Expand Down Expand Up @@ -2479,6 +2484,9 @@ const std::map<llvm::StringRef, hipAPIChangedVersions> HIP_SPARSE_FUNCTION_CHANG
{"hipsparseDenseToSparse_analysis", {HIP_6000}},
{"hipsparseDenseToSparse_bufferSize", {HIP_6000}},
{"hipsparseDenseToSparse_convert", {HIP_6000}},

{"rocsparse_destroy_spvec_descr", {HIP_6000}},
{"rocsparse_spvec_get_index_base", {HIP_6000}},
};

const std::map<unsigned int, llvm::StringRef> CUDA_SPARSE_API_SECTION_MAP {
Expand Down
2 changes: 0 additions & 2 deletions tests/unit_tests/synthetic/libraries/cusparse2hipsparse.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1845,13 +1845,11 @@ int main() {
status_t = cusparseCreateSpVec(&spVecDescr_t, size, nnz, indices, values, indexType_t, indexBase_t, dataType);

#if CUDA_VERSION < 12000
// TODO: Mark as C-Changed in 12.0.0
// CUDA: cusparseStatus_t CUSPARSEAPI cusparseDestroySpVec(cusparseSpVecDescr_t spVecDescr);
// HIP: hipsparseStatus_t hipsparseDestroySpVec(hipsparseSpVecDescr_t spVecDescr);
// CHECK: status_t = hipsparseDestroySpVec(spVecDescr_t);
status_t = cusparseDestroySpVec(spVecDescr_t);

// TODO: Mark as C-Changed in 12.0.0
// CUDA: cusparseStatus_t CUSPARSEAPI cusparseSpVecGetIndexBase(cusparseSpVecDescr_t spVecDescr, cusparseIndexBase_t* idxBase);
// HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseSpVecGetIndexBase(const hipsparseSpVecDescr_t spVecDescr, hipsparseIndexBase_t* idxBase);
// CHECK: status_t = hipsparseSpVecGetIndexBase(spVecDescr_t, &indexBase_t);
Expand Down
Loading

0 comments on commit 78a016d

Please sign in to comment.