Skip to content

Commit

Permalink
[HIPIFY][ROCm#674][rocSPARSE][feature] rocSPARSE support - Step 40 - …
Browse files Browse the repository at this point in the history
…functions

+ Updated synthetic tests and the regenerated hipify-perl and SPARSE docs
  • Loading branch information
emankov committed Sep 11, 2023
1 parent 472483d commit 31e51d6
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 13 deletions.
4 changes: 4 additions & 0 deletions bin/hipify-perl
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,7 @@ sub rocSubstitutions {
subst("cusparseCcsr2hyb", "rocsparse_ccsr2hyb", "library");
subst("cusparseCcsrcolor", "rocsparse_ccsrcolor", "library");
subst("cusparseCcsrilu02", "rocsparse_ccsrilu0", "library");
subst("cusparseCcsrilu02_analysis", "rocsparse_ccsrilu0_analysis", "library");
subst("cusparseCdense2csc", "rocsparse_cdense2csc", "library");
subst("cusparseCdense2csr", "rocsparse_cdense2csr", "library");
subst("cusparseCgebsr2csr", "rocsparse_cgebsr2csr", "library");
Expand Down Expand Up @@ -1734,6 +1735,7 @@ sub rocSubstitutions {
subst("cusparseDcsr2hyb", "rocsparse_dcsr2hyb", "library");
subst("cusparseDcsrcolor", "rocsparse_dcsrcolor", "library");
subst("cusparseDcsrilu02", "rocsparse_dcsrilu0", "library");
subst("cusparseDcsrilu02_analysis", "rocsparse_dcsrilu0_analysis", "library");
subst("cusparseDdense2csc", "rocsparse_ddense2csc", "library");
subst("cusparseDdense2csr", "rocsparse_ddense2csr", "library");
subst("cusparseDestroy", "rocsparse_destroy_handle", "library");
Expand Down Expand Up @@ -1804,6 +1806,7 @@ sub rocSubstitutions {
subst("cusparseScsr2hyb", "rocsparse_scsr2hyb", "library");
subst("cusparseScsrcolor", "rocsparse_scsrcolor", "library");
subst("cusparseScsrilu02", "rocsparse_scsrilu0", "library");
subst("cusparseScsrilu02_analysis", "rocsparse_scsrilu0_analysis", "library");
subst("cusparseSdense2csc", "rocsparse_sdense2csc", "library");
subst("cusparseSdense2csr", "rocsparse_sdense2csr", "library");
subst("cusparseSetMatDiagType", "rocsparse_set_mat_diag_type", "library");
Expand Down Expand Up @@ -1877,6 +1880,7 @@ sub rocSubstitutions {
subst("cusparseZcsr2hyb", "rocsparse_zcsr2hyb", "library");
subst("cusparseZcsrcolor", "rocsparse_zcsrcolor", "library");
subst("cusparseZcsrilu02", "rocsparse_zcsrilu0", "library");
subst("cusparseZcsrilu02_analysis", "rocsparse_zcsrilu0_analysis", "library");
subst("cusparseZdense2csc", "rocsparse_zdense2csc", "library");
subst("cusparseZdense2csr", "rocsparse_zdense2csr", "library");
subst("cusparseZgebsr2csr", "rocsparse_zgebsr2csr", "library");
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 @@ -485,7 +485,7 @@
|`cusparseCcsric02_bufferSizeExt`| |12.2| |`hipsparseCcsric02_bufferSizeExt`|3.1.0| | | | | | | | |
|`cusparseCcsrilu0`| |10.2|11.0| | | | | | | | | | |
|`cusparseCcsrilu02`| |12.2| |`hipsparseCcsrilu02`|3.1.0| | | |`rocsparse_ccsrilu0`|2.10.0| | | |
|`cusparseCcsrilu02_analysis`| |12.2| |`hipsparseCcsrilu02_analysis`|3.1.0| | | | | | | | |
|`cusparseCcsrilu02_analysis`| |12.2| |`hipsparseCcsrilu02_analysis`|3.1.0| | | |`rocsparse_ccsrilu0_analysis`|2.10.0| | | |
|`cusparseCcsrilu02_bufferSize`| |12.2| |`hipsparseCcsrilu02_bufferSize`|3.1.0| | | | | | | | |
|`cusparseCcsrilu02_bufferSizeExt`| |12.2| |`hipsparseCcsrilu02_bufferSizeExt`|3.1.0| | | | | | | | |
|`cusparseCcsrilu02_numericBoost`| |12.2| |`hipsparseCcsrilu02_numericBoost`|3.10.0| | | | | | | | |
Expand Down Expand Up @@ -519,7 +519,7 @@
|`cusparseDcsric02_bufferSizeExt`| |12.2| |`hipsparseDcsric02_bufferSizeExt`|3.1.0| | | | | | | | |
|`cusparseDcsrilu0`| |10.2|11.0| | | | | | | | | | |
|`cusparseDcsrilu02`| |12.2| |`hipsparseDcsrilu02`|1.9.2| | | |`rocsparse_dcsrilu0`|1.9.0| | | |
|`cusparseDcsrilu02_analysis`| |12.2| |`hipsparseDcsrilu02_analysis`|1.9.2| | | | | | | | |
|`cusparseDcsrilu02_analysis`| |12.2| |`hipsparseDcsrilu02_analysis`|1.9.2| | | |`rocsparse_dcsrilu0_analysis`|1.9.0| | | |
|`cusparseDcsrilu02_bufferSize`| |12.2| |`hipsparseDcsrilu02_bufferSize`|1.9.2| | | | | | | | |
|`cusparseDcsrilu02_bufferSizeExt`| |12.2| |`hipsparseDcsrilu02_bufferSizeExt`|1.9.2| | | | | | | | |
|`cusparseDcsrilu02_numericBoost`| |12.2| |`hipsparseDcsrilu02_numericBoost`|3.10.0| | | | | | | | |
Expand Down Expand Up @@ -552,7 +552,7 @@
|`cusparseScsric02_bufferSizeExt`| |12.2| |`hipsparseScsric02_bufferSizeExt`|3.1.0| | | | | | | | |
|`cusparseScsrilu0`| |10.2|11.0| | | | | | | | | | |
|`cusparseScsrilu02`| |12.2| |`hipsparseScsrilu02`|1.9.2| | | |`rocsparse_scsrilu0`|1.9.0| | | |
|`cusparseScsrilu02_analysis`| |12.2| |`hipsparseScsrilu02_analysis`|1.9.2| | | | | | | | |
|`cusparseScsrilu02_analysis`| |12.2| |`hipsparseScsrilu02_analysis`|1.9.2| | | |`rocsparse_scsrilu0_analysis`|1.9.0| | | |
|`cusparseScsrilu02_bufferSize`| |12.2| |`hipsparseScsrilu02_bufferSize`|1.9.2| | | | | | | | |
|`cusparseScsrilu02_bufferSizeExt`| |12.2| |`hipsparseScsrilu02_bufferSizeExt`|1.9.2| | | | | | | | |
|`cusparseScsrilu02_numericBoost`| |12.2| |`hipsparseScsrilu02_numericBoost`|3.10.0| | | | | | | | |
Expand Down Expand Up @@ -589,7 +589,7 @@
|`cusparseZcsric02_bufferSizeExt`| |12.2| |`hipsparseZcsric02_bufferSizeExt`|3.1.0| | | | | | | | |
|`cusparseZcsrilu0`| |10.2|11.0| | | | | | | | | | |
|`cusparseZcsrilu02`| |12.2| |`hipsparseZcsrilu02`|3.1.0| | | |`rocsparse_zcsrilu0`|2.10.0| | | |
|`cusparseZcsrilu02_analysis`| |12.2| |`hipsparseZcsrilu02_analysis`|3.1.0| | | | | | | | |
|`cusparseZcsrilu02_analysis`| |12.2| |`hipsparseZcsrilu02_analysis`|3.1.0| | | |`rocsparse_zcsrilu0_analysis`|2.10.0| | | |
|`cusparseZcsrilu02_bufferSize`| |12.2| |`hipsparseZcsrilu02_bufferSize`|3.1.0| | | | | | | | |
|`cusparseZcsrilu02_bufferSizeExt`| |12.2| |`hipsparseZcsrilu02_bufferSizeExt`|3.1.0| | | | | | | | |
|`cusparseZcsrilu02_numericBoost`| |12.2| |`hipsparseZcsrilu02_numericBoost`|3.10.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 @@ -485,7 +485,7 @@
|`cusparseCcsric02_bufferSizeExt`| |12.2| | | | | | |
|`cusparseCcsrilu0`| |10.2|11.0| | | | | |
|`cusparseCcsrilu02`| |12.2| |`rocsparse_ccsrilu0`|2.10.0| | | |
|`cusparseCcsrilu02_analysis`| |12.2| | | | | | |
|`cusparseCcsrilu02_analysis`| |12.2| |`rocsparse_ccsrilu0_analysis`|2.10.0| | | |
|`cusparseCcsrilu02_bufferSize`| |12.2| | | | | | |
|`cusparseCcsrilu02_bufferSizeExt`| |12.2| | | | | | |
|`cusparseCcsrilu02_numericBoost`| |12.2| | | | | | |
Expand Down Expand Up @@ -519,7 +519,7 @@
|`cusparseDcsric02_bufferSizeExt`| |12.2| | | | | | |
|`cusparseDcsrilu0`| |10.2|11.0| | | | | |
|`cusparseDcsrilu02`| |12.2| |`rocsparse_dcsrilu0`|1.9.0| | | |
|`cusparseDcsrilu02_analysis`| |12.2| | | | | | |
|`cusparseDcsrilu02_analysis`| |12.2| |`rocsparse_dcsrilu0_analysis`|1.9.0| | | |
|`cusparseDcsrilu02_bufferSize`| |12.2| | | | | | |
|`cusparseDcsrilu02_bufferSizeExt`| |12.2| | | | | | |
|`cusparseDcsrilu02_numericBoost`| |12.2| | | | | | |
Expand Down Expand Up @@ -552,7 +552,7 @@
|`cusparseScsric02_bufferSizeExt`| |12.2| | | | | | |
|`cusparseScsrilu0`| |10.2|11.0| | | | | |
|`cusparseScsrilu02`| |12.2| |`rocsparse_scsrilu0`|1.9.0| | | |
|`cusparseScsrilu02_analysis`| |12.2| | | | | | |
|`cusparseScsrilu02_analysis`| |12.2| |`rocsparse_scsrilu0_analysis`|1.9.0| | | |
|`cusparseScsrilu02_bufferSize`| |12.2| | | | | | |
|`cusparseScsrilu02_bufferSizeExt`| |12.2| | | | | | |
|`cusparseScsrilu02_numericBoost`| |12.2| | | | | | |
Expand Down Expand Up @@ -589,7 +589,7 @@
|`cusparseZcsric02_bufferSizeExt`| |12.2| | | | | | |
|`cusparseZcsrilu0`| |10.2|11.0| | | | | |
|`cusparseZcsrilu02`| |12.2| |`rocsparse_zcsrilu0`|2.10.0| | | |
|`cusparseZcsrilu02_analysis`| |12.2| | | | | | |
|`cusparseZcsrilu02_analysis`| |12.2| |`rocsparse_zcsrilu0_analysis`|2.10.0| | | |
|`cusparseZcsrilu02_bufferSize`| |12.2| | | | | | |
|`cusparseZcsrilu02_bufferSizeExt`| |12.2| | | | | | |
|`cusparseZcsrilu02_numericBoost`| |12.2| | | | | | |
Expand Down
12 changes: 8 additions & 4 deletions src/CUDA2HIP_SPARSE_API_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,10 @@ const std::map<llvm::StringRef, hipCounter> CUDA_SPARSE_FUNCTION_MAP {
{"cusparseZcsrilu02_bufferSize", {"hipsparseZcsrilu02_bufferSize", "", CONV_LIB_FUNC, API_SPARSE, 12, ROC_UNSUPPORTED | CUDA_DEPRECATED}},
{"cusparseZcsrilu02_bufferSizeExt", {"hipsparseZcsrilu02_bufferSizeExt", "", CONV_LIB_FUNC, API_SPARSE, 12, ROC_UNSUPPORTED | CUDA_DEPRECATED}},

{"cusparseScsrilu02_analysis", {"hipsparseScsrilu02_analysis", "", CONV_LIB_FUNC, API_SPARSE, 12, ROC_UNSUPPORTED | CUDA_DEPRECATED}},
{"cusparseDcsrilu02_analysis", {"hipsparseDcsrilu02_analysis", "", CONV_LIB_FUNC, API_SPARSE, 12, ROC_UNSUPPORTED | CUDA_DEPRECATED}},
{"cusparseCcsrilu02_analysis", {"hipsparseCcsrilu02_analysis", "", CONV_LIB_FUNC, API_SPARSE, 12, ROC_UNSUPPORTED | CUDA_DEPRECATED}},
{"cusparseZcsrilu02_analysis", {"hipsparseZcsrilu02_analysis", "", CONV_LIB_FUNC, API_SPARSE, 12, ROC_UNSUPPORTED | CUDA_DEPRECATED}},
{"cusparseScsrilu02_analysis", {"hipsparseScsrilu02_analysis", "rocsparse_scsrilu0_analysis", CONV_LIB_FUNC, API_SPARSE, 12, CUDA_DEPRECATED}},
{"cusparseDcsrilu02_analysis", {"hipsparseDcsrilu02_analysis", "rocsparse_dcsrilu0_analysis", CONV_LIB_FUNC, API_SPARSE, 12, CUDA_DEPRECATED}},
{"cusparseCcsrilu02_analysis", {"hipsparseCcsrilu02_analysis", "rocsparse_ccsrilu0_analysis", CONV_LIB_FUNC, API_SPARSE, 12, CUDA_DEPRECATED}},
{"cusparseZcsrilu02_analysis", {"hipsparseZcsrilu02_analysis", "rocsparse_zcsrilu0_analysis", CONV_LIB_FUNC, API_SPARSE, 12, CUDA_DEPRECATED}},

{"cusparseScsrilu02", {"hipsparseScsrilu02", "rocsparse_scsrilu0", CONV_LIB_FUNC, API_SPARSE, 12, CUDA_DEPRECATED}},
{"cusparseDcsrilu02", {"hipsparseDcsrilu02", "rocsparse_dcsrilu0", CONV_LIB_FUNC, API_SPARSE, 12, CUDA_DEPRECATED}},
Expand Down Expand Up @@ -2179,6 +2179,10 @@ const std::map<llvm::StringRef, hipAPIversions> HIP_SPARSE_FUNCTION_VER_MAP {
{"rocsparse_ccsrilu0", {HIP_2100, HIP_0, HIP_0 }},
{"rocsparse_dcsrilu0", {HIP_1090, HIP_0, HIP_0 }},
{"rocsparse_scsrilu0", {HIP_1090, HIP_0, HIP_0 }},
{"rocsparse_zcsrilu0_analysis", {HIP_2100, HIP_0, HIP_0 }},
{"rocsparse_ccsrilu0_analysis", {HIP_2100, HIP_0, HIP_0 }},
{"rocsparse_dcsrilu0_analysis", {HIP_1090, HIP_0, HIP_0 }},
{"rocsparse_scsrilu0_analysis", {HIP_1090, HIP_0, HIP_0 }},
};

const std::map<unsigned int, llvm::StringRef> CUDA_SPARSE_API_SECTION_MAP {
Expand Down
50 changes: 49 additions & 1 deletion src/HipifyAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ const std::string sCusparseZcsrilu02 = "cusparseZcsrilu02";
const std::string sCusparseCcsrilu02 = "cusparseCcsrilu02";
const std::string sCusparseDcsrilu02 = "cusparseDcsrilu02";
const std::string sCusparseScsrilu02 = "cusparseScsrilu02";
const std::string sCusparseZcsrilu02_analysis = "cusparseZcsrilu02_analysis";
const std::string sCusparseCcsrilu02_analysis = "cusparseCcsrilu02_analysis";
const std::string sCusparseDcsrilu02_analysis = "cusparseDcsrilu02_analysis";
const std::string sCusparseScsrilu02_analysis = "cusparseScsrilu02_analysis";
// CUDA_OVERLOADED
const std::string sCudaEventCreate = "cudaEventCreate";
const std::string sCudaGraphInstantiate = "cudaGraphInstantiate";
Expand Down Expand Up @@ -583,6 +587,46 @@ std::map<std::string, ArgCastStruct> FuncArgCasts {
false
}
},
{sCusparseZcsrilu02_analysis,
{
{
{8, {e_replace_argument_with_const, cw_None, "rocsparse_analysis_policy_force"}},
{9, {e_add_const_argument, cw_None, "rocsparse_solve_policy_auto"}}
},
true,
false
}
},
{sCusparseCcsrilu02_analysis,
{
{
{8, {e_replace_argument_with_const, cw_None, "rocsparse_analysis_policy_force"}},
{9, {e_add_const_argument, cw_None, "rocsparse_solve_policy_auto"}}
},
true,
false
}
},
{sCusparseDcsrilu02_analysis,
{
{
{8, {e_replace_argument_with_const, cw_None, "rocsparse_analysis_policy_force"}},
{9, {e_add_const_argument, cw_None, "rocsparse_solve_policy_auto"}}
},
true,
false
}
},
{sCusparseScsrilu02_analysis,
{
{
{8, {e_replace_argument_with_const, cw_None, "rocsparse_analysis_policy_force"}},
{9, {e_add_const_argument, cw_None, "rocsparse_solve_policy_auto"}}
},
true,
false
}
},
};

void HipifyAction::RewriteString(StringRef s, clang::SourceLocation start) {
Expand Down Expand Up @@ -1312,7 +1356,11 @@ std::unique_ptr<clang::ASTConsumer> HipifyAction::CreateASTConsumer(clang::Compi
sCusparseZcsrilu02,
sCusparseCcsrilu02,
sCusparseDcsrilu02,
sCusparseScsrilu02
sCusparseScsrilu02,
sCusparseZcsrilu02_analysis,
sCusparseCcsrilu02_analysis,
sCusparseDcsrilu02_analysis,
sCusparseScsrilu02_analysis
)
)
)
Expand Down
20 changes: 20 additions & 0 deletions tests/unit_tests/synthetic/libraries/cusparse2hipsparse.cu
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,26 @@ int main() {
// CHECK: status_t = hipsparseScsrilu02(handle_t, m, innz, matDescr_A, &csrSortedValA, &csrRowPtrA, &csrColIndA, csrilu02_info, solvePolicy_t, pBuffer);
status_t = cusparseScsrilu02(handle_t, m, innz, matDescr_A, &csrSortedValA, &csrRowPtrA, &csrColIndA, csrilu02_info, solvePolicy_t, pBuffer);

// CUDA: CUSPARSE_DEPRECATED cusparseStatus_t CUSPARSEAPI cusparseZcsrilu02_analysis(cusparseHandle_t handle, int m, int nnz, const cusparseMatDescr_t descrA, const cuDoubleComplex* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, csrilu02Info_t info, cusparseSolvePolicy_t policy, void* pBuffer);
// HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseZcsrilu02_analysis(hipsparseHandle_t handle, int m, int nnz, const hipsparseMatDescr_t descrA, const hipDoubleComplex* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, csrilu02Info_t info, hipsparseSolvePolicy_t policy, void* pBuffer);
// CHECK: status_t = hipsparseZcsrilu02_analysis(handle_t, m, innz, matDescr_A, &dComplexcsrSortedValA, &csrRowPtrA, &csrColIndA, csrilu02_info, solvePolicy_t, pBuffer);
status_t = cusparseZcsrilu02_analysis(handle_t, m, innz, matDescr_A, &dComplexcsrSortedValA, &csrRowPtrA, &csrColIndA, csrilu02_info, solvePolicy_t, pBuffer);

// CUDA: CUSPARSE_DEPRECATED cusparseStatus_t CUSPARSEAPI cusparseCcsrilu02_analysis(cusparseHandle_t handle, int m, int nnz, const cusparseMatDescr_t descrA, const cuComplex* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, csrilu02Info_t info, cusparseSolvePolicy_t policy, void* pBuffer);
// HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseCcsrilu02_analysis(hipsparseHandle_t handle, int m, int nnz, const hipsparseMatDescr_t descrA, const hipComplex* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, csrilu02Info_t info, hipsparseSolvePolicy_t policy, void* pBuffer);
// CHECK: status_t = hipsparseCcsrilu02_analysis(handle_t, m, innz, matDescr_A, &complexcsrSortedValA, &csrRowPtrA, &csrColIndA, csrilu02_info, solvePolicy_t, pBuffer);
status_t = cusparseCcsrilu02_analysis(handle_t, m, innz, matDescr_A, &complexcsrSortedValA, &csrRowPtrA, &csrColIndA, csrilu02_info, solvePolicy_t, pBuffer);

// CUDA: CUSPARSE_DEPRECATED cusparseStatus_t CUSPARSEAPI cusparseDcsrilu02_analysis(cusparseHandle_t handle, int m, int nnz, const cusparseMatDescr_t descrA, const double* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, csrilu02Info_t info, cusparseSolvePolicy_t policy, void* pBuffer);
// HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseDcsrilu02_analysis(hipsparseHandle_t handle, int m, int nnz, const hipsparseMatDescr_t descrA, const double* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, csrilu02Info_t info, hipsparseSolvePolicy_t policy, void* pBuffer);
// CHECK: status_t = hipsparseDcsrilu02_analysis(handle_t, m, innz, matDescr_A, &dcsrSortedValA, &csrRowPtrA, &csrColIndA, csrilu02_info, solvePolicy_t, pBuffer);
status_t = cusparseDcsrilu02_analysis(handle_t, m, innz, matDescr_A, &dcsrSortedValA, &csrRowPtrA, &csrColIndA, csrilu02_info, solvePolicy_t, pBuffer);

// CUDA: CUSPARSE_DEPRECATED cusparseStatus_t CUSPARSEAPI cusparseScsrilu02_analysis(cusparseHandle_t handle, int m, int nnz, const cusparseMatDescr_t descrA, const float* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, csrilu02Info_t info, cusparseSolvePolicy_t policy, void* pBuffer);
// HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseScsrilu02_analysis(hipsparseHandle_t handle, int m, int nnz, const hipsparseMatDescr_t descrA, const float* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, csrilu02Info_t info, hipsparseSolvePolicy_t policy, void* pBuffer);
// CHECK: status_t = hipsparseScsrilu02_analysis(handle_t, m, innz, matDescr_A, &csrSortedValA, &csrRowPtrA, &csrColIndA, csrilu02_info, solvePolicy_t, pBuffer);
status_t = cusparseScsrilu02_analysis(handle_t, m, innz, matDescr_A, &csrSortedValA, &csrRowPtrA, &csrColIndA, csrilu02_info, solvePolicy_t, pBuffer);

#if CUDA_VERSION >= 8000
// CHECK: hipDataType dataType_t;
// CHECK-NEXT: hipDataType dataType;
Expand Down
Loading

0 comments on commit 31e51d6

Please sign in to comment.