diff --git a/bin/hipify-perl b/bin/hipify-perl index bd422769..9ead8270 100755 --- a/bin/hipify-perl +++ b/bin/hipify-perl @@ -6135,6 +6135,8 @@ sub simpleSubstitutions { subst("cusparseZnnz", "hipsparseZnnz", "library"); subst("cusparseZnnz_compress", "hipsparseZnnz_compress", "library"); subst("cusparseZsctr", "hipsparseZsctr", "library"); + subst("cutensorCreate", "hiptensorCreate", "library"); + subst("cutensorDestroy", "hiptensorDestroy", "library"); subst("nvrtcAddNameExpression", "hiprtcAddNameExpression", "library"); subst("nvrtcCompileProgram", "hiprtcCompileProgram", "library"); subst("nvrtcCreateProgram", "hiprtcCreateProgram", "library"); @@ -7367,6 +7369,7 @@ sub simpleSubstitutions { subst("cusparseStatus_t", "hipsparseStatus_t", "type"); subst("cutensorAlgo_t", "hiptensorAlgo_t", "type"); subst("cutensorDataType_t", "hiptensorComputeType_t", "type"); + subst("cutensorHandle_t", "hiptensorHandle_t", "type"); subst("cutensorOperator_t", "hiptensorOperator_t", "type"); subst("cutensorStatus_t", "hiptensorStatus_t", "type"); subst("cutensorWorksizePreference_t", "hiptensorWorksizePreference_t", "type"); @@ -9866,6 +9869,9 @@ sub warnHipOnlyUnsupportedFunctions { "cutensorPlanAttribute_t", "cutensorOperationDescriptorAttribute_t", "cutensorJitMode_t", + "cutensorHandleWritePlanCacheToFile", + "cutensorHandleResizePlanCache", + "cutensorHandleReadPlanCacheFromFile", "cutensorCacheMode_t", "cutensorAutotuneMode_t", "cusparseZhybsv_solve", @@ -11186,6 +11192,9 @@ sub warnRocOnlyUnsupportedFunctions { "cutensorPlanAttribute_t", "cutensorOperationDescriptorAttribute_t", "cutensorJitMode_t", + "cutensorHandleWritePlanCacheToFile", + "cutensorHandleResizePlanCache", + "cutensorHandleReadPlanCacheFromFile", "cutensorCacheMode_t", "cutensorAutotuneMode_t", "cusparseZhybsv_solve", diff --git a/docs/tables/CUTENSOR_API_supported_by_HIP.md b/docs/tables/CUTENSOR_API_supported_by_HIP.md index 721cb312..98df7901 100644 --- a/docs/tables/CUTENSOR_API_supported_by_HIP.md +++ b/docs/tables/CUTENSOR_API_supported_by_HIP.md @@ -90,21 +90,21 @@ |`CUTENSOR_R_64U`|2.0.0.0| | | | | | | | | | |`CUTENSOR_R_8I`|2.0.0.0| | | |`HIPTENSOR_COMPUTE_8I`|5.7.0| | | | | |`CUTENSOR_R_8U`|2.0.0.0| | | |`HIPTENSOR_COMPUTE_8U`|5.7.0| | | | | -|`CUTENSOR_STATUS_ALLOC_FAILED`| | | | |`HIPTENSOR_STATUS_ALLOC_FAILED`| | | | | | -|`CUTENSOR_STATUS_ARCH_MISMATCH`| | | | |`HIPTENSOR_STATUS_ARCH_MISMATCH`| | | | | | -|`CUTENSOR_STATUS_CUBLAS_ERROR`| | | | | | | | | | | -|`CUTENSOR_STATUS_CUDA_ERROR`| | | | | | | | | | | -|`CUTENSOR_STATUS_EXECUTION_FAILED`| | | | |`HIPTENSOR_STATUS_EXECUTION_FAILED`| | | | | | -|`CUTENSOR_STATUS_INSUFFICIENT_DRIVER`| | | | |`HIPTENSOR_STATUS_INSUFFICIENT_DRIVER`| | | | | | -|`CUTENSOR_STATUS_INSUFFICIENT_WORKSPACE`| | | | |`HIPTENSOR_STATUS_INSUFFICIENT_WORKSPACE`| | | | | | -|`CUTENSOR_STATUS_INTERNAL_ERROR`| | | | |`HIPTENSOR_STATUS_INTERNAL_ERROR`| | | | | | -|`CUTENSOR_STATUS_INVALID_VALUE`| | | | |`HIPTENSOR_STATUS_INVALID_VALUE`| | | | | | -|`CUTENSOR_STATUS_IO_ERROR`| | | | |`HIPTENSOR_STATUS_IO_ERROR`| | | | | | -|`CUTENSOR_STATUS_LICENSE_ERROR`| | | | | | | | | | | -|`CUTENSOR_STATUS_MAPPING_ERROR`| | | | | | | | | | | -|`CUTENSOR_STATUS_NOT_INITIALIZED`| | | | |`HIPTENSOR_STATUS_NOT_INITIALIZED`| | | | | | -|`CUTENSOR_STATUS_NOT_SUPPORTED`| | | | |`HIPTENSOR_STATUS_NOT_SUPPORTED`| | | | | | -|`CUTENSOR_STATUS_SUCCESS`| | | | |`HIPTENSOR_STATUS_SUCCESS`| | | | | | +|`CUTENSOR_STATUS_ALLOC_FAILED`|1.0.1.0| | | |`HIPTENSOR_STATUS_ALLOC_FAILED`|5.7.0| | | | | +|`CUTENSOR_STATUS_ARCH_MISMATCH`|1.0.1.0| | | |`HIPTENSOR_STATUS_ARCH_MISMATCH`|5.7.0| | | | | +|`CUTENSOR_STATUS_CUBLAS_ERROR`|1.0.1.0| | | | | | | | | | +|`CUTENSOR_STATUS_CUDA_ERROR`|1.0.1.0| | | | | | | | | | +|`CUTENSOR_STATUS_EXECUTION_FAILED`|1.0.1.0| | | |`HIPTENSOR_STATUS_EXECUTION_FAILED`|5.7.0| | | | | +|`CUTENSOR_STATUS_INSUFFICIENT_DRIVER`|1.0.1.0| | | |`HIPTENSOR_STATUS_INSUFFICIENT_DRIVER`|5.7.0| | | | | +|`CUTENSOR_STATUS_INSUFFICIENT_WORKSPACE`|1.0.1.0| | | |`HIPTENSOR_STATUS_INSUFFICIENT_WORKSPACE`|5.7.0| | | | | +|`CUTENSOR_STATUS_INTERNAL_ERROR`|1.0.1.0| | | |`HIPTENSOR_STATUS_INTERNAL_ERROR`|5.7.0| | | | | +|`CUTENSOR_STATUS_INVALID_VALUE`|1.0.1.0| | | |`HIPTENSOR_STATUS_INVALID_VALUE`|5.7.0| | | | | +|`CUTENSOR_STATUS_IO_ERROR`|1.2.0.0| | | |`HIPTENSOR_STATUS_IO_ERROR`|5.7.0| | | | | +|`CUTENSOR_STATUS_LICENSE_ERROR`|1.0.1.0| | | | | | | | | | +|`CUTENSOR_STATUS_MAPPING_ERROR`|1.0.1.0| | | | | | | | | | +|`CUTENSOR_STATUS_NOT_INITIALIZED`|1.0.1.0| | | |`HIPTENSOR_STATUS_NOT_INITIALIZED`|5.7.0| | | | | +|`CUTENSOR_STATUS_NOT_SUPPORTED`|1.0.1.0| | | |`HIPTENSOR_STATUS_NOT_SUPPORTED`|5.7.0| | | | | +|`CUTENSOR_STATUS_SUCCESS`|1.0.1.0| | | |`HIPTENSOR_STATUS_SUCCESS`|5.7.0| | | | | |`CUTENSOR_WORKSPACE_DEFAULT`|2.0.0.0| | | | | | | | | | |`CUTENSOR_WORKSPACE_MAX`|1.0.1.0| | | |`HIPTENSOR_WORKSPACE_MAX`|5.7.0| | | | | |`CUTENSOR_WORKSPACE_MIN`|1.0.1.0| | | |`HIPTENSOR_WORKSPACE_MIN`|5.7.0| | | | | @@ -113,17 +113,24 @@ |`cutensorAutotuneMode_t`|1.2.0.0| | | | | | | | | | |`cutensorCacheMode_t`|1.2.0.0| | | | | | | | | | |`cutensorDataType_t`|2.0.0.0| | | |`hiptensorComputeType_t`|5.7.0| | | | | +|`cutensorHandle_t`| | | | |`hiptensorHandle_t`| | | | | | |`cutensorJitMode_t`|2.0.0.0| | | | | | | | | | |`cutensorOperationDescriptorAttribute_t`|2.0.0.0| | | | | | | | | | |`cutensorOperator_t`|1.0.1.0| | | |`hiptensorOperator_t`|5.7.0| | | | | |`cutensorPlanAttribute_t`|2.0.0.0| | | | | | | | | | |`cutensorPlanPreferenceAttribute_t`|2.0.0.0| | | | | | | | | | -|`cutensorStatus_t`| | | | |`hiptensorStatus_t`| | | | | | +|`cutensorStatus_t`|1.0.1.0| | | |`hiptensorStatus_t`|5.7.0| | | | | |`cutensorWorksizePreference_t`|1.0.1.0| | | |`hiptensorWorksizePreference_t`|5.7.0| | | | | ## **2. CUTENSOR Function Reference** -Unsupported +|**CUDA**|**A**|**D**|**C**|**R**|**HIP**|**A**|**D**|**C**|**R**|**E**| +|:--|:-:|:-:|:-:|:-:|:--|:-:|:-:|:-:|:-:|:-:| +|`cutensorCreate`|1.7.0.0| | | |`hiptensorCreate`|5.7.0| | | | | +|`cutensorDestroy`|1.7.0.0| | | |`hiptensorDestroy`|5.7.0| | | | | +|`cutensorHandleReadPlanCacheFromFile`|2.0.0.0| | | | | | | | | | +|`cutensorHandleResizePlanCache`|2.0.0.0| | | | | | | | | | +|`cutensorHandleWritePlanCacheToFile`|2.0.0.0| | | | | | | | | | \*A - Added; D - Deprecated; C - Changed; R - Removed; E - Experimental \ No newline at end of file diff --git a/src/CUDA2HIP_TENSOR_API_functions.cpp b/src/CUDA2HIP_TENSOR_API_functions.cpp index bd8f8903..476b7311 100644 --- a/src/CUDA2HIP_TENSOR_API_functions.cpp +++ b/src/CUDA2HIP_TENSOR_API_functions.cpp @@ -23,13 +23,25 @@ THE SOFTWARE. #include "CUDA2HIP.h" const std::map CUDA_TENSOR_FUNCTION_MAP { + {"cutensorCreate", {"hiptensorCreate", "", CONV_LIB_FUNC, API_TENSOR, 2}}, + {"cutensorDestroy", {"hiptensorDestroy", "", CONV_LIB_FUNC, API_TENSOR, 2}}, + {"cutensorHandleResizePlanCache", {"", "", CONV_LIB_FUNC, API_TENSOR, 2, UNSUPPORTED}}, + {"cutensorHandleWritePlanCacheToFile", {"", "", CONV_LIB_FUNC, API_TENSOR, 2, UNSUPPORTED}}, + {"cutensorHandleReadPlanCacheFromFile", {"", "", CONV_LIB_FUNC, API_TENSOR, 2, UNSUPPORTED}}, }; const std::map CUDA_TENSOR_FUNCTION_VER_MAP { + {"cutensorCreate", {CUTENSOR_1700, CUDA_0, CUDA_0 }}, + {"cutensorDestroy", {CUTENSOR_1700, CUDA_0, CUDA_0 }}, + {"cutensorHandleResizePlanCache", {CUTENSOR_2000, CUDA_0, CUDA_0 }}, + {"cutensorHandleWritePlanCacheToFile", {CUTENSOR_2000, CUDA_0, CUDA_0 }}, + {"cutensorHandleReadPlanCacheFromFile", {CUTENSOR_2000, CUDA_0, CUDA_0 }}, }; const std::map HIP_TENSOR_FUNCTION_VER_MAP { + {"hiptensorCreate", {HIP_5070, HIP_0, HIP_0, }}, + {"hiptensorDestroy", {HIP_5070, HIP_0, HIP_0, }}, }; const std::map CUDA_TENSOR_API_SECTION_MAP { diff --git a/src/CUDA2HIP_TENSOR_API_types.cpp b/src/CUDA2HIP_TENSOR_API_types.cpp index 7ea33c23..b2fc119f 100644 --- a/src/CUDA2HIP_TENSOR_API_types.cpp +++ b/src/CUDA2HIP_TENSOR_API_types.cpp @@ -152,6 +152,8 @@ const std::map CUDA_TENSOR_TYPE_NAME_MAP { {"cutensorPlanAttribute_t", {"", "", CONV_TYPE, API_TENSOR, 1, UNSUPPORTED}}, {"CUTENSOR_PLAN_REQUIRED_WORKSPACE", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}}, + {"cutensorHandle_t", {"hiptensorHandle_t", "", CONV_TYPE, API_TENSOR, 1}}, + }; const std::map CUDA_TENSOR_TYPE_NAME_VER_MAP { @@ -218,6 +220,22 @@ const std::map CUDA_TENSOR_TYPE_NAME_VER_MAP { {"CUTENSOR_OP_MAX", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, {"CUTENSOR_OP_MIN", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, {"CUTENSOR_OP_UNKNOWN", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, + {"cutensorStatus_t", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, + {"CUTENSOR_STATUS_SUCCESS", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, + {"CUTENSOR_STATUS_NOT_INITIALIZED", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, + {"CUTENSOR_STATUS_ALLOC_FAILED", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, + {"CUTENSOR_STATUS_INVALID_VALUE", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, + {"CUTENSOR_STATUS_ARCH_MISMATCH", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, + {"CUTENSOR_STATUS_MAPPING_ERROR", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, + {"CUTENSOR_STATUS_EXECUTION_FAILED", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, + {"CUTENSOR_STATUS_INTERNAL_ERROR", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, + {"CUTENSOR_STATUS_NOT_SUPPORTED", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, + {"CUTENSOR_STATUS_LICENSE_ERROR", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, + {"CUTENSOR_STATUS_CUBLAS_ERROR", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, + {"CUTENSOR_STATUS_CUDA_ERROR", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, + {"CUTENSOR_STATUS_INSUFFICIENT_WORKSPACE", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, + {"CUTENSOR_STATUS_INSUFFICIENT_DRIVER", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, + {"CUTENSOR_STATUS_IO_ERROR", {CUTENSOR_1200, CUDA_0, CUDA_0, }}, {"cutensorAlgo_t", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, {"CUTENSOR_ALGO_DEFAULT_PATIENT", {CUTENSOR_1400, CUDA_0, CUDA_0, }}, {"CUTENSOR_ALGO_GETT", {CUTENSOR_1010, CUDA_0, CUDA_0, }}, @@ -279,6 +297,18 @@ const std::map HIP_TENSOR_TYPE_NAME_VER_MAP { {"HIPTENSOR_OP_MAX", {HIP_6030, HIP_0, HIP_0, }}, {"HIPTENSOR_OP_MIN", {HIP_6030, HIP_0, HIP_0, }}, {"HIPTENSOR_OP_UNKNOWN", {HIP_5070, HIP_0, HIP_0, }}, + {"hiptensorStatus_t", {HIP_5070, HIP_0, HIP_0, }}, + {"HIPTENSOR_STATUS_SUCCESS", {HIP_5070, HIP_0, HIP_0, }}, + {"HIPTENSOR_STATUS_NOT_INITIALIZED", {HIP_5070, HIP_0, HIP_0, }}, + {"HIPTENSOR_STATUS_ALLOC_FAILED", {HIP_5070, HIP_0, HIP_0, }}, + {"HIPTENSOR_STATUS_INVALID_VALUE", {HIP_5070, HIP_0, HIP_0, }}, + {"HIPTENSOR_STATUS_ARCH_MISMATCH", {HIP_5070, HIP_0, HIP_0, }}, + {"HIPTENSOR_STATUS_EXECUTION_FAILED", {HIP_5070, HIP_0, HIP_0, }}, + {"HIPTENSOR_STATUS_INTERNAL_ERROR", {HIP_5070, HIP_0, HIP_0, }}, + {"HIPTENSOR_STATUS_NOT_SUPPORTED", {HIP_5070, HIP_0, HIP_0, }}, + {"HIPTENSOR_STATUS_INSUFFICIENT_WORKSPACE", {HIP_5070, HIP_0, HIP_0, }}, + {"HIPTENSOR_STATUS_INSUFFICIENT_DRIVER", {HIP_5070, HIP_0, HIP_0, }}, + {"HIPTENSOR_STATUS_IO_ERROR", {HIP_5070, HIP_0, HIP_0, }}, {"hiptensorAlgo_t", {HIP_5070, HIP_0, HIP_0, }}, {"HIPTENSOR_ALGO_DEFAULT", {HIP_5070, HIP_0, HIP_0, }}, {"HIPTENSOR_ALGO_DEFAULT_PATIENT", {HIP_5070, HIP_0, HIP_0, }}, diff --git a/tests/unit_tests/synthetic/libraries/cutensor2hiptensor.cu b/tests/unit_tests/synthetic/libraries/cutensor2hiptensor.cu index 856457a2..18e58f8d 100644 --- a/tests/unit_tests/synthetic/libraries/cutensor2hiptensor.cu +++ b/tests/unit_tests/synthetic/libraries/cutensor2hiptensor.cu @@ -100,5 +100,23 @@ int main() { cutensorWorksizePreference_t TENSOR_WORKSPACE_RECOMMENDED = CUTENSOR_WORKSPACE_RECOMMENDED; #endif + // CHECK: hiptensorHandle_t handle; + cutensorHandle_t handle; + + //CHECK: hiptensorStatus_t status; + cutensorStatus_t status; + +#if (CUTENSOR_MAJOR == 1 && CUTENSOR_MINOR >= 7) || CUTENSOR_MAJOR >= 2 + // CUDA: cutensorStatus_t cutensorCreate(cutensorHandle_t* handle); + // HIP: hiptensorStatus_t hiptensorCreate(hiptensorHandle_t** handle); + // CHECK: status = hiptensorCreate(&handle); + status = cutensorCreate(&handle); + + // CUDA: cutensorStatus_t cutensorDestroy(cutensorHandle_t handle); + // HIP: hiptensorStatus_t hiptensorDestroy(hiptensorHandle_t* handle); + // CHECK: status = hiptensorDestroy(handle); + status = cutensorDestroy(handle); +#endif + return 0; }