From 6e0f33444a6305726f5d795b379c8e8f02c8af57 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Sat, 6 Jan 2024 19:25:16 +0000 Subject: [PATCH] [HIPIFY][#674][rocSPARSE][feature] rocSPARSE support - Step 91 - functions `rocsparse_(s|d|c|z)csrgeam` + Created a synthetic test `cusparse2rocsparse_10000.cu` for rocSPARSE APIs with args transformations, which are used in CUDA >= 10.0 (FileCheck tool limitation) + Updated `SPARSE` synthetic tests, the regenerated hipify-perl, and `SPARSE` `CUDA2HIP` documentation + [TODO] Fix the bug with the deletion of the last argument (`e_remove_argument`), which leads to an app crash in `cusparse2rocsparse_10000.cu` --- bin/hipify-perl | 4 + .../CUSPARSE_API_supported_by_HIP_and_ROC.md | 8 +- docs/tables/CUSPARSE_API_supported_by_ROC.md | 8 +- src/CUDA2HIP_SPARSE_API_functions.cpp | 8 +- src/HipifyAction.cpp | 46 +++++++++- tests/lit.cfg | 1 + .../synthetic/libraries/cusparse2hipsparse.cu | 22 +++++ .../libraries/cusparse2rocsparse_10000.cu | 92 +++++++++++++++++++ 8 files changed, 176 insertions(+), 13 deletions(-) create mode 100644 tests/unit_tests/synthetic/libraries/cusparse2rocsparse_10000.cu diff --git a/bin/hipify-perl b/bin/hipify-perl index 523eafc6..71bdd78e 100755 --- a/bin/hipify-perl +++ b/bin/hipify-perl @@ -2283,6 +2283,7 @@ sub rocSubstitutions { subst("cusparseCcsr2hyb", "rocsparse_ccsr2hyb", "library"); subst("cusparseCcsrcolor", "rocsparse_ccsrcolor", "library"); subst("cusparseCcsrgeam", "rocsparse_ccsrgeam", "library"); + subst("cusparseCcsrgeam2", "rocsparse_ccsrgeam", "library"); subst("cusparseCcsrgemm2_bufferSizeExt", "rocsparse_ccsrgemm_buffer_size", "library"); subst("cusparseCcsric02", "rocsparse_ccsric0", "library"); subst("cusparseCcsric02_analysis", "rocsparse_ccsric0_analysis", "library"); @@ -2404,6 +2405,7 @@ sub rocSubstitutions { subst("cusparseDcsr2hyb", "rocsparse_dcsr2hyb", "library"); subst("cusparseDcsrcolor", "rocsparse_dcsrcolor", "library"); subst("cusparseDcsrgeam", "rocsparse_dcsrgeam", "library"); + subst("cusparseDcsrgeam2", "rocsparse_dcsrgeam", "library"); subst("cusparseDcsrgemm2_bufferSizeExt", "rocsparse_dcsrgemm_buffer_size", "library"); subst("cusparseDcsric02", "rocsparse_dcsric0", "library"); subst("cusparseDcsric02_analysis", "rocsparse_dcsric0_analysis", "library"); @@ -2528,6 +2530,7 @@ sub rocSubstitutions { subst("cusparseScsr2hyb", "rocsparse_scsr2hyb", "library"); subst("cusparseScsrcolor", "rocsparse_scsrcolor", "library"); subst("cusparseScsrgeam", "rocsparse_scsrgeam", "library"); + subst("cusparseScsrgeam2", "rocsparse_scsrgeam", "library"); subst("cusparseScsrgemm2_bufferSizeExt", "rocsparse_scsrgemm_buffer_size", "library"); subst("cusparseScsric02", "rocsparse_scsric0", "library"); subst("cusparseScsric02_analysis", "rocsparse_scsric0_analysis", "library"); @@ -2653,6 +2656,7 @@ sub rocSubstitutions { subst("cusparseZcsr2hyb", "rocsparse_zcsr2hyb", "library"); subst("cusparseZcsrcolor", "rocsparse_zcsrcolor", "library"); subst("cusparseZcsrgeam", "rocsparse_zcsrgeam", "library"); + subst("cusparseZcsrgeam2", "rocsparse_zcsrgeam", "library"); subst("cusparseZcsrgemm2_bufferSizeExt", "rocsparse_zcsrgemm_buffer_size", "library"); subst("cusparseZcsric02", "rocsparse_zcsric0", "library"); subst("cusparseZcsric02_analysis", "rocsparse_zcsric0_analysis", "library"); diff --git a/docs/tables/CUSPARSE_API_supported_by_HIP_and_ROC.md b/docs/tables/CUSPARSE_API_supported_by_HIP_and_ROC.md index 88401f1d..bb61970b 100644 --- a/docs/tables/CUSPARSE_API_supported_by_HIP_and_ROC.md +++ b/docs/tables/CUSPARSE_API_supported_by_HIP_and_ROC.md @@ -439,19 +439,19 @@ |**CUDA**|**A**|**D**|**C**|**R**|**HIP**|**A**|**D**|**C**|**R**|**E**|**ROC**|**A**|**D**|**C**|**R**|**E**| |:--|:-:|:-:|:-:|:-:|:--|:-:|:-:|:-:|:-:|:-:|:--|:-:|:-:|:-:|:-:|:-:| |`cusparseCcsrgeam`| |10.2| |11.0|`hipsparseCcsrgeam`|3.5.0| | | | |`rocsparse_ccsrgeam`|3.5.0| | | | | -|`cusparseCcsrgeam2`|10.0| | | |`hipsparseCcsrgeam2`|3.5.0| | | | | | | | | | | +|`cusparseCcsrgeam2`|10.0| | | |`hipsparseCcsrgeam2`|3.5.0| | | | |`rocsparse_ccsrgeam`|3.5.0| | | | | |`cusparseCcsrgeam2_bufferSizeExt`|10.0| | | |`hipsparseCcsrgeam2_bufferSizeExt`|3.5.0| | | | | | | | | | | |`cusparseCcsrgemm`| |10.2| |11.0|`hipsparseCcsrgemm`|3.1.0| | | | | | | | | | | |`cusparseCcsrgemm2`| |11.0| |12.0|`hipsparseCcsrgemm2`|3.1.0| | | | | | | | | | | |`cusparseCcsrgemm2_bufferSizeExt`| |11.0| |12.0|`hipsparseCcsrgemm2_bufferSizeExt`|3.1.0| | | | |`rocsparse_ccsrgemm_buffer_size`|2.8.0| | | | | |`cusparseDcsrgeam`| |10.2| |11.0|`hipsparseDcsrgeam`|3.5.0| | | | |`rocsparse_dcsrgeam`|3.5.0| | | | | -|`cusparseDcsrgeam2`|10.0| | | |`hipsparseDcsrgeam2`|3.5.0| | | | | | | | | | | +|`cusparseDcsrgeam2`|10.0| | | |`hipsparseDcsrgeam2`|3.5.0| | | | |`rocsparse_dcsrgeam`|3.5.0| | | | | |`cusparseDcsrgeam2_bufferSizeExt`|10.0| | | |`hipsparseDcsrgeam2_bufferSizeExt`|3.5.0| | | | | | | | | | | |`cusparseDcsrgemm`| |10.2| |11.0|`hipsparseDcsrgemm`|2.8.0| | | | | | | | | | | |`cusparseDcsrgemm2`| |11.0| |12.0|`hipsparseDcsrgemm2`|2.8.0| | | | | | | | | | | |`cusparseDcsrgemm2_bufferSizeExt`| |11.0| |12.0|`hipsparseDcsrgemm2_bufferSizeExt`|2.8.0| | | | |`rocsparse_dcsrgemm_buffer_size`|2.8.0| | | | | |`cusparseScsrgeam`| |10.2| |11.0|`hipsparseScsrgeam`|3.5.0| | | | |`rocsparse_scsrgeam`|3.5.0| | | | | -|`cusparseScsrgeam2`|10.0| | | |`hipsparseScsrgeam2`|3.5.0| | | | | | | | | | | +|`cusparseScsrgeam2`|10.0| | | |`hipsparseScsrgeam2`|3.5.0| | | | |`rocsparse_scsrgeam`|3.5.0| | | | | |`cusparseScsrgeam2_bufferSizeExt`|10.0| | | |`hipsparseScsrgeam2_bufferSizeExt`|3.5.0| | | | | | | | | | | |`cusparseScsrgemm`| |10.2| |11.0|`hipsparseScsrgemm`|2.8.0| | | | | | | | | | | |`cusparseScsrgemm2`| |11.0| |12.0|`hipsparseScsrgemm2`|2.8.0| | | | | | | | | | | @@ -461,7 +461,7 @@ |`cusparseXcsrgemm2Nnz`| |11.0| |12.0|`hipsparseXcsrgemm2Nnz`|2.8.0| | | | |`rocsparse_csrgemm_nnz`|2.8.0| | | | | |`cusparseXcsrgemmNnz`| |10.2| |11.0|`hipsparseXcsrgemmNnz`|2.8.0| | | | | | | | | | | |`cusparseZcsrgeam`| |10.2| |11.0|`hipsparseZcsrgeam`|3.5.0| | | | |`rocsparse_zcsrgeam`|3.5.0| | | | | -|`cusparseZcsrgeam2`|10.0| | | |`hipsparseZcsrgeam2`|3.5.0| | | | | | | | | | | +|`cusparseZcsrgeam2`|10.0| | | |`hipsparseZcsrgeam2`|3.5.0| | | | |`rocsparse_zcsrgeam`|3.5.0| | | | | |`cusparseZcsrgeam2_bufferSizeExt`|10.0| | | |`hipsparseZcsrgeam2_bufferSizeExt`|3.5.0| | | | | | | | | | | |`cusparseZcsrgemm`| |10.2| |11.0|`hipsparseZcsrgemm`|3.1.0| | | | | | | | | | | |`cusparseZcsrgemm2`| |11.0| |12.0|`hipsparseZcsrgemm2`|3.1.0| | | | | | | | | | | diff --git a/docs/tables/CUSPARSE_API_supported_by_ROC.md b/docs/tables/CUSPARSE_API_supported_by_ROC.md index 4c156ce9..734047a2 100644 --- a/docs/tables/CUSPARSE_API_supported_by_ROC.md +++ b/docs/tables/CUSPARSE_API_supported_by_ROC.md @@ -439,19 +439,19 @@ |**CUDA**|**A**|**D**|**C**|**R**|**ROC**|**A**|**D**|**C**|**R**|**E**| |:--|:-:|:-:|:-:|:-:|:--|:-:|:-:|:-:|:-:|:-:| |`cusparseCcsrgeam`| |10.2| |11.0|`rocsparse_ccsrgeam`|3.5.0| | | | | -|`cusparseCcsrgeam2`|10.0| | | | | | | | | | +|`cusparseCcsrgeam2`|10.0| | | |`rocsparse_ccsrgeam`|3.5.0| | | | | |`cusparseCcsrgeam2_bufferSizeExt`|10.0| | | | | | | | | | |`cusparseCcsrgemm`| |10.2| |11.0| | | | | | | |`cusparseCcsrgemm2`| |11.0| |12.0| | | | | | | |`cusparseCcsrgemm2_bufferSizeExt`| |11.0| |12.0|`rocsparse_ccsrgemm_buffer_size`|2.8.0| | | | | |`cusparseDcsrgeam`| |10.2| |11.0|`rocsparse_dcsrgeam`|3.5.0| | | | | -|`cusparseDcsrgeam2`|10.0| | | | | | | | | | +|`cusparseDcsrgeam2`|10.0| | | |`rocsparse_dcsrgeam`|3.5.0| | | | | |`cusparseDcsrgeam2_bufferSizeExt`|10.0| | | | | | | | | | |`cusparseDcsrgemm`| |10.2| |11.0| | | | | | | |`cusparseDcsrgemm2`| |11.0| |12.0| | | | | | | |`cusparseDcsrgemm2_bufferSizeExt`| |11.0| |12.0|`rocsparse_dcsrgemm_buffer_size`|2.8.0| | | | | |`cusparseScsrgeam`| |10.2| |11.0|`rocsparse_scsrgeam`|3.5.0| | | | | -|`cusparseScsrgeam2`|10.0| | | | | | | | | | +|`cusparseScsrgeam2`|10.0| | | |`rocsparse_scsrgeam`|3.5.0| | | | | |`cusparseScsrgeam2_bufferSizeExt`|10.0| | | | | | | | | | |`cusparseScsrgemm`| |10.2| |11.0| | | | | | | |`cusparseScsrgemm2`| |11.0| |12.0| | | | | | | @@ -461,7 +461,7 @@ |`cusparseXcsrgemm2Nnz`| |11.0| |12.0|`rocsparse_csrgemm_nnz`|2.8.0| | | | | |`cusparseXcsrgemmNnz`| |10.2| |11.0| | | | | | | |`cusparseZcsrgeam`| |10.2| |11.0|`rocsparse_zcsrgeam`|3.5.0| | | | | -|`cusparseZcsrgeam2`|10.0| | | | | | | | | | +|`cusparseZcsrgeam2`|10.0| | | |`rocsparse_zcsrgeam`|3.5.0| | | | | |`cusparseZcsrgeam2_bufferSizeExt`|10.0| | | | | | | | | | |`cusparseZcsrgemm`| |10.2| |11.0| | | | | | | |`cusparseZcsrgemm2`| |11.0| |12.0| | | | | | | diff --git a/src/CUDA2HIP_SPARSE_API_functions.cpp b/src/CUDA2HIP_SPARSE_API_functions.cpp index a8f0a980..71d18a9b 100644 --- a/src/CUDA2HIP_SPARSE_API_functions.cpp +++ b/src/CUDA2HIP_SPARSE_API_functions.cpp @@ -296,10 +296,10 @@ const std::map CUDA_SPARSE_FUNCTION_MAP { {"cusparseZcsrgeam", {"hipsparseZcsrgeam", "rocsparse_zcsrgeam", CONV_LIB_FUNC, API_SPARSE, 11, CUDA_DEPRECATED | CUDA_REMOVED}}, {"cusparseXcsrgeamNnz", {"hipsparseXcsrgeamNnz", "rocsparse_csrgeam_nnz", CONV_LIB_FUNC, API_SPARSE, 11, CUDA_DEPRECATED | CUDA_REMOVED}}, - {"cusparseScsrgeam2", {"hipsparseScsrgeam2", "", CONV_LIB_FUNC, API_SPARSE, 11, ROC_UNSUPPORTED}}, - {"cusparseDcsrgeam2", {"hipsparseDcsrgeam2", "", CONV_LIB_FUNC, API_SPARSE, 11, ROC_UNSUPPORTED}}, - {"cusparseCcsrgeam2", {"hipsparseCcsrgeam2", "", CONV_LIB_FUNC, API_SPARSE, 11, ROC_UNSUPPORTED}}, - {"cusparseZcsrgeam2", {"hipsparseZcsrgeam2", "", CONV_LIB_FUNC, API_SPARSE, 11, ROC_UNSUPPORTED}}, + {"cusparseScsrgeam2", {"hipsparseScsrgeam2", "rocsparse_scsrgeam", CONV_LIB_FUNC, API_SPARSE, 11}}, + {"cusparseDcsrgeam2", {"hipsparseDcsrgeam2", "rocsparse_dcsrgeam", CONV_LIB_FUNC, API_SPARSE, 11}}, + {"cusparseCcsrgeam2", {"hipsparseCcsrgeam2", "rocsparse_ccsrgeam", CONV_LIB_FUNC, API_SPARSE, 11}}, + {"cusparseZcsrgeam2", {"hipsparseZcsrgeam2", "rocsparse_zcsrgeam", CONV_LIB_FUNC, API_SPARSE, 11}}, {"cusparseXcsrgeam2Nnz", {"hipsparseXcsrgeam2Nnz", "", CONV_LIB_FUNC, API_SPARSE, 11, ROC_UNSUPPORTED}}, {"cusparseScsrgeam2_bufferSizeExt", {"hipsparseScsrgeam2_bufferSizeExt", "", CONV_LIB_FUNC, API_SPARSE, 11, ROC_UNSUPPORTED}}, diff --git a/src/HipifyAction.cpp b/src/HipifyAction.cpp index 1e345050..34e517b1 100644 --- a/src/HipifyAction.cpp +++ b/src/HipifyAction.cpp @@ -179,6 +179,10 @@ const std::string sCusparseZcsrmm = "cusparseZcsrmm"; const std::string sCusparseCcsrmm = "cusparseCcsrmm"; const std::string sCusparseDcsrmm = "cusparseDcsrmm"; const std::string sCusparseScsrmm = "cusparseScsrmm"; +const std::string sCusparseZcsrgeam2 = "cusparseZcsrgeam2"; +const std::string sCusparseCcsrgeam2 = "cusparseCcsrgeam2"; +const std::string sCusparseDcsrgeam2 = "cusparseDcsrgeam2"; +const std::string sCusparseScsrgeam2 = "cusparseScsrgeam2"; // CUDA_OVERLOADED const std::string sCudaEventCreate = "cudaEventCreate"; @@ -1375,6 +1379,42 @@ std::map FuncArgCasts { false } }, + {sCusparseZcsrgeam2, + { + { + {19, {e_remove_argument, cw_None}} + }, + true, + false + } + }, + {sCusparseCcsrgeam2, + { + { + {19, {e_remove_argument, cw_None}} + }, + true, + false + } + }, + {sCusparseDcsrgeam2, + { + { + {19, {e_remove_argument, cw_None}} + }, + true, + false + } + }, + {sCusparseScsrgeam2, + { + { + {19, {e_remove_argument, cw_None}} + }, + true, + false + } + }, }; void HipifyAction::RewriteString(StringRef s, clang::SourceLocation start) { @@ -2186,7 +2226,11 @@ std::unique_ptr HipifyAction::CreateASTConsumer(clang::Compi sCusparseZcsrmm, sCusparseCcsrmm, sCusparseDcsrmm, - sCusparseScsrmm + sCusparseScsrmm, + sCusparseZcsrgeam2, + sCusparseCcsrgeam2, + sCusparseDcsrgeam2, + sCusparseScsrgeam2 ) ) ) diff --git a/tests/lit.cfg b/tests/lit.cfg index 04ad2b6f..4fe2dff1 100644 --- a/tests/lit.cfg +++ b/tests/lit.cfg @@ -74,6 +74,7 @@ if config.cuda_version_major < 10: config.excludes.append('cuSPARSE_10.cu') config.excludes.append('cuSPARSE_11.cu') config.excludes.append('simple_mechs.cu') + config.excludes.append('cusparse2rocsparse_10000.cu') if config.cuda_version_major > 10: clang_arguments += " -DTHRUST_IGNORE_CUB_VERSION_CHECK" diff --git a/tests/unit_tests/synthetic/libraries/cusparse2hipsparse.cu b/tests/unit_tests/synthetic/libraries/cusparse2hipsparse.cu index e710fc7c..725280ab 100644 --- a/tests/unit_tests/synthetic/libraries/cusparse2hipsparse.cu +++ b/tests/unit_tests/synthetic/libraries/cusparse2hipsparse.cu @@ -1768,6 +1768,28 @@ int main() { #endif #endif +#if CUDA_VERSION >= 10000 + // CUDA: cusparseStatus_t CUSPARSEAPI cusparseZcsrgeam2(cusparseHandle_t handle, int m, int n, const cuDoubleComplex* alpha, const cusparseMatDescr_t descrA, int nnzA, const cuDoubleComplex* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, const cuDoubleComplex* beta, const cusparseMatDescr_t descrB, int nnzB, const cuDoubleComplex* csrSortedValB, const int* csrSortedRowPtrB, const int* csrSortedColIndB, const cusparseMatDescr_t descrC, cuDoubleComplex* csrSortedValC, int* csrSortedRowPtrC, int* csrSortedColIndC, void* pBuffer); + // HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseZcsrgeam2(hipsparseHandle_t handle, int m, int n, const hipDoubleComplex* alpha, const hipsparseMatDescr_t descrA, int nnzA, const hipDoubleComplex* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, const hipDoubleComplex* beta, const hipsparseMatDescr_t descrB, int nnzB, const hipDoubleComplex* csrSortedValB, const int* csrSortedRowPtrB, const int* csrSortedColIndB, const hipsparseMatDescr_t descrC, hipDoubleComplex* csrSortedValC, int* csrSortedRowPtrC, int* csrSortedColIndC, void* pBuffer); + // CHECK: status_t = hipsparseZcsrgeam2(handle_t, m, n, &dcomplexA, matDescr_A, nnza, &dComplexcsrSortedValA, &csrRowPtrA, &csrColIndA, &dcomplexB, matDescr_B, nnzb, &dComplexcsrSortedValB, &csrRowPtrB, &csrColIndB, matDescr_C, &dComplexcsrSortedValC, &csrRowPtrC, &csrColIndC, pBuffer); + status_t = cusparseZcsrgeam2(handle_t, m, n, &dcomplexA, matDescr_A, nnza, &dComplexcsrSortedValA, &csrRowPtrA, &csrColIndA, &dcomplexB, matDescr_B, nnzb, &dComplexcsrSortedValB, &csrRowPtrB, &csrColIndB, matDescr_C, &dComplexcsrSortedValC, &csrRowPtrC, &csrColIndC, pBuffer); + + // CUDA: cusparseStatus_t CUSPARSEAPI cusparseCcsrgeam2(cusparseHandle_t handle, int m, int n, const cuComplex* alpha, const cusparseMatDescr_t descrA, int nnzA, const cuComplex* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, const cuComplex* beta, const cusparseMatDescr_t descrB, int nnzB, const cuComplex* csrSortedValB, const int* csrSortedRowPtrB, const int* csrSortedColIndB, const cusparseMatDescr_t descrC, cuComplex* csrSortedValC, int* csrSortedRowPtrC, int* csrSortedColIndC, void* pBuffer); + // HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseCcsrgeam2(hipsparseHandle_t handle, int m, int n, const hipComplex* alpha, const hipsparseMatDescr_t descrA, int nnzA, const hipComplex* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, const hipComplex* beta, const hipsparseMatDescr_t descrB, int nnzB, const hipComplex* csrSortedValB, const int* csrSortedRowPtrB, const int* csrSortedColIndB, const hipsparseMatDescr_t descrC, hipComplex* csrSortedValC, int* csrSortedRowPtrC, int* csrSortedColIndC, void* pBuffer); + // CHECK: status_t = hipsparseCcsrgeam2(handle_t, m, n, &complexA, matDescr_A, nnza, &complexcsrSortedValA, &csrRowPtrA, &csrColIndA, &complexB, matDescr_B, nnzb, &complexcsrSortedValB, &csrRowPtrB, &csrColIndB, matDescr_C, &complexcsrSortedValC, &csrRowPtrC, &csrColIndC, pBuffer); + status_t = cusparseCcsrgeam2(handle_t, m, n, &complexA, matDescr_A, nnza, &complexcsrSortedValA, &csrRowPtrA, &csrColIndA, &complexB, matDescr_B, nnzb, &complexcsrSortedValB, &csrRowPtrB, &csrColIndB, matDescr_C, &complexcsrSortedValC, &csrRowPtrC, &csrColIndC, pBuffer); + + // CUDA: cusparseStatus_t CUSPARSEAPI cusparseDcsrgeam2(cusparseHandle_t handle, int m, int n, const double* alpha, const cusparseMatDescr_t descrA, int nnzA, const double* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, const double* beta, const cusparseMatDescr_t descrB, int nnzB, const double* csrSortedValB, const int* csrSortedRowPtrB, const int* csrSortedColIndB, const cusparseMatDescr_t descrC, double* csrSortedValC, int* csrSortedRowPtrC, int* csrSortedColIndC, void* pBuffer); + // HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseDcsrgeam2(hipsparseHandle_t handle, int m, int n, const double* alpha, const hipsparseMatDescr_t descrA, int nnzA, const double* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, const double* beta, const hipsparseMatDescr_t descrB, int nnzB, const double* csrSortedValB, const int* csrSortedRowPtrB, const int* csrSortedColIndB, const hipsparseMatDescr_t descrC, double* csrSortedValC, int* csrSortedRowPtrC, int* csrSortedColIndC, void* pBuffer); + // CHECK: status_t = hipsparseDcsrgeam2(handle_t, m, n, &dA, matDescr_A, nnza, &dcsrSortedValA, &csrRowPtrA, &csrColIndA, &dB, matDescr_B, nnzb, &dcsrSortedValB, &csrRowPtrB, &csrColIndB, matDescr_C, &dcsrSortedValC, &csrRowPtrC, &csrColIndC, pBuffer); + status_t = cusparseDcsrgeam2(handle_t, m, n, &dA, matDescr_A, nnza, &dcsrSortedValA, &csrRowPtrA, &csrColIndA, &dB, matDescr_B, nnzb, &dcsrSortedValB, &csrRowPtrB, &csrColIndB, matDescr_C, &dcsrSortedValC, &csrRowPtrC, &csrColIndC, pBuffer); + + // CUDA: cusparseStatus_t CUSPARSEAPI cusparseScsrgeam2(cusparseHandle_t handle, int m, int n, const float* alpha, const cusparseMatDescr_t descrA, int nnzA, const float* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, const float* beta, const cusparseMatDescr_t descrB, int nnzB, const float* csrSortedValB, const int* csrSortedRowPtrB, const int* csrSortedColIndB, const cusparseMatDescr_t descrC, float* csrSortedValC, int* csrSortedRowPtrC, int* csrSortedColIndC, void* pBuffer); + // HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseScsrgeam2(hipsparseHandle_t handle, int m, int n, const float* alpha, const hipsparseMatDescr_t descrA, int nnzA, const float* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, const float* beta, const hipsparseMatDescr_t descrB, int nnzB, const float* csrSortedValB, const int* csrSortedRowPtrB, const int* csrSortedColIndB, const hipsparseMatDescr_t descrC, float* csrSortedValC, int* csrSortedRowPtrC, int* csrSortedColIndC, void* pBuffer); + // CHECK: status_t = hipsparseScsrgeam2(handle_t, m, n, &fA, matDescr_A, nnza, &csrSortedValA, &csrRowPtrA, &csrColIndA, &fB, matDescr_B, nnzb, &csrSortedValB, &csrRowPtrB, &csrColIndB, matDescr_C, &csrSortedValC, &csrRowPtrC, &csrColIndC, pBuffer); + status_t = cusparseScsrgeam2(handle_t, m, n, &fA, matDescr_A, nnza, &csrSortedValA, &csrRowPtrA, &csrColIndA, &fB, matDescr_B, nnzb, &csrSortedValB, &csrRowPtrB, &csrColIndB, matDescr_C, &csrSortedValC, &csrRowPtrC, &csrColIndC, pBuffer); +#endif + #if CUDA_VERSION >= 10010 // CHECK: hipsparseCsr2CscAlg_t Csr2CscAlg_t; // CHECK-NEXT: hipsparseCsr2CscAlg_t CSR2CSC_ALG1 = HIPSPARSE_CSR2CSC_ALG1; diff --git a/tests/unit_tests/synthetic/libraries/cusparse2rocsparse_10000.cu b/tests/unit_tests/synthetic/libraries/cusparse2rocsparse_10000.cu new file mode 100644 index 00000000..d0f76131 --- /dev/null +++ b/tests/unit_tests/synthetic/libraries/cusparse2rocsparse_10000.cu @@ -0,0 +1,92 @@ +// RUN: %run_test hipify "%s" "%t" %hipify_args 4 --skip-excluded-preprocessor-conditional-blocks --experimental --roc --use-hip-data-types %clang_args -ferror-limit=500 + +// CHECK: #include +#include +// CHECK: #include "hip/hip_complex.h" +#include "cuComplex.h" +#include +// CHECK: #include "rocsparse.h" +#include "cusparse.h" +// CHECK-NOT: #include "rocsparse.h" + +int main() { + printf("18.1. cuSPARSE API to rocSPARSE API synthetic test\n"); + + // CHECK: _rocsparse_handle *handle = nullptr; + // CHECK-NEXT: rocsparse_handle handle_t; + cusparseContext *handle = nullptr; + cusparseHandle_t handle_t; + + // CHECK: rocsparse_status status_t; + cusparseStatus_t status_t; + + // CHECK: _rocsparse_mat_descr *matDescr = nullptr; + // CHECK-NEXT: rocsparse_mat_descr matDescr_t, matDescr_t_2, matDescr_A, matDescr_B, matDescr_C, matDescr_D; + cusparseMatDescr *matDescr = nullptr; + cusparseMatDescr_t matDescr_t, matDescr_t_2, matDescr_A, matDescr_B, matDescr_C, matDescr_D; + + int m = 0; + int n = 0; + int k = 0; + int nnza = 0; + int nnzb = 0; + int nnzc = 0; + int lda = 0; + int ldb = 0; + int ldc = 0; + int csrRowPtrA = 0; + int csrRowPtrB = 0; + int csrRowPtrC = 0; + int csrColIndA = 0; + int csrColIndB = 0; + int csrColIndC = 0; + double dAlpha = 0.f; + double dBeta = 0.f; + double dA = 0.f; + double dB = 0.f; + double dC = 0.f; + double dcsrSortedValA = 0.f; + double dcsrSortedValB = 0.f; + double dcsrSortedValC = 0.f; + float fA = 0.f; + float fB = 0.f; + float fC = 0.f; + float csrSortedValA = 0.f; + float csrSortedValB = 0.f; + float csrSortedValC = 0.f; + void *pBuffer = nullptr; + + // TODO: should be rocsparse_double_complex + // TODO: add to TypeOverloads cuDoubleComplex -> rocsparse_double_complex under a new option --sparse + // CHECK: rocblas_double_complex dcomplex, dcomplexA, dcomplexB, dComplexbsrSortedValA, dComplexbsrSortedValC, dComplexcsrSortedValA, dComplexcsrSortedValB, dComplexcsrSortedValC, dcomplextol, dComplexbsrSortedVal, dComplexbscVal, dComplexcscSortedVal, dcomplexds, dcomplexdl, dcomplexd, dcomplexdu, dcomplexdw, dcomplexx, dcomplex_boost_val; + cuDoubleComplex dcomplex, dcomplexA, dcomplexB, dComplexbsrSortedValA, dComplexbsrSortedValC, dComplexcsrSortedValA, dComplexcsrSortedValB, dComplexcsrSortedValC, dcomplextol, dComplexbsrSortedVal, dComplexbscVal, dComplexcscSortedVal, dcomplexds, dcomplexdl, dcomplexd, dcomplexdu, dcomplexdw, dcomplexx, dcomplex_boost_val; + + // TODO: should be rocsparse_double_complex + // TODO: add to TypeOverloads cuComplex -> rocsparse_float_complex under a new option --sparse + // CHECK: rocblas_float_complex complex, complexA, complexB, complexbsrValA, complexbsrSortedValC, complexcsrSortedValA, complexcsrSortedValB, complexcsrSortedValC, complextol, complexbsrSortedVal, complexbscVal, complexcscSortedVal, complexds, complexdl, complexd, complexdu, complexdw, complexx, complex_boost_val; + cuComplex complex, complexA, complexB, complexbsrValA, complexbsrSortedValC, complexcsrSortedValA, complexcsrSortedValB, complexcsrSortedValC, complextol, complexbsrSortedVal, complexbscVal, complexcscSortedVal, complexds, complexdl, complexd, complexdu, complexdw, complexx, complex_boost_val; + +#if CUDA_VERSION >= 10000 + // CUDA: cusparseStatus_t CUSPARSEAPI cusparseZcsrgeam2(cusparseHandle_t handle, int m, int n, const cuDoubleComplex* alpha, const cusparseMatDescr_t descrA, int nnzA, const cuDoubleComplex* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, const cuDoubleComplex* beta, const cusparseMatDescr_t descrB, int nnzB, const cuDoubleComplex* csrSortedValB, const int* csrSortedRowPtrB, const int* csrSortedColIndB, const cusparseMatDescr_t descrC, cuDoubleComplex* csrSortedValC, int* csrSortedRowPtrC, int* csrSortedColIndC, void* pBuffer); + // ROC: ROCSPARSE_EXPORT rocsparse_status rocsparse_zcsrgeam(rocsparse_handle handle, rocsparse_int m, rocsparse_int n, const rocsparse_double_complex* alpha, const rocsparse_mat_descr descr_A, rocsparse_int nnz_A, const rocsparse_double_complex* csr_val_A, const rocsparse_int* csr_row_ptr_A, const rocsparse_int* csr_col_ind_A, const rocsparse_double_complex* beta, const rocsparse_mat_descr descr_B, rocsparse_int nnz_B, const rocsparse_double_complex* csr_val_B, const rocsparse_int* csr_row_ptr_B, const rocsparse_int* csr_col_ind_B, const rocsparse_mat_descr descr_C, rocsparse_double_complex* csr_val_C, const rocsparse_int* csr_row_ptr_C, rocsparse_int* csr_col_ind_C); + // CHECK: status_t = rocsparse_zcsrgeam(handle_t, m, n, &dcomplexA, matDescr_A, nnza, &dComplexcsrSortedValA, &csrRowPtrA, &csrColIndA, &dcomplexB, matDescr_B, nnzb, &dComplexcsrSortedValB, &csrRowPtrB, &csrColIndB, matDescr_C, &dComplexcsrSortedValC, &csrRowPtrC, &csrColIndC); + status_t = cusparseZcsrgeam2(handle_t, m, n, &dcomplexA, matDescr_A, nnza, &dComplexcsrSortedValA, &csrRowPtrA, &csrColIndA, &dcomplexB, matDescr_B, nnzb, &dComplexcsrSortedValB, &csrRowPtrB, &csrColIndB, matDescr_C, &dComplexcsrSortedValC, &csrRowPtrC, &csrColIndC, pBuffer); + + // CUDA: cusparseStatus_t CUSPARSEAPI cusparseCcsrgeam2(cusparseHandle_t handle, int m, int n, const cuComplex* alpha, const cusparseMatDescr_t descrA, int nnzA, const cuComplex* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, const cuComplex* beta, const cusparseMatDescr_t descrB, int nnzB, const cuComplex* csrSortedValB, const int* csrSortedRowPtrB, const int* csrSortedColIndB, const cusparseMatDescr_t descrC, cuComplex* csrSortedValC, int* csrSortedRowPtrC, int* csrSortedColIndC, void* pBuffer); + // ROC: ROCSPARSE_EXPORT rocsparse_status rocsparse_ccsrgeam(rocsparse_handle handle, rocsparse_int m, rocsparse_int n, const rocsparse_float_complex* alpha, const rocsparse_mat_descr descr_A, rocsparse_int nnz_A, const rocsparse_float_complex* csr_val_A, const rocsparse_int* csr_row_ptr_A, const rocsparse_int* csr_col_ind_A, const rocsparse_float_complex* beta, const rocsparse_mat_descr descr_B, rocsparse_int nnz_B, const rocsparse_float_complex* csr_val_B, const rocsparse_int* csr_row_ptr_B, const rocsparse_int* csr_col_ind_B, const rocsparse_mat_descr descr_C, rocsparse_float_complex* csr_val_C, const rocsparse_int* csr_row_ptr_C, rocsparse_int* csr_col_ind_C); + // CHECK: status_t = rocsparse_ccsrgeam(handle_t, m, n, &complexA, matDescr_A, nnza, &complexcsrSortedValA, &csrRowPtrA, &csrColIndA, &complexB, matDescr_B, nnzb, &complexcsrSortedValB, &csrRowPtrB, &csrColIndB, matDescr_C, &complexcsrSortedValC, &csrRowPtrC, &csrColIndC); + status_t = cusparseCcsrgeam2(handle_t, m, n, &complexA, matDescr_A, nnza, &complexcsrSortedValA, &csrRowPtrA, &csrColIndA, &complexB, matDescr_B, nnzb, &complexcsrSortedValB, &csrRowPtrB, &csrColIndB, matDescr_C, &complexcsrSortedValC, &csrRowPtrC, &csrColIndC, pBuffer); + + // CUDA: cusparseStatus_t CUSPARSEAPI cusparseDcsrgeam2(cusparseHandle_t handle, int m, int n, const double* alpha, const cusparseMatDescr_t descrA, int nnzA, const double* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, const double* beta, const cusparseMatDescr_t descrB, int nnzB, const double* csrSortedValB, const int* csrSortedRowPtrB, const int* csrSortedColIndB, const cusparseMatDescr_t descrC, double* csrSortedValC, int* csrSortedRowPtrC, int* csrSortedColIndC, void* pBuffer); + // ROC: ROCSPARSE_EXPORT rocsparse_status rocsparse_dcsrgeam(rocsparse_handle handle, rocsparse_int m, rocsparse_int n, const double* alpha, const rocsparse_mat_descr descr_A, rocsparse_int nnz_A, const double* csr_val_A, const rocsparse_int* csr_row_ptr_A, const rocsparse_int* csr_col_ind_A, const double* beta, const rocsparse_mat_descr descr_B, rocsparse_int nnz_B, const double* csr_val_B, const rocsparse_int* csr_row_ptr_B, const rocsparse_int* csr_col_ind_B, const rocsparse_mat_descr descr_C, double* csr_val_C, const rocsparse_int* csr_row_ptr_C, rocsparse_int* csr_col_ind_C); + // CHECK: status_t = rocsparse_dcsrgeam(handle_t, m, n, &dA, matDescr_A, nnza, &dcsrSortedValA, &csrRowPtrA, &csrColIndA, &dB, matDescr_B, nnzb, &dcsrSortedValB, &csrRowPtrB, &csrColIndB, matDescr_C, &dcsrSortedValC, &csrRowPtrC, &csrColIndC); + status_t = cusparseDcsrgeam2(handle_t, m, n, &dA, matDescr_A, nnza, &dcsrSortedValA, &csrRowPtrA, &csrColIndA, &dB, matDescr_B, nnzb, &dcsrSortedValB, &csrRowPtrB, &csrColIndB, matDescr_C, &dcsrSortedValC, &csrRowPtrC, &csrColIndC, pBuffer); + + // CUDA: cusparseStatus_t CUSPARSEAPI cusparseScsrgeam2(cusparseHandle_t handle, int m, int n, const float* alpha, const cusparseMatDescr_t descrA, int nnzA, const float* csrSortedValA, const int* csrSortedRowPtrA, const int* csrSortedColIndA, const float* beta, const cusparseMatDescr_t descrB, int nnzB, const float* csrSortedValB, const int* csrSortedRowPtrB, const int* csrSortedColIndB, const cusparseMatDescr_t descrC, float* csrSortedValC, int* csrSortedRowPtrC, int* csrSortedColIndC, void* pBuffer); + // ROC: ROCSPARSE_EXPORT rocsparse_status rocsparse_scsrgeam(rocsparse_handle handle, rocsparse_int m, rocsparse_int n, const float* alpha, const rocsparse_mat_descr descr_A, rocsparse_int nnz_A, const float* csr_val_A, const rocsparse_int* csr_row_ptr_A, const rocsparse_int* csr_col_ind_A, const float* beta, const rocsparse_mat_descr descr_B, rocsparse_int nnz_B, const float* csr_val_B, const rocsparse_int* csr_row_ptr_B, const rocsparse_int* csr_col_ind_B, const rocsparse_mat_descr descr_C, float* csr_val_C, const rocsparse_int* csr_row_ptr_C, rocsparse_int* csr_col_ind_C); + // CHECK: status_t = rocsparse_scsrgeam(handle_t, m, n, &fA, matDescr_A, nnza, &csrSortedValA, &csrRowPtrA, &csrColIndA, &fB, matDescr_B, nnzb, &csrSortedValB, &csrRowPtrB, &csrColIndB, matDescr_C, &csrSortedValC, &csrRowPtrC, &csrColIndC); + status_t = cusparseScsrgeam2(handle_t, m, n, &fA, matDescr_A, nnza, &csrSortedValA, &csrRowPtrA, &csrColIndA, &fB, matDescr_B, nnzb, &csrSortedValB, &csrRowPtrB, &csrColIndB, matDescr_C, &csrSortedValC, &csrRowPtrC, &csrColIndC, pBuffer); +#endif + + return 0; +}