Skip to content

Commit

Permalink
[HIPIFY][ROCm#674][rocSPARSE][feature] rocSPARSE support - Step 99 - …
Browse files Browse the repository at this point in the history
…`cusparseSparseToDense_bufferSize` -> `rocsparse_sparse_to_dense`

+ [IMP] `rocsparse_sparse_to_dense` has been changed in 6.0.0; so reflected that in HIPIFY, docs, and tests
+ Updated `SPARSE` synthetic tests, the regenerated hipify-perl, and `SPARSE` `CUDA2HIP` documentation
  • Loading branch information
emankov committed Jan 17, 2024
1 parent 5d82b98 commit 247d691
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 7 deletions.
1 change: 1 addition & 0 deletions bin/hipify-perl
Original file line number Diff line number Diff line change
Expand Up @@ -2611,6 +2611,7 @@ sub rocSubstitutions {
subst("cusparseSpVecGetValues", "rocsparse_spvec_get_values", "library");
subst("cusparseSpVecSetValues", "rocsparse_spvec_set_values", "library");
subst("cusparseSparseToDense", "rocsparse_sparse_to_dense", "library");
subst("cusparseSparseToDense_bufferSize", "rocsparse_sparse_to_dense", "library");
subst("cusparseSpruneCsr2csr", "rocsparse_sprune_csr2csr", "library");
subst("cusparseSpruneCsr2csrByPercentage", "rocsparse_sprune_csr2csr_by_percentage", "library");
subst("cusparseSpruneCsr2csrByPercentage_bufferSizeExt", "rocsparse_sprune_csr2csr_by_percentage_buffer_size", "library");
Expand Down
2 changes: 1 addition & 1 deletion docs/tables/CUSPARSE_API_supported_by_HIP_and_ROC.md
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@
|`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| | |`rocsparse_sparse_to_dense`|4.1.0| |6.0.0| | |
|`cusparseSparseToDense_bufferSize`|11.1| |12.0| |`hipsparseSparseToDense_bufferSize`|4.2.0| |6.0.0| | | | | | | | |
|`cusparseSparseToDense_bufferSize`|11.1| |12.0| |`hipsparseSparseToDense_bufferSize`|4.2.0| |6.0.0| | |`rocsparse_sparse_to_dense`|4.1.0| |6.0.0| | |


\*A - Added; D - Deprecated; C - Changed; R - Removed; E - Experimental
2 changes: 1 addition & 1 deletion docs/tables/CUSPARSE_API_supported_by_ROC.md
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@
|`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| |`rocsparse_sparse_to_dense`|4.1.0| |6.0.0| | |
|`cusparseSparseToDense_bufferSize`|11.1| |12.0| | | | | | | |
|`cusparseSparseToDense_bufferSize`|11.1| |12.0| |`rocsparse_sparse_to_dense`|4.1.0| |6.0.0| | |


\*A - Added; D - Deprecated; C - Changed; R - Removed; E - Experimental
6 changes: 3 additions & 3 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 {
{"cusparseSpMV_bufferSize", {"hipsparseSpMV_bufferSize", "", CONV_LIB_FUNC, API_SPARSE, 15, ROC_UNSUPPORTED}},

{"cusparseSparseToDense", {"hipsparseSparseToDense", "rocsparse_sparse_to_dense", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseSparseToDense_bufferSize", {"hipsparseSparseToDense_bufferSize", "", CONV_LIB_FUNC, API_SPARSE, 15, ROC_UNSUPPORTED}},
{"cusparseSparseToDense_bufferSize", {"hipsparseSparseToDense_bufferSize", "rocsparse_sparse_to_dense", CONV_LIB_FUNC, API_SPARSE, 15}},
{"cusparseDenseToSparse_bufferSize", {"hipsparseDenseToSparse_bufferSize", "", CONV_LIB_FUNC, API_SPARSE, 15, ROC_UNSUPPORTED}},
{"cusparseDenseToSparse_analysis", {"hipsparseDenseToSparse_analysis", "", CONV_LIB_FUNC, API_SPARSE, 15, ROC_UNSUPPORTED}},
{"cusparseDenseToSparse_convert", {"hipsparseDenseToSparse_convert", "", CONV_LIB_FUNC, API_SPARSE, 15, ROC_UNSUPPORTED}},
Expand Down Expand Up @@ -1222,8 +1222,8 @@ const std::map<llvm::StringRef, cudaAPIversions> CUDA_SPARSE_FUNCTION_VER_MAP {
{"cusparseCsrSetPointers", {CUDA_110, CUDA_0, CUDA_0 }},
{"cusparseCscSetPointers", {CUDA_111, CUDA_0, CUDA_0 }},
{"cusparseCooSetPointers", {CUDA_111, CUDA_0, CUDA_0 }},
{"cusparseSparseToDense_bufferSize", {CUDA_111, CUDA_0, CUDA_0 }},
{"cusparseSparseToDense", {CUDA_111, CUDA_0, CUDA_0 }},// A: CUSPARSE_VERSION 11300 C: CUSPARSE_VERSION 12000
{"cusparseSparseToDense_bufferSize", {CUDA_111, CUDA_0, CUDA_0 }}, // A: CUSPARSE_VERSION 11300 C: CUSPARSE_VERSION 12000
{"cusparseSparseToDense", {CUDA_111, CUDA_0, CUDA_0 }}, // A: CUSPARSE_VERSION 11300 C: CUSPARSE_VERSION 12000
{"cusparseDenseToSparse_bufferSize", {CUDA_111, CUDA_0, CUDA_0 }},
{"cusparseDenseToSparse_analysis", {CUDA_111, CUDA_0, CUDA_0 }},
{"cusparseDenseToSparse_convert", {CUDA_111, CUDA_0, CUDA_0 }},
Expand Down
13 changes: 12 additions & 1 deletion src/HipifyAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ const std::string sCusparseDbsrilu02_bufferSize = "cusparseDbsrilu02_bufferSize"
const std::string sCusparseSbsrilu02_bufferSize = "cusparseSbsrilu02_bufferSize";
const std::string sCusparseCsr2cscEx2_bufferSize = "cusparseCsr2cscEx2_bufferSize";
const std::string sCusparseSparseToDense = "cusparseSparseToDense";
const std::string sCusparseSparseToDense_bufferSize = "cusparseSparseToDense_bufferSize";

// CUDA_OVERLOADED
const std::string sCudaEventCreate = "cudaEventCreate";
Expand Down Expand Up @@ -1641,6 +1642,15 @@ std::map<std::string, ArgCastStruct> FuncArgCasts {
false
}
},
{sCusparseSparseToDense_bufferSize,
{
{
{5, {e_add_const_argument, cw_None, "nullptr"}}
},
true,
false
}
},
};

void HipifyAction::RewriteString(StringRef s, clang::SourceLocation start) {
Expand Down Expand Up @@ -2486,7 +2496,8 @@ std::unique_ptr<clang::ASTConsumer> HipifyAction::CreateASTConsumer(clang::Compi
sCusparseDbsrilu02_bufferSize,
sCusparseSbsrilu02_bufferSize,
sCusparseCsr2cscEx2_bufferSize,
sCusparseSparseToDense
sCusparseSparseToDense,
sCusparseSparseToDense_bufferSize
)
)
)
Expand Down
1 change: 0 additions & 1 deletion tests/unit_tests/synthetic/libraries/cusparse2hipsparse.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2575,7 +2575,6 @@ int main() {
status_t = cusparseCscSetPointers(spMatDescr_t, cscColOffsets, cscRowInd, cscValues);

#if CUDA_VERSION < 12000
// TODO: Mark as C-Changed in 12.0.0
// CUDA: cusparseStatus_t CUSPARSEAPI cusparseSparseToDense_bufferSize(cusparseHandle_t handle, cusparseSpMatDescr_t matA, cusparseDnMatDescr_t matB, cusparseSparseToDenseAlg_t alg, size_t* bufferSize);
// HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseSparseToDense_bufferSize(hipsparseHandle_t handle, hipsparseSpMatDescr_t matA, hipsparseDnMatDescr_t matB, hipsparseSparseToDenseAlg_t alg, size_t* bufferSize);
// CHECK: status_t = hipsparseSparseToDense_bufferSize(handle_t, spmatA, dnmatB, sparseToDenseAlg_t, &bufferSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ int main() {
int csrColIndC = 0;
int csrColIndD = 0;
int bufferSizeInBytes = 0;
size_t bufferSize = 0;
double dA = 0.f;
double dB = 0.f;
double dAlpha = 0.f;
Expand Down Expand Up @@ -102,6 +103,11 @@ int main() {
// ROC: ROCSPARSE_EXPORT rocsparse_status rocsparse_sparse_to_dense(rocsparse_handle handle, rocsparse_const_spmat_descr mat_A, rocsparse_dnmat_descr mat_B, rocsparse_sparse_to_dense_alg alg, size_t* buffer_size, void* temp_buffer);
// CHECK: status_t = rocsparse_sparse_to_dense(handle_t, constSpMatDescr, dnmatB, sparseToDenseAlg_t, nullptr, tempBuffer);
status_t = cusparseSparseToDense(handle_t, constSpMatDescr, dnmatB, sparseToDenseAlg_t, tempBuffer);

// CUDA: cusparseStatus_t CUSPARSEAPI cusparseSparseToDense_bufferSize(cusparseHandle_t handle, cusparseConstSpMatDescr_t matA, cusparseDnMatDescr_t matB, cusparseSparseToDenseAlg_t alg, size_t* bufferSize);
// ROC: ROCSPARSE_EXPORT rocsparse_status rocsparse_sparse_to_dense(rocsparse_handle handle, rocsparse_const_spmat_descr mat_A, rocsparse_dnmat_descr mat_B, rocsparse_sparse_to_dense_alg alg, size_t* buffer_size, void* temp_buffer);
// CHECK: status_t = rocsparse_sparse_to_dense(handle_t, constSpMatDescr, dnmatB, sparseToDenseAlg_t, &bufferSize, nullptr);
status_t = cusparseSparseToDense_bufferSize(handle_t, constSpMatDescr, dnmatB, sparseToDenseAlg_t, &bufferSize);
#endif

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ int main() {
int csrColIndC = 0;
int csrColIndD = 0;
int bufferSizeInBytes = 0;
size_t bufferSize = 0;
double dA = 0.f;
double dB = 0.f;
double dAlpha = 0.f;
Expand Down Expand Up @@ -96,6 +97,11 @@ int main() {
// ROC: ROCSPARSE_EXPORT rocsparse_status rocsparse_sparse_to_dense(rocsparse_handle handle, const rocsparse_spmat_descr mat_A, rocsparse_dnmat_descr mat_B, rocsparse_sparse_to_dense_alg alg, size_t* buffer_size, void* temp_buffer);
// CHECK: status_t = rocsparse_sparse_to_dense(handle_t, spmatA, dnmatB, sparseToDenseAlg_t, nullptr, tempBuffer);
status_t = cusparseSparseToDense(handle_t, spmatA, dnmatB, sparseToDenseAlg_t, tempBuffer);

// CUDA: cusparseStatus_t CUSPARSEAPI cusparseSparseToDense_bufferSize(cusparseHandle_t handle, cusparseSpMatDescr_t matA, cusparseDnMatDescr_t matB, cusparseSparseToDenseAlg_t alg, size_t* bufferSize);
// ROC: ROCSPARSE_EXPORT rocsparse_status rocsparse_sparse_to_dense(rocsparse_handle handle, const rocsparse_spmat_descr mat_A, rocsparse_dnmat_descr mat_B, rocsparse_sparse_to_dense_alg alg, size_t* buffer_size, void* temp_buffer);
// CHECK: status_t = rocsparse_sparse_to_dense(handle_t, spmatA, dnmatB, sparseToDenseAlg_t, &bufferSize, nullptr);
status_t = cusparseSparseToDense_bufferSize(handle_t, spmatA, dnmatB, sparseToDenseAlg_t, &bufferSize);
#endif
#endif

Expand Down

0 comments on commit 247d691

Please sign in to comment.