Skip to content

Commit

Permalink
[HIPIFY][ROCm#674][rocSPARSE][feature] rocSPARSE support - Step 34 - …
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 Aug 30, 2023
1 parent 6afbe6b commit 5fc03fd
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 @@ -1691,6 +1691,7 @@ sub rocSubstitutions {
subst("cusparseCgebsr2gebsr_bufferSize", "rocsparse_cgebsr2gebsr_buffer_size", "library");
subst("cusparseCgpsvInterleavedBatch", "rocsparse_cgpsv_interleaved_batch", "library");
subst("cusparseCgpsvInterleavedBatch_bufferSizeExt", "rocsparse_cgpsv_interleaved_batch_buffer_size", "library");
subst("cusparseCgtsvInterleavedBatch", "rocsparse_cgtsv_interleaved_batch", "library");
subst("cusparseCnnz", "rocsparse_cnnz", "library");
subst("cusparseCnnz_compress", "rocsparse_cnnz_compress", "library");
subst("cusparseCooAoSGet", "rocsparse_coo_aos_get", "library");
Expand Down Expand Up @@ -1741,6 +1742,7 @@ sub rocSubstitutions {
subst("cusparseDgebsr2gebsr_bufferSize", "rocsparse_dgebsr2gebsr_buffer_size", "library");
subst("cusparseDgpsvInterleavedBatch", "rocsparse_dgpsv_interleaved_batch", "library");
subst("cusparseDgpsvInterleavedBatch_bufferSizeExt", "rocsparse_dgpsv_interleaved_batch_buffer_size", "library");
subst("cusparseDgtsvInterleavedBatch", "rocsparse_dgtsv_interleaved_batch", "library");
subst("cusparseDnMatGet", "rocsparse_dnmat_get", "library");
subst("cusparseDnMatGetStridedBatch", "rocsparse_dnmat_get_strided_batch", "library");
subst("cusparseDnMatGetValues", "rocsparse_dnmat_get_values", "library");
Expand Down Expand Up @@ -1800,6 +1802,7 @@ sub rocSubstitutions {
subst("cusparseSgebsr2gebsr_bufferSize", "rocsparse_sgebsr2gebsr_buffer_size", "library");
subst("cusparseSgpsvInterleavedBatch", "rocsparse_sgpsv_interleaved_batch", "library");
subst("cusparseSgpsvInterleavedBatch_bufferSizeExt", "rocsparse_sgpsv_interleaved_batch_buffer_size", "library");
subst("cusparseSgtsvInterleavedBatch", "rocsparse_sgtsv_interleaved_batch", "library");
subst("cusparseSnnz", "rocsparse_snnz", "library");
subst("cusparseSnnz_compress", "rocsparse_snnz_compress", "library");
subst("cusparseSpMV", "rocsparse_spmv", "library");
Expand Down Expand Up @@ -1858,6 +1861,7 @@ sub rocSubstitutions {
subst("cusparseZgebsr2gebsr_bufferSize", "rocsparse_zgebsr2gebsr_buffer_size", "library");
subst("cusparseZgpsvInterleavedBatch", "rocsparse_zgpsv_interleaved_batch", "library");
subst("cusparseZgpsvInterleavedBatch_bufferSizeExt", "rocsparse_zgpsv_interleaved_batch_buffer_size", "library");
subst("cusparseZgtsvInterleavedBatch", "rocsparse_zgtsv_interleaved_batch", "library");
subst("cusparseZnnz", "rocsparse_znnz", "library");
subst("cusparseZnnz_compress", "rocsparse_znnz_compress", "library");
subst("cublas.h", "rocblas.h", "include_cuda_main_header");
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 @@ -498,7 +498,7 @@
|`cusparseCgtsv2_bufferSizeExt`|9.0| | |`hipsparseCgtsv2_bufferSizeExt`|4.3.0| | | | | | | | |
|`cusparseCgtsv2_nopivot`|9.0| | |`hipsparseCgtsv2_nopivot`|4.3.0| | | | | | | | |
|`cusparseCgtsv2_nopivot_bufferSizeExt`|9.0| | |`hipsparseCgtsv2_nopivot_bufferSizeExt`|4.3.0| | | | | | | | |
|`cusparseCgtsvInterleavedBatch`|9.2| | |`hipsparseCgtsvInterleavedBatch`|5.1.0| | | | | | | | |
|`cusparseCgtsvInterleavedBatch`|9.2| | |`hipsparseCgtsvInterleavedBatch`|5.1.0| | | |`rocsparse_cgtsv_interleaved_batch`|5.1.0| | | |
|`cusparseCgtsvInterleavedBatch_bufferSizeExt`|9.2| | |`hipsparseCgtsvInterleavedBatch_bufferSizeExt`|5.1.0| | | | | | | | |
|`cusparseCgtsvStridedBatch`| |10.2|11.0| | | | | | | | | | |
|`cusparseCgtsv_nopivot`| |10.2|11.0| | | | | | | | | | |
Expand Down Expand Up @@ -532,7 +532,7 @@
|`cusparseDgtsv2_bufferSizeExt`|9.0| | |`hipsparseDgtsv2_bufferSizeExt`|4.3.0| | | | | | | | |
|`cusparseDgtsv2_nopivot`|9.0| | |`hipsparseDgtsv2_nopivot`|4.3.0| | | | | | | | |
|`cusparseDgtsv2_nopivot_bufferSizeExt`|9.0| | |`hipsparseDgtsv2_nopivot_bufferSizeExt`|4.3.0| | | | | | | | |
|`cusparseDgtsvInterleavedBatch`|9.2| | |`hipsparseDgtsvInterleavedBatch`|5.1.0| | | | | | | | |
|`cusparseDgtsvInterleavedBatch`|9.2| | |`hipsparseDgtsvInterleavedBatch`|5.1.0| | | |`rocsparse_dgtsv_interleaved_batch`|5.1.0| | | |
|`cusparseDgtsvInterleavedBatch_bufferSizeExt`|9.2| | |`hipsparseDgtsvInterleavedBatch_bufferSizeExt`|5.1.0| | | | | | | | |
|`cusparseDgtsvStridedBatch`| |10.2|11.0| | | | | | | | | | |
|`cusparseDgtsv_nopivot`| |10.2|11.0| | | | | | | | | | |
Expand Down Expand Up @@ -565,7 +565,7 @@
|`cusparseSgtsv2_bufferSizeExt`|9.0| | |`hipsparseSgtsv2_bufferSizeExt`|4.3.0| | | | | | | | |
|`cusparseSgtsv2_nopivot`|9.0| | |`hipsparseSgtsv2_nopivot`|4.3.0| | | | | | | | |
|`cusparseSgtsv2_nopivot_bufferSizeExt`|9.0| | |`hipsparseSgtsv2_nopivot_bufferSizeExt`|4.3.0| | | | | | | | |
|`cusparseSgtsvInterleavedBatch`|9.2| | |`hipsparseSgtsvInterleavedBatch`|5.1.0| | | | | | | | |
|`cusparseSgtsvInterleavedBatch`|9.2| | |`hipsparseSgtsvInterleavedBatch`|5.1.0| | | |`rocsparse_sgtsv_interleaved_batch`|5.1.0| | | |
|`cusparseSgtsvInterleavedBatch_bufferSizeExt`|9.2| | |`hipsparseSgtsvInterleavedBatch_bufferSizeExt`|5.1.0| | | | | | | | |
|`cusparseSgtsvStridedBatch`| |10.2|11.0| | | | | | | | | | |
|`cusparseSgtsv_nopivot`| |10.2|11.0| | | | | | | | | | |
Expand Down Expand Up @@ -602,7 +602,7 @@
|`cusparseZgtsv2_bufferSizeExt`|9.0| | |`hipsparseZgtsv2_bufferSizeExt`|4.3.0| | | | | | | | |
|`cusparseZgtsv2_nopivot`|9.0| | |`hipsparseZgtsv2_nopivot`|4.3.0| | | | | | | | |
|`cusparseZgtsv2_nopivot_bufferSizeExt`|9.0| | |`hipsparseZgtsv2_nopivot_bufferSizeExt`|4.3.0| | | | | | | | |
|`cusparseZgtsvInterleavedBatch`|9.2| | |`hipsparseZgtsvInterleavedBatch`|5.1.0| | | | | | | | |
|`cusparseZgtsvInterleavedBatch`|9.2| | |`hipsparseZgtsvInterleavedBatch`|5.1.0| | | |`rocsparse_zgtsv_interleaved_batch`|5.1.0| | | |
|`cusparseZgtsvInterleavedBatch_bufferSizeExt`|9.2| | |`hipsparseZgtsvInterleavedBatch_bufferSizeExt`|5.1.0| | | | | | | | |
|`cusparseZgtsvStridedBatch`| |10.2|11.0| | | | | | | | | | |
|`cusparseZgtsv_nopivot`| |10.2|11.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 @@ -498,7 +498,7 @@
|`cusparseCgtsv2_bufferSizeExt`|9.0| | | | | | | |
|`cusparseCgtsv2_nopivot`|9.0| | | | | | | |
|`cusparseCgtsv2_nopivot_bufferSizeExt`|9.0| | | | | | | |
|`cusparseCgtsvInterleavedBatch`|9.2| | | | | | | |
|`cusparseCgtsvInterleavedBatch`|9.2| | |`rocsparse_cgtsv_interleaved_batch`|5.1.0| | | |
|`cusparseCgtsvInterleavedBatch_bufferSizeExt`|9.2| | | | | | | |
|`cusparseCgtsvStridedBatch`| |10.2|11.0| | | | | |
|`cusparseCgtsv_nopivot`| |10.2|11.0| | | | | |
Expand Down Expand Up @@ -532,7 +532,7 @@
|`cusparseDgtsv2_bufferSizeExt`|9.0| | | | | | | |
|`cusparseDgtsv2_nopivot`|9.0| | | | | | | |
|`cusparseDgtsv2_nopivot_bufferSizeExt`|9.0| | | | | | | |
|`cusparseDgtsvInterleavedBatch`|9.2| | | | | | | |
|`cusparseDgtsvInterleavedBatch`|9.2| | |`rocsparse_dgtsv_interleaved_batch`|5.1.0| | | |
|`cusparseDgtsvInterleavedBatch_bufferSizeExt`|9.2| | | | | | | |
|`cusparseDgtsvStridedBatch`| |10.2|11.0| | | | | |
|`cusparseDgtsv_nopivot`| |10.2|11.0| | | | | |
Expand Down Expand Up @@ -565,7 +565,7 @@
|`cusparseSgtsv2_bufferSizeExt`|9.0| | | | | | | |
|`cusparseSgtsv2_nopivot`|9.0| | | | | | | |
|`cusparseSgtsv2_nopivot_bufferSizeExt`|9.0| | | | | | | |
|`cusparseSgtsvInterleavedBatch`|9.2| | | | | | | |
|`cusparseSgtsvInterleavedBatch`|9.2| | |`rocsparse_sgtsv_interleaved_batch`|5.1.0| | | |
|`cusparseSgtsvInterleavedBatch_bufferSizeExt`|9.2| | | | | | | |
|`cusparseSgtsvStridedBatch`| |10.2|11.0| | | | | |
|`cusparseSgtsv_nopivot`| |10.2|11.0| | | | | |
Expand Down Expand Up @@ -602,7 +602,7 @@
|`cusparseZgtsv2_bufferSizeExt`|9.0| | | | | | | |
|`cusparseZgtsv2_nopivot`|9.0| | | | | | | |
|`cusparseZgtsv2_nopivot_bufferSizeExt`|9.0| | | | | | | |
|`cusparseZgtsvInterleavedBatch`|9.2| | | | | | | |
|`cusparseZgtsvInterleavedBatch`|9.2| | |`rocsparse_zgtsv_interleaved_batch`|5.1.0| | | |
|`cusparseZgtsvInterleavedBatch_bufferSizeExt`|9.2| | | | | | | |
|`cusparseZgtsvStridedBatch`| |10.2|11.0| | | | | |
|`cusparseZgtsv_nopivot`| |10.2|11.0| | | | | |
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 @@ -476,10 +476,10 @@ const std::map<llvm::StringRef, hipCounter> CUDA_SPARSE_FUNCTION_MAP {
{"cusparseCgtsvInterleavedBatch_bufferSizeExt", {"hipsparseCgtsvInterleavedBatch_bufferSizeExt", "", CONV_LIB_FUNC, API_SPARSE, 12, ROC_UNSUPPORTED}},
{"cusparseZgtsvInterleavedBatch_bufferSizeExt", {"hipsparseZgtsvInterleavedBatch_bufferSizeExt", "", CONV_LIB_FUNC, API_SPARSE, 12, ROC_UNSUPPORTED}},

{"cusparseSgtsvInterleavedBatch", {"hipsparseSgtsvInterleavedBatch", "", CONV_LIB_FUNC, API_SPARSE, 12, ROC_UNSUPPORTED}},
{"cusparseDgtsvInterleavedBatch", {"hipsparseDgtsvInterleavedBatch", "", CONV_LIB_FUNC, API_SPARSE, 12, ROC_UNSUPPORTED}},
{"cusparseCgtsvInterleavedBatch", {"hipsparseCgtsvInterleavedBatch", "", CONV_LIB_FUNC, API_SPARSE, 12, ROC_UNSUPPORTED}},
{"cusparseZgtsvInterleavedBatch", {"hipsparseZgtsvInterleavedBatch", "", CONV_LIB_FUNC, API_SPARSE, 12, ROC_UNSUPPORTED}},
{"cusparseSgtsvInterleavedBatch", {"hipsparseSgtsvInterleavedBatch", "rocsparse_sgtsv_interleaved_batch", CONV_LIB_FUNC, API_SPARSE, 12}},
{"cusparseDgtsvInterleavedBatch", {"hipsparseDgtsvInterleavedBatch", "rocsparse_dgtsv_interleaved_batch", CONV_LIB_FUNC, API_SPARSE, 12}},
{"cusparseCgtsvInterleavedBatch", {"hipsparseCgtsvInterleavedBatch", "rocsparse_cgtsv_interleaved_batch", CONV_LIB_FUNC, API_SPARSE, 12}},
{"cusparseZgtsvInterleavedBatch", {"hipsparseZgtsvInterleavedBatch", "rocsparse_zgtsv_interleaved_batch", CONV_LIB_FUNC, API_SPARSE, 12}},

// 12.5. Batched Pentadiagonal Solve
{"cusparseSgpsvInterleavedBatch_bufferSizeExt", {"hipsparseSgpsvInterleavedBatch_bufferSizeExt", "rocsparse_sgpsv_interleaved_batch_buffer_size", CONV_LIB_FUNC, API_SPARSE, 12}},
Expand Down Expand Up @@ -2143,6 +2143,10 @@ const std::map<llvm::StringRef, hipAPIversions> HIP_SPARSE_FUNCTION_VER_MAP {
{"rocsparse_cgpsv_interleaved_batch_buffer_size", {HIP_5010, HIP_0, HIP_0 }},
{"rocsparse_dgpsv_interleaved_batch_buffer_size", {HIP_5010, HIP_0, HIP_0 }},
{"rocsparse_sgpsv_interleaved_batch_buffer_size", {HIP_5010, HIP_0, HIP_0 }},
{"rocsparse_zgtsv_interleaved_batch", {HIP_5010, HIP_0, HIP_0 }},
{"rocsparse_cgtsv_interleaved_batch", {HIP_5010, HIP_0, HIP_0 }},
{"rocsparse_dgtsv_interleaved_batch", {HIP_5010, HIP_0, HIP_0 }},
{"rocsparse_sgtsv_interleaved_batch", {HIP_5010, HIP_0, HIP_0 }},
};

const std::map<unsigned int, llvm::StringRef> CUDA_SPARSE_API_SECTION_MAP {
Expand Down
46 changes: 45 additions & 1 deletion src/HipifyAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ const std::string sCusparseZgpsvInterleavedBatch_bufferSizeExt = "cusparseZgpsvI
const std::string sCusparseCgpsvInterleavedBatch_bufferSizeExt = "cusparseCgpsvInterleavedBatch_bufferSizeExt";
const std::string sCusparseDgpsvInterleavedBatch_bufferSizeExt = "cusparseDgpsvInterleavedBatch_bufferSizeExt";
const std::string sCusparseSgpsvInterleavedBatch_bufferSizeExt = "cusparseSgpsvInterleavedBatch_bufferSizeExt";
const std::string sCusparseZgtsvInterleavedBatch = "cusparseZgtsvInterleavedBatch";
const std::string sCusparseCgtsvInterleavedBatch = "cusparseCgtsvInterleavedBatch";
const std::string sCusparseDgtsvInterleavedBatch = "cusparseDgtsvInterleavedBatch";
const std::string sCusparseSgtsvInterleavedBatch = "cusparseSgtsvInterleavedBatch";
// CUDA_OVERLOADED
const std::string sCudaEventCreate = "cudaEventCreate";
const std::string sCudaGraphInstantiate = "cudaGraphInstantiate";
Expand Down Expand Up @@ -462,6 +466,42 @@ std::map<std::string, ArgCastStruct> FuncArgCasts {
false
}
},
{sCusparseZgtsvInterleavedBatch,
{
{
{7, {e_add_var_argument, cw_None, "", 8}}
},
true,
false
}
},
{sCusparseCgtsvInterleavedBatch,
{
{
{7, {e_add_var_argument, cw_None, "", 8}}
},
true,
false
}
},
{sCusparseDgtsvInterleavedBatch,
{
{
{7, {e_add_var_argument, cw_None, "", 8}}
},
true,
false
}
},
{sCusparseSgtsvInterleavedBatch,
{
{
{7, {e_add_var_argument, cw_None, "", 8}}
},
true,
false
}
},
};

void HipifyAction::RewriteString(StringRef s, clang::SourceLocation start) {
Expand Down Expand Up @@ -1171,7 +1211,11 @@ std::unique_ptr<clang::ASTConsumer> HipifyAction::CreateASTConsumer(clang::Compi
sCusparseZgpsvInterleavedBatch_bufferSizeExt,
sCusparseCgpsvInterleavedBatch_bufferSizeExt,
sCusparseDgpsvInterleavedBatch_bufferSizeExt,
sCusparseSgpsvInterleavedBatch_bufferSizeExt
sCusparseSgpsvInterleavedBatch_bufferSizeExt,
sCusparseZgtsvInterleavedBatch,
sCusparseCgtsvInterleavedBatch,
sCusparseDgtsvInterleavedBatch,
sCusparseSgtsvInterleavedBatch
)
)
)
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 @@ -850,6 +850,26 @@ int main() {
// HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseSgpsvInterleavedBatch_bufferSizeExt(hipsparseHandle_t handle, int algo, int m, const float* ds, const float* dl, const float* d, const float* du, const float* dw, const float* x, int batchCount, size_t* pBufferSizeInBytes);
// CHECK: status_t = hipsparseSgpsvInterleavedBatch_bufferSizeExt(handle_t, algo, m, &fds, &fdl, &fd, &fdu, &fdw, &fx, batchCount, &bufferSize);
status_t = cusparseSgpsvInterleavedBatch_bufferSizeExt(handle_t, algo, m, &fds, &fdl, &fd, &fdu, &fdw, &fx, batchCount, &bufferSize);

// CUDA: cusparseStatus_t CUSPARSEAPI cusparseZgtsvInterleavedBatch(cusparseHandle_t handle, int algo, int m, cuDoubleComplex* dl, cuDoubleComplex* d, cuDoubleComplex* du, cuDoubleComplex* x, int batchCount, void* pBuffer);
// HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseZgtsvInterleavedBatch(hipsparseHandle_t handle, int algo, int m, hipDoubleComplex* dl, hipDoubleComplex* d, hipDoubleComplex* du, hipDoubleComplex* x, int batchCount, void* pBuffer);
// CHECK: status_t = hipsparseZgtsvInterleavedBatch(handle_t, algo, m, &dcomplexdl, &dcomplexd, &dcomplexdu, &dcomplexx, batchCount, pBuffer);
status_t = cusparseZgtsvInterleavedBatch(handle_t, algo, m, &dcomplexdl, &dcomplexd, &dcomplexdu, &dcomplexx, batchCount, pBuffer);

// CUDA: cusparseStatus_t CUSPARSEAPI cusparseCgtsvInterleavedBatch(cusparseHandle_t handle, int algo, int m, cuComplex* dl, cuComplex* d, cuComplex* du, cuComplex* x, int batchCount, void* pBuffer);
// HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseCgtsvInterleavedBatch(hipsparseHandle_t handle, int algo, int m, hipComplex* dl, hipComplex* d, hipComplex* du, hipComplex* x, int batchCount, void* pBuffer);
// CHECK: status_t = hipsparseCgtsvInterleavedBatch(handle_t, algo, m, &complexdl, &complexd, &complexdu, &complexx, batchCount, pBuffer);
status_t = cusparseCgtsvInterleavedBatch(handle_t, algo, m, &complexdl, &complexd, &complexdu, &complexx, batchCount, pBuffer);

// CUDA: cusparseStatus_t CUSPARSEAPI cusparseDgtsvInterleavedBatch(cusparseHandle_t handle, int algo, int m, double* dl, double* d, double* du, double* x, int batchCount, void* pBuffer);
// HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseDgtsvInterleavedBatch(hipsparseHandle_t handle, int algo, int m, double* dl, double* d, double* du, double* x, int batchCount, void* pBuffer);
// CHECK: status_t = hipsparseDgtsvInterleavedBatch(handle_t, algo, m, &ddl, &dd, &ddu, &dx, batchCount, pBuffer);
status_t = cusparseDgtsvInterleavedBatch(handle_t, algo, m, &ddl, &dd, &ddu, &dx, batchCount, pBuffer);

// CUDA: cusparseStatus_t CUSPARSEAPI cusparseSgtsvInterleavedBatch(cusparseHandle_t handle, int algo, int m, float* dl, float* d, float* du, float* x, int batchCount, void* pBuffer);
// HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseSgtsvInterleavedBatch(hipsparseHandle_t handle, int algo, int m, float* dl, float* d, float* du, float* x, int batchCount, void* pBuffer);
// CHECK: status_t = hipsparseSgtsvInterleavedBatch(handle_t, algo, m, &fdl, &fd, &fdu, &fx, batchCount, pBuffer);
status_t = cusparseSgtsvInterleavedBatch(handle_t, algo, m, &fdl, &fd, &fdu, &fx, batchCount, pBuffer);
#endif

#if CUDA_VERSION >= 10010
Expand Down
Loading

0 comments on commit 5fc03fd

Please sign in to comment.