Skip to content

Commit

Permalink
[HIPIFY][ROCm#674][rocSPARSE][6.0.0][feature] rocSPARSE support - Ste…
Browse files Browse the repository at this point in the history
…p 83 - Functions (SpMat)

+ Added new const `SpMat` functions
+ Marked some const `SpMat` functions as `CHANGED` due to ABI breakage
+ Updated `SPARSE` synthetic tests, the regenerated hipify-perl, and `SPARSE` `CUDA2HIP` documentation
  • Loading branch information
emankov committed Jan 2, 2024
1 parent b01b9ca commit c6d7246
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 45 deletions.
3 changes: 3 additions & 0 deletions bin/hipify-perl
Original file line number Diff line number Diff line change
Expand Up @@ -2326,8 +2326,11 @@ sub rocSubstitutions {
subst("cusparseChybmv", "rocsparse_chybmv", "library");
subst("cusparseCnnz", "rocsparse_cnnz", "library");
subst("cusparseCnnz_compress", "rocsparse_cnnz_compress", "library");
subst("cusparseConstBlockedEllGet", "rocsparse_const_bell_get", "library");
subst("cusparseConstCooGet", "rocsparse_const_coo_get", "library");
subst("cusparseConstCscGet", "rocsparse_const_csc_get", "library");
subst("cusparseConstCsrGet", "rocsparse_const_csr_get", "library");
subst("cusparseConstSpMatGetValues", "rocsparse_const_spmat_get_values", "library");
subst("cusparseConstSpVecGet", "rocsparse_const_spvec_get", "library");
subst("cusparseConstSpVecGetValues", "rocsparse_const_spvec_get_values", "library");
subst("cusparseCooAoSGet", "rocsparse_coo_aos_get", "library");
Expand Down
16 changes: 8 additions & 8 deletions docs/tables/CUSPARSE_API_supported_by_HIP_and_ROC.md
Original file line number Diff line number Diff line change
Expand Up @@ -801,15 +801,15 @@
|`cusparseAxpby`|11.0| |12.0| |`hipsparseAxpby`|4.1.0| |6.0.0| | |`rocsparse_axpby`|4.1.0| | | | |
|`cusparseBlockedEllGet`|11.2| | | |`hipsparseBlockedEllGet`|4.5.0| | | | |`rocsparse_bell_get`|4.1.0| | | | |
|`cusparseBsrSetStridedBatch`|12.1| | | | | | | | | | | | | | | |
|`cusparseConstBlockedEllGet`|12.0| | | |`hipsparseConstBlockedEllGet`|6.0.0| | | | | | | | | | |
|`cusparseConstBlockedEllGet`|12.0| | | |`hipsparseConstBlockedEllGet`|6.0.0| | | | |`rocsparse_const_bell_get`|6.0.0| | | | |
|`cusparseConstCooGet`|12.0| | | |`hipsparseConstCooGet`|6.0.0| | | | |`rocsparse_const_coo_get`|6.0.0| | | | |
|`cusparseConstCscGet`|12.0| | | | | | | | | | | | | | | |
|`cusparseConstCscGet`|12.0| | | | | | | | | |`rocsparse_const_csc_get`|6.0.0| | | | |
|`cusparseConstCsrGet`|12.0| | | |`hipsparseConstCsrGet`|6.0.0| | | | |`rocsparse_const_csr_get`|6.0.0| | | | |
|`cusparseConstDnMatGet`|12.0| | | |`hipsparseConstDnMatGet`|6.0.0| | | | | | | | | | |
|`cusparseConstDnMatGetValues`|12.0| | | |`hipsparseConstDnMatGetValues`|6.0.0| | | | | | | | | | |
|`cusparseConstDnVecGet`|12.0| | | |`hipsparseConstDnVecGet`|6.0.0| | | | | | | | | | |
|`cusparseConstDnVecGetValues`|12.0| | | |`hipsparseConstDnVecGetValues`|6.0.0| | | | | | | | | | |
|`cusparseConstSpMatGetValues`|12.0| | | |`hipsparseConstSpMatGetValues`|6.0.0| | | | | | | | | | |
|`cusparseConstSpMatGetValues`|12.0| | | |`hipsparseConstSpMatGetValues`|6.0.0| | | | |`rocsparse_const_spmat_get_values`|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| | | | | | | | | | | | |
Expand Down Expand Up @@ -882,12 +882,12 @@
|`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| | | | | | | | |
|`cusparseSpMatGetAttribute`|11.3| |12.0| |`hipsparseSpMatGetAttribute`|4.5.0| |6.0.0| | |`rocsparse_spmat_get_attribute`|4.5.0| | | | |
|`cusparseSpMatGetFormat`|10.1| |12.0| |`hipsparseSpMatGetFormat`|4.1.0| |6.0.0| | |`rocsparse_spmat_get_format`|4.1.0| | | | |
|`cusparseSpMatGetIndexBase`|10.1| |12.0| |`hipsparseSpMatGetIndexBase`|4.1.0| |6.0.0| | |`rocsparse_spmat_get_index_base`|4.1.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| | |
|`cusparseSpMatGetNumBatches`|10.1| | |10.2| | | | | | | | | | | | |
|`cusparseSpMatGetSize`|11.0| |12.0| |`hipsparseSpMatGetSize`|4.1.0| |6.0.0| | |`rocsparse_spmat_get_size`|4.1.0| | | | |
|`cusparseSpMatGetStridedBatch`|10.2| |12.0| |`hipsparseSpMatGetStridedBatch`|5.2.0| |6.0.0| | |`rocsparse_spmat_get_strided_batch`|5.2.0| | | | |
|`cusparseSpMatGetSize`|11.0| |12.0| |`hipsparseSpMatGetSize`|4.1.0| |6.0.0| | |`rocsparse_spmat_get_size`|4.1.0| |6.0.0| | |
|`cusparseSpMatGetStridedBatch`|10.2| |12.0| |`hipsparseSpMatGetStridedBatch`|5.2.0| |6.0.0| | |`rocsparse_spmat_get_strided_batch`|5.2.0| |6.0.0| | |
|`cusparseSpMatGetValues`|10.2| | | |`hipsparseSpMatGetValues`|4.1.0| | | | |`rocsparse_spmat_get_values`|4.1.0| | | | |
|`cusparseSpMatSetAttribute`|11.3| | | |`hipsparseSpMatSetAttribute`|4.5.0| | | | |`rocsparse_spmat_set_attribute`|4.5.0| | | | |
|`cusparseSpMatSetNumBatches`|10.1| | |10.2| | | | | | | | | | | | |
Expand Down
16 changes: 8 additions & 8 deletions docs/tables/CUSPARSE_API_supported_by_ROC.md
Original file line number Diff line number Diff line change
Expand Up @@ -801,15 +801,15 @@
|`cusparseAxpby`|11.0| |12.0| |`rocsparse_axpby`|4.1.0| | | | |
|`cusparseBlockedEllGet`|11.2| | | |`rocsparse_bell_get`|4.1.0| | | | |
|`cusparseBsrSetStridedBatch`|12.1| | | | | | | | | |
|`cusparseConstBlockedEllGet`|12.0| | | | | | | | | |
|`cusparseConstBlockedEllGet`|12.0| | | |`rocsparse_const_bell_get`|6.0.0| | | | |
|`cusparseConstCooGet`|12.0| | | |`rocsparse_const_coo_get`|6.0.0| | | | |
|`cusparseConstCscGet`|12.0| | | | | | | | | |
|`cusparseConstCscGet`|12.0| | | |`rocsparse_const_csc_get`|6.0.0| | | | |
|`cusparseConstCsrGet`|12.0| | | |`rocsparse_const_csr_get`|6.0.0| | | | |
|`cusparseConstDnMatGet`|12.0| | | | | | | | | |
|`cusparseConstDnMatGetValues`|12.0| | | | | | | | | |
|`cusparseConstDnVecGet`|12.0| | | | | | | | | |
|`cusparseConstDnVecGetValues`|12.0| | | | | | | | | |
|`cusparseConstSpMatGetValues`|12.0| | | | | | | | | |
|`cusparseConstSpMatGetValues`|12.0| | | |`rocsparse_const_spmat_get_values`|6.0.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| | | | | | |
Expand Down Expand Up @@ -882,12 +882,12 @@
|`cusparseSpMM_preprocess`|11.2| |12.0| | | | | | | |
|`cusparseSpMV`|10.2| |12.0| |`rocsparse_spmv`|4.1.0| | | | |
|`cusparseSpMV_bufferSize`|10.2| |12.0| | | | | | | |
|`cusparseSpMatGetAttribute`|11.3| |12.0| |`rocsparse_spmat_get_attribute`|4.5.0| | | | |
|`cusparseSpMatGetFormat`|10.1| |12.0| |`rocsparse_spmat_get_format`|4.1.0| | | | |
|`cusparseSpMatGetIndexBase`|10.1| |12.0| |`rocsparse_spmat_get_index_base`|4.1.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| | |
|`cusparseSpMatGetNumBatches`|10.1| | |10.2| | | | | | |
|`cusparseSpMatGetSize`|11.0| |12.0| |`rocsparse_spmat_get_size`|4.1.0| | | | |
|`cusparseSpMatGetStridedBatch`|10.2| |12.0| |`rocsparse_spmat_get_strided_batch`|5.2.0| | | | |
|`cusparseSpMatGetSize`|11.0| |12.0| |`rocsparse_spmat_get_size`|4.1.0| |6.0.0| | |
|`cusparseSpMatGetStridedBatch`|10.2| |12.0| |`rocsparse_spmat_get_strided_batch`|5.2.0| |6.0.0| | |
|`cusparseSpMatGetValues`|10.2| | | |`rocsparse_spmat_get_values`|4.1.0| | | | |
|`cusparseSpMatSetAttribute`|11.3| | | |`rocsparse_spmat_set_attribute`|4.5.0| | | | |
|`cusparseSpMatSetNumBatches`|10.1| | |10.2| | | | | | |
Expand Down
14 changes: 11 additions & 3 deletions src/CUDA2HIP_SPARSE_API_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,13 +751,13 @@ const std::map<llvm::StringRef, hipCounter> CUDA_SPARSE_FUNCTION_MAP {
{"cusparseCsrSetPointers", {"hipsparseCsrSetPointers", "rocsparse_csr_set_pointers", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseCscSetPointers", {"hipsparseCscSetPointers", "rocsparse_csc_set_pointers", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseCscGet", {"hipsparseCscGet", "", CONV_LIB_FUNC, API_SPARSE, 15, UNSUPPORTED}},
{"cusparseConstCscGet", {"hipsparseConstCscGet", "", CONV_LIB_FUNC, API_SPARSE, 15, UNSUPPORTED}},
{"cusparseConstCscGet", {"hipsparseConstCscGet", "rocsparse_const_csc_get", CONV_LIB_FUNC, API_SPARSE, 15, HIP_UNSUPPORTED}},
{"cusparseCooSetPointers", {"hipsparseCooSetPointers", "rocsparse_coo_set_pointers", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseCsrSetStridedBatch", {"hipsparseCsrSetStridedBatch", "rocsparse_csr_set_strided_batch", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseSpMatGetFormat", {"hipsparseSpMatGetFormat", "rocsparse_spmat_get_format", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseSpMatGetIndexBase", {"hipsparseSpMatGetIndexBase", "rocsparse_spmat_get_index_base", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseSpMatGetValues", {"hipsparseSpMatGetValues", "rocsparse_spmat_get_values", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseConstSpMatGetValues", {"hipsparseConstSpMatGetValues", "", CONV_LIB_FUNC, API_SPARSE, 15, ROC_UNSUPPORTED}},
{"cusparseConstSpMatGetValues", {"hipsparseConstSpMatGetValues", "rocsparse_const_spmat_get_values", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseSpMatSetValues", {"hipsparseSpMatSetValues", "rocsparse_spmat_set_values", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseSpMatGetStridedBatch", {"hipsparseSpMatGetStridedBatch", "rocsparse_spmat_get_strided_batch", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseSpMatSetStridedBatch", {"hipsparseSpMatSetStridedBatch", "rocsparse_spmat_set_strided_batch", CONV_LIB_FUNC, API_SPARSE, 15, CUDA_REMOVED}},
Expand All @@ -767,7 +767,7 @@ const std::map<llvm::StringRef, hipCounter> CUDA_SPARSE_FUNCTION_MAP {
{"cusparseSpMatGetAttribute", {"hipsparseSpMatGetAttribute", "rocsparse_spmat_get_attribute", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseSpMatSetAttribute", {"hipsparseSpMatSetAttribute", "rocsparse_spmat_set_attribute", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseBlockedEllGet", {"hipsparseBlockedEllGet", "rocsparse_bell_get", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseConstBlockedEllGet", {"hipsparseConstBlockedEllGet", "", CONV_LIB_FUNC, API_SPARSE, 15, ROC_UNSUPPORTED}},
{"cusparseConstBlockedEllGet", {"hipsparseConstBlockedEllGet", "rocsparse_const_bell_get", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseCreateBlockedEll", {"hipsparseCreateBlockedEll", "rocsparse_create_bell_descr", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseCreateConstBlockedEll", {"hipsparseCreateConstBlockedEll", "rocsparse_create_const_bell_descr", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseBsrSetStridedBatch", {"hipsparseBsrSetStridedBatch", "", CONV_LIB_FUNC, API_SPARSE, 15, UNSUPPORTED}},
Expand Down Expand Up @@ -2400,6 +2400,9 @@ const std::map<llvm::StringRef, hipAPIversions> HIP_SPARSE_FUNCTION_VER_MAP {
{"rocsparse_create_const_bell_descr", {HIP_6000, HIP_0, HIP_0 }},
{"rocsparse_const_coo_get", {HIP_6000, HIP_0, HIP_0 }},
{"rocsparse_const_csr_get", {HIP_6000, HIP_0, HIP_0 }},
{"rocsparse_const_csc_get", {HIP_6000, HIP_0, HIP_0 }},
{"rocsparse_const_bell_get", {HIP_6000, HIP_0, HIP_0 }},
{"rocsparse_const_spmat_get_values", {HIP_6000, HIP_0, HIP_0 }},
};

const std::map<llvm::StringRef, cudaAPIChangedVersions> CUDA_SPARSE_FUNCTION_CHANGED_VER_MAP {
Expand Down Expand Up @@ -2494,6 +2497,11 @@ const std::map<llvm::StringRef, hipAPIChangedVersions> HIP_SPARSE_FUNCTION_CHANG
{"rocsparse_destroy_spvec_descr", {HIP_6000}},
{"rocsparse_spvec_get_index_base", {HIP_6000}},
{"rocsparse_destroy_spmat_descr", {HIP_6000}},
{"rocsparse_spmat_get_size", {HIP_6000}},
{"rocsparse_spmat_get_format", {HIP_6000}},
{"rocsparse_spmat_get_index_base", {HIP_6000}},
{"rocsparse_spmat_get_strided_batch", {HIP_6000}},
{"rocsparse_spmat_get_attribute", {HIP_6000}},
};

const std::map<unsigned int, llvm::StringRef> CUDA_SPARSE_API_SECTION_MAP {
Expand Down
5 changes: 0 additions & 5 deletions tests/unit_tests/synthetic/libraries/cusparse2hipsparse.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1751,13 +1751,11 @@ int main() {
// CHECK: status_t = hipsparseDestroySpMat(spMatDescr_t);
status_t = cusparseDestroySpMat(spMatDescr_t);

// TODO: Mark as C-Changed in 12.0.0
// CUDA: cusparseStatus_t CUSPARSEAPI cusparseSpMatGetFormat(cusparseSpMatDescr_t spMatDescr, cusparseFormat_t* format);
// HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseSpMatGetFormat(const hipsparseSpMatDescr_t spMatDescr, hipsparseFormat_t* format);
// CHECK: status_t = hipsparseSpMatGetFormat(spMatDescr_t, &format_t);
status_t = cusparseSpMatGetFormat(spMatDescr_t, &format_t);

// TODO: Mark as C-Changed in 12.0.0
// CUDA: cusparseStatus_t CUSPARSEAPI cusparseSpMatGetIndexBase(cusparseSpMatDescr_t spMatDescr, cusparseIndexBase_t* idxBase);
// HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseSpMatGetIndexBase(const hipsparseSpMatDescr_t spMatDescr, hipsparseIndexBase_t* idxBase);
// CHECK: status_t = hipsparseSpMatGetIndexBase(spMatDescr_t, &indexBase_t);
Expand Down Expand Up @@ -1854,7 +1852,6 @@ int main() {
// CHECK: status_t = hipsparseSpVecGetIndexBase(spVecDescr_t, &indexBase_t);
status_t = cusparseSpVecGetIndexBase(spVecDescr_t, &indexBase_t);

// TODO: Mark as C-Changed in 12.0.0
// CUDA: cusparseStatus_t CUSPARSEAPI cusparseSpMatGetStridedBatch(cusparseSpMatDescr_t spMatDescr, int* batchCount);
// HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseSpMatGetStridedBatch(hipsparseSpMatDescr_t spMatDescr, int* batchCount);
// CHECK: status_t = hipsparseSpMatGetStridedBatch(spMatDescr_t, &batchCount);
Expand Down Expand Up @@ -2266,7 +2263,6 @@ int main() {
status_t = cusparseCsrSetPointers(spMatDescr_t, csrRowOffsets, csrColInd, csrValues);

#if CUDA_VERSION < 12000
// TODO: Mark as C-Changed in 12.0.0
// CUDA: cusparseStatus_t CUSPARSEAPI cusparseSpMatGetSize(cusparseSpMatDescr_t spMatDescr, int64_t* rows, int64_t* cols, int64_t* nnz);
// HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseSpMatGetSize(hipsparseSpMatDescr_t spMatDescr, int64_t* rows, int64_t* cols, int64_t* nnz);
// CHECK: status_t = hipsparseSpMatGetSize(spMatDescr_t, &rows, &cols, &nnz);
Expand Down Expand Up @@ -2482,7 +2478,6 @@ int main() {
cusparseSpSVDescr_t spSVDescr;

#if CUDA_VERSION < 12000
// TODO: Mark as C-Changed in 12.0.0
// CUDA: cusparseStatus_t CUSPARSEAPI cusparseSpMatGetAttribute(cusparseSpMatDescr_t spMatDescr, cusparseSpMatAttribute_t attribute, void* data, size_t dataSize);
// HIP: hipsparseStatus_t hipsparseSpMatGetAttribute(hipsparseSpMatDescr_t spMatDescr, hipsparseSpMatAttribute_t attribute, void* data, size_t dataSize);
// CHECK: status_t = hipsparseSpMatGetAttribute(spMatDescr_t, spMatAttribute_t, &data, dataSize);
Expand Down
Loading

0 comments on commit c6d7246

Please sign in to comment.