From 5f6c8fa5359ddb1ea6c9b51cbaedd3c885bb3fbb Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Wed, 18 Mar 2020 13:07:46 +0300 Subject: [PATCH] [HIPIFY][SPARSE] sync with hipSPARSE + Update doc and hipify-perl accordingly --- bin/hipify-perl | 7 +++++++ docs/markdown/CUSPARSE_API_supported_by_HIP.md | 14 +++++++------- hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp | 8 ++++---- hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp | 6 +++--- .../unit_tests/libraries/cuSPARSE/cuSPARSE_12.cu | 3 +-- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/bin/hipify-perl b/bin/hipify-perl index f6de5abae4..dc039cb8a1 100755 --- a/bin/hipify-perl +++ b/bin/hipify-perl @@ -759,6 +759,7 @@ sub simpleSubstitutions { $ft{'library'} += s/\bcusparseCgthr\b/hipsparseCgthr/g; $ft{'library'} += s/\bcusparseCgthrz\b/hipsparseCgthrz/g; $ft{'library'} += s/\bcusparseChybmv\b/hipsparseChybmv/g; + $ft{'library'} += s/\bcusparseCnnz\b/hipsparseCnnz/g; $ft{'library'} += s/\bcusparseCreate\b/hipsparseCreate/g; $ft{'library'} += s/\bcusparseCreateCsrgemm2Info\b/hipsparseCreateCsrgemm2Info/g; $ft{'library'} += s/\bcusparseCreateCsrilu02Info\b/hipsparseCreateCsrilu02Info/g; @@ -794,6 +795,7 @@ sub simpleSubstitutions { $ft{'library'} += s/\bcusparseDgthr\b/hipsparseDgthr/g; $ft{'library'} += s/\bcusparseDgthrz\b/hipsparseDgthrz/g; $ft{'library'} += s/\bcusparseDhybmv\b/hipsparseDhybmv/g; + $ft{'library'} += s/\bcusparseDnnz\b/hipsparseDnnz/g; $ft{'library'} += s/\bcusparseDroti\b/hipsparseDroti/g; $ft{'library'} += s/\bcusparseDsctr\b/hipsparseDsctr/g; $ft{'library'} += s/\bcusparseGetMatDiagType\b/hipsparseGetMatDiagType/g; @@ -830,6 +832,7 @@ sub simpleSubstitutions { $ft{'library'} += s/\bcusparseSgthr\b/hipsparseSgthr/g; $ft{'library'} += s/\bcusparseSgthrz\b/hipsparseSgthrz/g; $ft{'library'} += s/\bcusparseShybmv\b/hipsparseShybmv/g; + $ft{'library'} += s/\bcusparseSnnz\b/hipsparseSnnz/g; $ft{'library'} += s/\bcusparseSroti\b/hipsparseSroti/g; $ft{'library'} += s/\bcusparseSsctr\b/hipsparseSsctr/g; $ft{'library'} += s/\bcusparseXbsrilu02_zeroPivot\b/hipsparseXbsrilu02_zeroPivot/g; @@ -868,6 +871,7 @@ sub simpleSubstitutions { $ft{'library'} += s/\bcusparseZgthr\b/hipsparseZgthr/g; $ft{'library'} += s/\bcusparseZgthrz\b/hipsparseZgthrz/g; $ft{'library'} += s/\bcusparseZhybmv\b/hipsparseZhybmv/g; + $ft{'library'} += s/\bcusparseZnnz\b/hipsparseZnnz/g; $ft{'library'} += s/\bcusparseZsctr\b/hipsparseZsctr/g; $ft{'device_library'} += s/\bcurand\b/hiprand/g; $ft{'device_library'} += s/\bcurand_discrete\b/hiprand_discrete/g; @@ -1124,6 +1128,7 @@ sub simpleSubstitutions { $ft{'type'} += s/\bcurandStatus_t\b/hiprandStatus_t/g; $ft{'type'} += s/\bcusparseAction_t\b/hipsparseAction_t/g; $ft{'type'} += s/\bcusparseDiagType_t\b/hipsparseDiagType_t/g; + $ft{'type'} += s/\bcusparseDirection_t\b/hipsparseDirection_t/g; $ft{'type'} += s/\bcusparseFillMode_t\b/hipsparseFillMode_t/g; $ft{'type'} += s/\bcusparseHandle_t\b/hipsparseHandle_t/g; $ft{'type'} += s/\bcusparseHybMat_t\b/hipsparseHybMat_t/g; @@ -1392,6 +1397,8 @@ sub simpleSubstitutions { $ft{'numeric_literal'} += s/\bCUSPARSE_ACTION_SYMBOLIC\b/HIPSPARSE_ACTION_SYMBOLIC/g; $ft{'numeric_literal'} += s/\bCUSPARSE_DIAG_TYPE_NON_UNIT\b/HIPSPARSE_DIAG_TYPE_NON_UNIT/g; $ft{'numeric_literal'} += s/\bCUSPARSE_DIAG_TYPE_UNIT\b/HIPSPARSE_DIAG_TYPE_UNIT/g; + $ft{'numeric_literal'} += s/\bCUSPARSE_DIRECTION_COLUMN\b/HIPSPARSE_DIRECTION_COLUMN/g; + $ft{'numeric_literal'} += s/\bCUSPARSE_DIRECTION_ROW\b/HIPSPARSE_DIRECTION_ROW/g; $ft{'numeric_literal'} += s/\bCUSPARSE_FILL_MODE_LOWER\b/HIPSPARSE_FILL_MODE_LOWER/g; $ft{'numeric_literal'} += s/\bCUSPARSE_FILL_MODE_UPPER\b/HIPSPARSE_FILL_MODE_UPPER/g; $ft{'numeric_literal'} += s/\bCUSPARSE_HYB_PARTITION_AUTO\b/HIPSPARSE_HYB_PARTITION_AUTO/g; diff --git a/docs/markdown/CUSPARSE_API_supported_by_HIP.md b/docs/markdown/CUSPARSE_API_supported_by_HIP.md index fc7a8ee8cd..939c631d67 100644 --- a/docs/markdown/CUSPARSE_API_supported_by_HIP.md +++ b/docs/markdown/CUSPARSE_API_supported_by_HIP.md @@ -12,9 +12,9 @@ | enum |***`cusparseAction_t`*** | |***`hipsparseAction_t`*** | | 0 |*`CUSPARSE_ACTION_SYMBOLIC`* | |*`HIPSPARSE_ACTION_SYMBOLIC`* | | 1 |*`CUSPARSE_ACTION_NUMERIC`* | |*`HIPSPARSE_ACTION_NUMERIC`* | -| enum |***`cusparseDirection_t`*** | | | -| 0 |*`CUSPARSE_DIRECTION_ROW`* | | | -| 1 |*`CUSPARSE_DIRECTION_COLUMN`* | | | +| enum |***`cusparseDirection_t`*** | |***`hipsparseDirection_t`*** | +| 0 |*`CUSPARSE_DIRECTION_ROW`* | |*`HIPSPARSE_DIRECTION_ROW`* | +| 1 |*`CUSPARSE_DIRECTION_COLUMN`* | |*`HIPSPARSE_DIRECTION_COLUMN`* | | enum |***`cusparseHybPartition_t`*** | |***`hipsparseHybPartition_t`*** | | 0 |*`CUSPARSE_HYB_PARTITION_AUTO`* | |*`HIPSPARSE_HYB_PARTITION_AUTO`* | | 1 |*`CUSPARSE_HYB_PARTITION_USER`* | |*`HIPSPARSE_HYB_PARTITION_USER`* | @@ -662,10 +662,10 @@ |`cusparseDhyb2dense` | | |`cusparseChyb2dense` | | |`cusparseZhyb2dense` | | -|`cusparseSnnz` | | -|`cusparseDnnz` | | -|`cusparseCnnz` | | -|`cusparseZnnz` | | +|`cusparseSnnz` |`cusparseSnnz` | +|`cusparseDnnz` |`cusparseDnnz` | +|`cusparseCnnz` |`cusparseCnnz` | +|`cusparseZnnz` |`cusparseZnnz` | |`cusparseCreateIdentityPermutation` |`hipsparseCreateIdentityPermutation` | |`cusparseXcoosort_bufferSizeExt` |`hipsparseXcoosort_bufferSizeExt` | |`cusparseXcoosortByRow` |`hipsparseXcoosortByRow` | diff --git a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp index 1df1bb9cba..d5d32cd0ff 100644 --- a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp +++ b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp @@ -619,10 +619,10 @@ const std::map CUDA_SPARSE_FUNCTION_MAP{ {"cusparseChyb2dense", {"hipsparseChyb2dense", "", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseZhyb2dense", {"hipsparseZhyb2dense", "", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSnnz", {"hipsparseSnnz", "", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDnnz", {"hipsparseDnnz", "", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCnnz", {"hipsparseCnnz", "", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZnnz", {"hipsparseZnnz", "", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSnnz", {"hipsparseSnnz", "", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDnnz", {"hipsparseDnnz", "", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCnnz", {"hipsparseCnnz", "", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseZnnz", {"hipsparseZnnz", "", CONV_LIB_FUNC, API_SPARSE}}, {"cusparseCreateIdentityPermutation", {"hipsparseCreateIdentityPermutation", "", CONV_LIB_FUNC, API_SPARSE}}, diff --git a/hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp b/hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp index 1d3fe28c62..8cebef51d4 100644 --- a/hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp +++ b/hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp @@ -88,9 +88,9 @@ const std::map CUDA_SPARSE_TYPE_NAME_MAP{ {"CUSPARSE_ACTION_SYMBOLIC", {"HIPSPARSE_ACTION_SYMBOLIC", "", CONV_NUMERIC_LITERAL, API_SPARSE}}, {"CUSPARSE_ACTION_NUMERIC", {"HIPSPARSE_ACTION_NUMERIC", "", CONV_NUMERIC_LITERAL, API_SPARSE}}, - {"cusparseDirection_t", {"hipsparseDirection_t", "", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, - {"CUSPARSE_DIRECTION_ROW", {"HIPSPARSE_DIRECTION_ROW", "", CONV_NUMERIC_LITERAL, API_SPARSE, HIP_UNSUPPORTED}}, - {"CUSPARSE_DIRECTION_COLUMN", {"HIPSPARSE_DIRECTION_COLUMN", "", CONV_NUMERIC_LITERAL, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDirection_t", {"hipsparseDirection_t", "", CONV_TYPE, API_SPARSE}}, + {"CUSPARSE_DIRECTION_ROW", {"HIPSPARSE_DIRECTION_ROW", "", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_DIRECTION_COLUMN", {"HIPSPARSE_DIRECTION_COLUMN", "", CONV_NUMERIC_LITERAL, API_SPARSE}}, {"cusparseHybPartition_t", {"hipsparseHybPartition_t", "", CONV_TYPE, API_SPARSE}}, {"CUSPARSE_HYB_PARTITION_AUTO", {"HIPSPARSE_HYB_PARTITION_AUTO", "", CONV_NUMERIC_LITERAL, API_SPARSE}}, diff --git a/tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_12.cu b/tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_12.cu index c6d62c0007..e6a2178053 100644 --- a/tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_12.cu +++ b/tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_12.cu @@ -385,8 +385,7 @@ double compute_BSR(BCRSArrays& bcsr, double *x , double *y){ cudaEventCreate(&startTime); cudaEventCreate(&stopTime); cudaEventRecord(startTime, bcsr.streamId); - // NOTE: cusparseDbsrmv and CUSPARSE_DIRECTION_COLUMN (of type cusparseDirection_t) are yet unsupported by HIP - // CHECK: cusparseDbsrmv(bcsr.cusparseHandle, CUSPARSE_DIRECTION_COLUMN, HIPSPARSE_OPERATION_NON_TRANSPOSE, + // CHECK: cusparseDbsrmv(bcsr.cusparseHandle, HIPSPARSE_DIRECTION_COLUMN, HIPSPARSE_OPERATION_NON_TRANSPOSE, cusparseDbsrmv(bcsr.cusparseHandle, CUSPARSE_DIRECTION_COLUMN, CUSPARSE_OPERATION_NON_TRANSPOSE, bcsr.nbBlockRow, bcsr.m, bcsr.nbBlocks, &alpha, descr, bcsr.cu_bsrValC, bcsr.cu_bsrRowPtrC, bcsr.cu_bsrColIndC, bcsr.blockSize,