rocm.comgr.hiprtc_header#
2026-09-24
6 min read time
Advanced Micro Devices, Inc.
The hipRTC builtin header, taken from the installed ROCm.
Compiling HIP source with AMD COMGR means supplying the declarations hipRTC
would otherwise supply itself: malloc and free for the device, the
__ocml_* maths entry points, the nan/modf/… wrappers over them.
hipRTC keeps that text inside its builtins library, hiprtc-builtins, which
exports it as a pair of data symbols so its own front end can prepend it.
Reading those symbols gets the same text hipRTC itself would use.
Reading it rather than shipping a copy matters because the text is not portable
between hosts. It is generated by running clang over HIP’s device headers, so
whichever machine generated it froze its own data model into the result: on
Linux size_t comes out as long unsigned int, on Windows as long long
unsigned int. That is not cosmetic. HIP device compilation mirrors the host
target into the device job – the -aux-triple clang receives – so that
host and device agree on the layout of anything passed between them, which
means a Linux-generated copy fed to a Windows compilation declares size_t
as a 32-bit type and contradicts the compilation’s own. ROCm builds the header
per platform and its Windows copy also drops a bitfield union that MSVC layout
rules would size differently, so the installed copy is right by construction
where a shipped one can only be right by luck.
The version follows too: the text always describes the ROCm that is installed, not the one that was current when this package was built.
Nothing is shipped as a fallback. Earlier releases carried a generated
hiprtc_runtime.h, produced by ci/internal/generate-bindings.sh configuring
clr/hipamd and building its hiprtc-builtins target; that step is gone. An
install without the builtins library cannot compile HIP source through COMGR
anyway, since it has no AMD COMGR either – the two arrive together in every
ROCm distribution, and neither is part of the GPU driver.
Attributes#
Functions#
|
Path to the |
|
The header text held by the library at |
|
The hipRTC builtin header text from the installed ROCm. |
The file |
Module Contents#
- rocm.comgr.hiprtc_header.BUILTINS_LIBRARY_SHORTNAME = 'hiprtc-builtins'#
- rocm.comgr.hiprtc_header.HEADER_SYMBOL = '__hipRTC_header'#
- rocm.comgr.hiprtc_header.HEADER_SIZE_SYMBOL = '__hipRTC_header_size'#
- rocm.comgr.hiprtc_header.HEADER_PATH_ENV_VAR = 'HIP_PYTHON_HIPRTC_RUNTIME_HEADER'#
- rocm.comgr.hiprtc_header.find_builtins_library() pathlib.Path | None#
Path to the
hiprtc-builtinslibrary, orNoneif there is none.Noneis a normal outcome: a Windows install that has only the GPU driver ships the HIP runtime without hipRTC.
- rocm.comgr.hiprtc_header.read_header_from_library(library_path) str | None#
The header text held by the library at
library_path.Noneif the library will not load or does not export the symbols; the caller turns that into a message naming the library and the symbols, which is more use than a ctypes error mentioning neither.
- rocm.comgr.hiprtc_header.get_hiprtc_runtime_header() str#
The hipRTC builtin header text from the installed ROCm.
- Raises:
- RuntimeError: if the builtins library cannot be found, will not load, or
does not export the header.
- rocm.comgr.hiprtc_header.get_hiprtc_runtime_header_origin() str#
The file
get_hiprtc_runtime_header()read the text from.