[HIPIFY][8.0][FILE][feature][Linux] Initial support of cuFile to hipFile hipification#2174
[HIPIFY][8.0][FILE][feature][Linux] Initial support of cuFile to hipFile hipification#2174emankov merged 6 commits intoROCm:amd-developfrom
cuFile to hipFile hipification#2174Conversation
| {"CUFILE_ERRSTR", {CUDA_129, CUDA_0, CUDA_0}}, | ||
| {"CUDA_DRV_ERR", {CUDA_129, CUDA_0, CUDA_0}}, | ||
| {"IS_CUDA_ERR", {CUDA_129, CUDA_0, CUDA_0}}, | ||
| }; |
There was a problem hiding this comment.
We just used version placeholders, so this will probably need some fixing.
cuFile to hipFile and rocFile hipification
cuFile to hipFile and rocFile hipificationcuFile to hipFile and rocFile hipification
cuFile to hipFile and rocFile hipificationcuFile to hipFile and rocFile hipification
| const string sHIPFILE = "cuFile_API_supported_by_HIP"; | ||
| const string sHIPFILE_md = sHIPFILE + md_ext; | ||
| const string sHIPFILE_csv = sHIPFILE + csv_ext; | ||
| const string sHIPFILE_and_ROC_md = sHIPFILE + sandROC + md_ext; | ||
| const string sHIPFILE_and_ROC_csv = sHIPFILE + sandROC + csv_ext; | ||
| const string sROCFILE = "cuFile_API_supported_by_ROC"; | ||
| const string sROCFILE_md = sROCFILE + md_ext; | ||
| const string sROCFILE_csv = sROCFILE + csv_ext; | ||
| const string sCUFILE = "cuFile"; |
There was a problem hiding this comment.
| const string sHIPFILE = "cuFile_API_supported_by_HIP"; | |
| const string sHIPFILE_md = sHIPFILE + md_ext; | |
| const string sHIPFILE_csv = sHIPFILE + csv_ext; | |
| const string sHIPFILE_and_ROC_md = sHIPFILE + sandROC + md_ext; | |
| const string sHIPFILE_and_ROC_csv = sHIPFILE + sandROC + csv_ext; | |
| const string sROCFILE = "cuFile_API_supported_by_ROC"; | |
| const string sROCFILE_md = sROCFILE + md_ext; | |
| const string sROCFILE_csv = sROCFILE + csv_ext; | |
| const string sCUFILE = "cuFile"; | |
| const string sHIPFILE = "cuFile_API_supported_by_HIP"; |
Could we keep same format as before?
There was a problem hiding this comment.
How is the format different? I think I just copied one of the other libraries that has both hip and roc flavors (perhaps hipSolver/rocSover) because we have both hipFile and rocFile and would like to support both.
There was a problem hiding this comment.
I guess the request was to keep the existing formatting.
There was a problem hiding this comment.
How is the format different? I think I just copied one of the other libraries that has both hip and roc flavors (perhaps hipSolver/rocSover) because we have both hipFile and rocFile and would like to support both.
| const string sHIPFILE = "cuFile_API_supported_by_HIP"; | |
| const string sHIPFILE_md = sHIPFILE + md_ext; | |
| const string sHIPFILE_csv = sHIPFILE + csv_ext; | |
| const string sHIPFILE_and_ROC_md = sHIPFILE + sandROC + md_ext; | |
| const string sHIPFILE_and_ROC_csv = sHIPFILE + sandROC + csv_ext; | |
| const string sROCFILE = "cuFile_API_supported_by_ROC"; | |
| const string sROCFILE_md = sROCFILE + md_ext; | |
| const string sROCFILE_csv = sROCFILE + csv_ext; | |
| const string sCUFILE = "cuFile"; | |
| const string sHIPFILE = "cuFile_API_supported_by_HIP"; |
I meant to use existing format.
There was a problem hiding this comment.
Is this all okay now?
|
@derobins, could you please let us know the first CUDA version in which gds-nvidia-fs (with cuFile in it) appeared in the CUDA Toolkit Linux distribution? |
It looks like cuFile was released with CUDA 11.4.0. I don't see a cuFile section in the 11.3.x docs. It's confusing, though - 11.3 and 11.2 mention the library and header file in the list of things that are included, but there's no API documentation. Maybe the answer is 11.2? https://docs.nvidia.com/cuda/archive/11.4.0/cufile-api/index.html We'll have to grab header files from the various CUDA releases to see how the API has evolved and when new API calls were introduced. |
|
@derobins, I'll detect the former versions in the fs releases a bit later. |
84a81c0 to
5d5cd1d
Compare
cuFile to hipFile and rocFile hipificationcuFile to hipFile hipification
src/CUDA2HIP_FILE_API_functions.cpp
Outdated
| }; | ||
|
|
||
| const std::map<llvm::StringRef, hipAPIChangedVersions> HIP_FILE_FUNCTION_CHANGED_VER_MAP { | ||
| {"hipFileHandleRegister", {HIP_0}}, |
There was a problem hiding this comment.
{HIP_8000, HIP_0, HIP_0, HIP_8000}},,
or
{HIP_7000, HIP_0, HIP_0}},,
if hipFile were really shipped with HIP 7.0.0
There was a problem hiding this comment.
HIP_8000 is probably the right value, but the enum stops at HIP_7020 and I don't see any HIPIFY branches that look like they are prep for ROCm 8.0.
These have been removed from hipFile and/or will not be hipified.
There was a problem hiding this comment.
Pull request overview
This pull request adds initial support for hipifying NVIDIA's cuFile API to AMD's hipFile API. This enables automatic conversion of GPU Direct Storage code from CUDA to HIP, allowing applications that use cuFile for fast data transfers between storage and GPU memory to be ported to ROCm.
Changes:
- Adds new
API_FILEenum type to categorize cuFile/hipFile API calls in the hipification system - Implements comprehensive type and function mappings between cuFile and hipFile APIs (129 types, 36 functions)
- Integrates cuFile support into the documentation generation system
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Statistics.h | Adds API_FILE enum value for cuFile API categorization |
| src/Statistics.cpp | Updates API name and type arrays with "cuFile API" and adds API_FILE to ROC translation logic |
| src/HipifyAction.h | Adds insertedFILEHeader flag to track hipfile.h header insertion |
| src/HipifyAction.cpp | Implements header insertion logic for API_FILE in the Exclude function |
| src/CUDA2HIP_FILE_API_types.cpp | New file defining 129 type mappings from cuFile to hipFile with CUDA 12.9+ and HIP 7.0+ version information |
| src/CUDA2HIP_FILE_API_functions.cpp | New file defining 36 function mappings from cuFile to hipFile with version tracking |
| src/CUDA2HIP_Doc.cpp | Adds HIPFILE documentation class and integrates it into the documentation generation pipeline |
| src/CUDA2HIP.h | Declares extern maps for cuFile type and function mappings, plus version tracking maps |
| src/CUDA2HIP.cpp | Registers cuFile maps in the unified rename and version tracking systems, adds cufile.h to hipfile.h include mapping |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| extern const std::map<llvm::StringRef, hipCounter> CUDA_TENSOR_FUNCTION_MAP; | ||
| // Maps the names of cuFile API types to the corresponding HIP types | ||
| extern const std::map<llvm::StringRef, hipCounter> CUDA_FILE_TYPE_NAME_MAP; | ||
| // Maps the names of cuFile API functions to the corresponding HIP types |
There was a problem hiding this comment.
The comment incorrectly states "to the corresponding HIP types" but this is the CUDA_FILE_FUNCTION_MAP which maps to HIP functions. The comment should read "Maps the names of cuFile API functions to the corresponding HIP functions" to be consistent with other function map comments in this file (e.g., lines 86-87, 90-91).
| // Maps the names of cuFile API functions to the corresponding HIP types | |
| // Maps the names of cuFile API functions to the corresponding HIP functions |
| {"CUfileFileHandleType", {CUDA_129, CUDA_0, CUDA_0}}, | ||
| {"CUfileDrvProps_t", {CUDA_129, CUDA_0, CUDA_0}}, | ||
| {"cufileRDMAInfo_t", {CUDA_129, CUDA_0, CUDA_0}}, | ||
| {"cufileFSOps_t", {CUDA_129, CUDA_0, CUDA_0}}, |
There was a problem hiding this comment.
The key name 'cufileFSOps_t' (lowercase 'u') in CUDA_FILE_TYPE_NAME_VER_MAP does not match the key 'CUfileFSOps_t' (uppercase 'U') used in CUDA_FILE_TYPE_NAME_MAP at line 12. This inconsistency will cause the version mapping to fail for this type. The key should be 'CUfileFSOps_t' to match the main mapping.
| {"cufileFSOps_t", {CUDA_129, CUDA_0, CUDA_0}}, | |
| {"CUfileFSOps_t", {CUDA_129, CUDA_0, CUDA_0}}, |
| {"CUfileIOParams_t", {CUDA_129, CUDA_0, CUDA_0}}, | ||
| {"CUfileIOEvents_t", {CUDA_129, CUDA_0, CUDA_0}}, | ||
| {"CUfileBatchHandle_t", {CUDA_129, CUDA_0, CUDA_0}}, | ||
| {"CUfileBatchMode_t", {CUDA_129, CUDA_0, CUDA_0}}, |
There was a problem hiding this comment.
The mapping for 'CUfileOpcode_t' and 'CUfileStatus_t' are missing from CUDA_FILE_TYPE_NAME_VER_MAP. These types are present in CUDA_FILE_TYPE_NAME_MAP (lines 17-18) and HIP_FILE_TYPE_NAME_VER_MAP (lines 284-285), but absent here. Add version entries for both types with CUDA_129 as the appeared version.
| {"CUfileBatchMode_t", {CUDA_129, CUDA_0, CUDA_0}}, | |
| {"CUfileBatchMode_t", {CUDA_129, CUDA_0, CUDA_0}}, | |
| {"CUfileOpcode_t", {CUDA_129, CUDA_0, CUDA_0}}, | |
| {"CUfileStatus_t", {CUDA_129, CUDA_0, CUDA_0}}, |
| {"CU_FILE_SCALEFLUX_CSD_SUPPORTED", {"hipFileScaleFluxCSDSupported", "", CONV_NUMERIC_LITERAL, API_FILE, 1, FULL}}, | ||
| {"CU_FILE_NVMESH_SUPPORTED", {"hipFileNVMeshSupported", "", CONV_NUMERIC_LITERAL, API_FILE, 1, FULL}}, | ||
| {"CU_FILE_BEEGFS_SUPPORTED", {"hipFileBEEGFSSupported", "", CONV_NUMERIC_LITERAL, API_FILE, 1, FULL}}, | ||
| {"CU_FILE_NVME_P2P_SUPPORTED", {"hipFileNVMeP2PSsupported", "", CONV_NUMERIC_LITERAL, API_FILE, 1, FULL}}, |
There was a problem hiding this comment.
The hipified name 'hipFileNVMeP2PSsupported' has inconsistent capitalization with a double 'S' - 'P2PSsupported' instead of 'P2PSupported'. This breaks the naming convention where 'Supported' should start with a capital 'S'. This should be 'hipFileNVMeP2PSupported' to match the pattern used for all other 'Supported' suffixes in this file.
| {"CU_FILE_NVME_P2P_SUPPORTED", {"hipFileNVMeP2PSsupported", "", CONV_NUMERIC_LITERAL, API_FILE, 1, FULL}}, | |
| {"CU_FILE_NVME_P2P_SUPPORTED", {"hipFileNVMeP2PSupported", "", CONV_NUMERIC_LITERAL, API_FILE, 1, FULL}}, |
| {"hipFileScaleFluxCSDSupported", {HIP_7000, HIP_0, HIP_0}}, | ||
| {"hipFileNVMeshSupported", {HIP_7000, HIP_0, HIP_0}}, | ||
| {"hipFileBEEGFSSupported", {HIP_7000, HIP_0, HIP_0}}, | ||
| {"hipFileNVMeP2PSsupported", {HIP_7000, HIP_0, HIP_0}}, |
There was a problem hiding this comment.
The hipified name 'hipFileNVMeP2PSsupported' has inconsistent capitalization with a double 'S'. This entry should use 'hipFileNVMeP2PSupported' to be consistent with the corrected naming convention.
| {"hipFileNVMeP2PSsupported", {HIP_7000, HIP_0, HIP_0}}, | |
| {"hipFileNVMeP2PSupported", {HIP_7000, HIP_0, HIP_0}}, |
| {"cuFileSetParameterString", {CUDA_0}}, | ||
| }; | ||
|
|
||
| const std::map<llvm::StringRef, hipAPIChangedVersions> HIP_FILE_FUNCTION_CHANGED_VER_MAP { |
There was a problem hiding this comment.
The function 'hipFileOpStatusError' is missing from HIP_FILE_FUNCTION_CHANGED_VER_MAP. This function is present in CUDA_FILE_FUNCTION_MAP (line 5), HIP_FILE_FUNCTION_VER_MAP (line 40), and CUDA_FILE_FUNCTION_CHANGED_VER_MAP (line 107). Add an entry with HIP_7000 to maintain consistency across all version maps.
| const std::map<llvm::StringRef, hipAPIChangedVersions> HIP_FILE_FUNCTION_CHANGED_VER_MAP { | |
| const std::map<llvm::StringRef, hipAPIChangedVersions> HIP_FILE_FUNCTION_CHANGED_VER_MAP { | |
| {"hipFileOpStatusError", {HIP_7000}}, |
| @@ -0,0 +1,396 @@ | |||
| #include "CUDA2HIP.h" | |||
There was a problem hiding this comment.
This file is missing the standard copyright header that is present in all other similar source files in the codebase. Add an MIT license copyright header with "Copyright (c) 2025 - present Advanced Micro Devices, Inc. All rights reserved." at the beginning of the file, consistent with the pattern used in files like CUDA2HIP_TENSOR_API_types.cpp.
| @@ -0,0 +1,175 @@ | |||
| #include "CUDA2HIP.h" | |||
There was a problem hiding this comment.
This file is missing the standard copyright header that is present in all other similar source files in the codebase. Add an MIT license copyright header with "Copyright (c) 2025 - present Advanced Micro Devices, Inc. All rights reserved." at the beginning of the file, consistent with the pattern used in other API function files.
emankov
left a comment
There was a problem hiding this comment.
LGTM, tests, versioning, and documentation changes will come in separate changes.
Do not upstream
… `CU_FILE_CUDA_ERR` + Updated the regenerated `hipify-perl` and `File` `CUDA2HIP` docs accordingly
AIROCFILE-7
AIROCFILE-15
Adds types and API calls from ROCm/hipFile: