HIPIFY
repository·amd-develop·Indexed 20 days ago
https://github.com/rocm/hipifyA suite of tools for the automatic translation of CUDA source code into portable HIP C++, facilitating migration to the ROCm ecosystem. It includes hipify-clang for API translation and documentation generation, hipify-perl for conversion, and various utility scripts for locating CUDA/HIP source and header files, performing in-place conversions, and generating conversion statistics.
What's inside rocm-hipify
- HIPIFY is a suite of tools designed to automatically translate CUDA source code into portable HIP C++. This allows developers to migrate existing CUDA-based workloads to the ROCm platform.
Overview of HIPIFY tools
amd-developHIPIFY is a ROCm toolset designed to automate the translation of NVIDIA CUDA source code into portable HIP C++ for use on AMD GPUs. It provides two primary tools depending on the complexity of the translation required:
hipify-clang: A robust, clang-based tool that parses CUDA code to handle syntax changes, API calls, and kernel launch differences. It provides higher fidelity through code parsing.hipify-perl: A simpler tool that uses text replacement to swap CUDA API calls with HIP equivalents. It is suitable for basic translation needs but offers less error detection than the clang-based version.
Note on
hipify_torch: For PyTorch-specific requirements,hipify_torchis a related independent utility developed for translating CUDA code into portable HIP C++.Understand CURAND API support mapping for HIP and ROCm
amd-developWhen hipifying CUDA code that uses the
cuRANDlibrary, you can map CUDA CURAND types and functions to their HIP (hipRAND) or ROCm (rocRAND) equivalents.Use the following legend to interpret the support tables:
- A: Added
- D: Deprecated
- C: Changed
- R: Removed
- U: Unsupported for specific CUDA version(s)
- E: Experimental
Limitations and manual steps in CUDA to HIP migration
amd-developWhile HIPIFY automates many aspects of migration, it is not a seamless 1:1 replacement.
What is automatically converted:
- CUDA runtime API calls
- Kernel launch syntax
- Standard CUDA library functions (where a HIP equivalent exists)
- Specific keywords like
__global__and__device__
What requires manual intervention:
- Unsupported Libraries: CUDA libraries or third-party libraries without HIP equivalents cannot be automatically translated.
- Performance Optimization: Code optimized specifically for NVIDIA GPUs may require manual rework to achieve optimal performance on AMD GPUs.
Recommended Post-Migration Workflow:
- Code Review: Verify functional correctness of the translated code.
- Library Replacement: Replace any unsupported libraries or constructs with HIP or ROCm features.
- Debug and Test: Run the new HIP program to ensure it behaves as expected.
- Optimize: Perform performance tuning specifically for the target AMD hardware.
Understand CUSOLVER to HIPAPI mapping status
amd-developWhen hipifying CUDA code that uses CUSOLVER, use the following legend to interpret the compatibility tables to determine if a specific data type or function has a direct HIP equivalent and what its status is:
- A: Added
- D: Deprecated
- C: Changed
- R: Removed
- U: Unsupported for specific CUDA version(s)
- E: Experimental
Understand the CUDNN API support status indicators in MIOpen
amd-developWhen reviewing the tables of CUDNN APIs supported by MIOpen, specific single-letter codes are used to indicate the status and compatibility of each API. Use these markers to determine if an API is safe to use, if it has changed, or if it is unsupported in your current environment:
- A: Added
- D: Deprecated
- C: Changed
- R: Removed
- U: Unsupported for specific CUDA version(s)
- E: Experimental
Understand CUB API support status in HIP
amd-developWhen hipifying CUDA code that uses the CUB library, you can check the compatibility of specific CUB data types and macros with
hipCUB. The support status is tracked using specific indicators in the compatibility tables.Status Indicators:
- A: Added
- D: Deprecated
- C: Changed
- R: Removed
- U: Unsupported for specific CUDA version(s)
- E: Experimental
Understand CUBLAS to hipBLAS API mapping
amd-developWhen hipifying CUDA code that uses the cuBLAS library, many constants, types, and enums are mapped to their
hipBLASequivalents. Use the following legend to interpret the support tables:- A: Added
- D: Deprecated
- C: Changed
- R: Removed
- U: Unsupported for specific CUDA version(s)
- E: Experimental
For example,
CUBLAS_STATUS_SUCCESSmaps toHIPBLAS_STATUS_SUCCESS(Added in HIP 1.8.2).Understand CURAND to ROCm API mapping conventions
amd-developWhen reviewing the CURAND API support tables for hipification, the following column markers are used to indicate the status of CUDA APIs in the ROCm (ROC) implementation:
- A: Added
- D: Deprecated
- C: Changed
- R: Removed
- U: Unsupported for specific CUDA version(s)
- E: Experimental
Understand CUSOLVER API support in ROCm
amd-developWhen hipifying CUDA code, you can use this reference to check which
CUSOLVERdata types and functions have corresponding support in ROCm (rocSOLVER/rocBLAS).Key for support status columns:
- A: Added
- D: Deprecated
- C: Changed
- R: Removed
- U: Unsupported for specific CUDA versions
- E: Experimental
If a CUDA type or function is listed with a ROCm equivalent, the table provides the corresponding ROCm token and the version in which it was introduced.
Map CUDA Driver API Data Types to HIP
amd-developWhen hipifying CUDA Driver API code, many CUDA data types and enums have direct equivalents in HIP. This mapping is essential for ensuring compatibility when porting low-level driver calls.
Common mappings include:
- Graph API:
CUgraph_stmaps toihipGraph,CUgraphNodetohipGraphNode_t, andCUgraphNodeTypetohipGraphNodeType. - Memory Management:
CUmemAllocationPropmaps tohipMemAllocationProp,CUmemPoolPropstohipMemPoolProps, andCUmem_advisetohipMemoryAdvise. - Kernel & Launch:
CUkernelmaps tohipKernel_tandCUlaunchConfigmaps toHIP_LAUNCH_CONFIG. - Modules & Libraries:
CUmodulemaps tohipModule_tandCUlibrarymaps tohipLibrary_t. - Error Handling:
CUresultmaps tohipError_t.
- Graph API:
Understand CUBLAS API support mapping for HIP and ROCm
amd-developWhen hipifying CUDA code, you can use this reference to map
cuBLAStypes and constants to theirhipBLAS(HIP) orrocBLAS(ROCm) equivalents.Mapping Legend:
- A: Added
- D: Deprecated
- C: Changed
- R: Removed
- U: Unsupported for specific CUDA versions
- E: Experimental
This table helps identify which CUDA features have direct equivalents in the HIP and ROCm ecosystems and which versions of the libraries introduced them.