rocm.hipfile#
2026-09-24
7 min read time
Advanced Micro Devices, Inc.
High-level Pythonic interface to the hipFile (Accelerated I/O Storage) library.
This sub-package wraps the lower-level hipfile
auto-generated bindings with idiomatic Python classes:
Driver— context manager for the hipFile driver lifecycle.FileHandle— context manager for an open + registered file.Buffer— context manager for a registered GPU memory region.
plus the mirrored enums (OpError,
FileHandleType), the HipFileException type, and
the standalone driver_get_properties /
get_version helpers.
The complete copy-via-GPU-memory example lives in
examples/0_Basic_Usage/hipfile_copy.py.
Submodules#
Exceptions#
Exception raised on a non-success hipFile error. |
Classes#
Lifecycle manager for a hipFile-registered GPU memory region. |
|
Lifecycle manager for the hipFile driver. |
|
Python enum mirroring |
|
Python enum mirroring |
|
Lifecycle manager for a hipFile-registered open file. |
Functions#
Return the driver properties struct as set by |
|
Return |
Package Contents#
- class rocm.hipfile.Buffer(buffer_ptr, length, flags)#
Lifecycle manager for a hipFile-registered GPU memory region.
The caller pre-allocates the underlying device buffer (typically via
hipMallocor any equivalent GPU-allocator) and constructs aBufferto register it with the hipFile driver. Deregistration happens on context exit (or via explicitderegister).Use as a context manager:
- with Buffer(ptr, length, flags=0) as registered_buf:
…
- classmethod from_ctypes_void_p(ctypes_void_p: ctypes.c_void_p, length, flags)#
Construct a
Bufferfrom actypes.c_void_p.
- property ptr#
- deregister()#
- register()#
- class rocm.hipfile.Driver#
Lifecycle manager for the hipFile driver.
Each instance brackets one
hipFileDriverOpen/hipFileDriverClosepair. The driver is reference-counted by the library; multipleDriverinstances coexist safely.Use as a context manager:
- with Driver():
…
or call
open/closeexplicitly.- static use_count()#
Return the current driver reference count.
- close()#
- open()#
- class rocm.hipfile.FileHandleType#
Bases:
enum.IntEnumPython enum mirroring
hipFileFileHandleType_twith friendly names.- OPAQUE_FD#
- OPAQUE_WIN32#
- USERSPACE_FS#
- class rocm.hipfile.OpError#
Bases:
enum.IntEnumPython enum mirroring
hipFileOpError_twith upstream-friendly names.- SUCCESS#
- DRIVER_NOT_INITIALIZED#
- DRIVER_INVALID_PROPS#
- DRIVER_UNSUPPORTED_LIMIT#
- DRIVER_VERSION_MISMATCH#
- DRIVER_VERSION_READ_ERROR#
- DRIVER_CLOSING#
- PLATFORM_NOT_SUPPORTED#
- IO_NOT_SUPPORTED#
- DEVICE_NOT_SUPPORTED#
- DRIVER_ERROR#
- HIP_DRIVER_ERROR#
- HIP_POINTER_INVALID#
- HIP_MEMORY_TYPE_INVALID#
- HIP_POINTER_RANGE_ERROR#
- HIP_CONTEXT_MISMATCH#
- INVALID_MAPPING_SIZE#
- INVALID_MAPPING_RANGE#
- INVALID_FILE_TYPE#
- INVALID_FILE_OPEN_FLAG#
- DIO_NOT_SET#
- INVALID_VALUE#
- MEMORY_ALREADY_REGISTERED#
- MEMORY_NOT_REGISTERED#
- PERMISSION_DENIED#
- DRIVER_ALREADY_OPEN#
- HANDLE_NOT_REGISTERED#
- HANDLE_ALREADY_REGISTERED#
- DEVICE_NOT_FOUND#
- INTERNAL_ERROR#
- GET_NEW_FD_FAILED#
- DRIVER_SETUP_ERROR#
- IO_DISABLED#
- BATCH_SUBMIT_FAILED#
- GPU_MEMORY_PINNING_FAILED#
- BATCH_FULL#
- ASYNC_NOT_SUPPORTED#
- IO_MAX_ERROR#
- exception rocm.hipfile.HipFileException(hipfile_err, hip_err)#
Bases:
ExceptionException raised on a non-success hipFile error.
Carries both the hipFile-level error code (
hipfile_err) and the underlying HIP driver error (hip_err) when the former isOpError.HIP_DRIVER_ERROR.- property hipfile_err#
- property hip_err#
- class rocm.hipfile.FileHandle(path, flags, mode=DEFAULT_MODE, handle_type=FileHandleType.OPAQUE_FD)#
Lifecycle manager for a hipFile-registered open file.
Wraps
hipFileHandleRegister/hipFileHandleDeregisterplus synchronoushipFileRead/hipFileWrite.Use as a context manager:
- with FileHandle(path, os.O_RDWR | os.O_DIRECT) as fh:
fh.read(buf, size, file_offset, buffer_offset) fh.write(buf, size, file_offset, buffer_offset)
- DEFAULT_MODE = 420#
- property handle_type#
- property flags#
- property handle#
- property mode#
- property path#
- open()#
- close()#
- read(buffer, size, file_offset, buffer_offset)#
Synchronous read into a registered
Buffer.Returns the number of bytes read on success. Raises
HipFileException(with the parsedOpErrorand HIP driver error) on a hipFile-level error, orOSError(with the realerrno) on a POSIX-level error.
- rocm.hipfile.driver_get_properties()#
Return the driver properties struct as set by
hipFileDriverGetProperties.
- rocm.hipfile.get_version()#
Return
(major, minor, patch)for the loaded libhipfile.so.