This repository contains Rust bindings for AMD ROCm HIP runtime libraries (hiprtc, amdhip64) used by CubeCL.
These bindings are unsafe as they are just the raw bindings generated by bindgen with no improvements.
- Works only on Linux
- Bindings generated for AMD GPUs only
Install ROCm following the ROCm documentation:
The crates in this repository follow the same versioning as HIP. Note that HIP version is somewhat different than ROCm version. The patch number of HIP version is a monotonic number that uniquely indentify the version of HIP.
Moreover we concatenate two additional digits to the HIP patch version in order to be able to release fixes for the same HIP patch number.
For instance 6.4.4348200
represents the first release of the bindings for HIP 43482
of ROCm 6.4.x
and 6.4.4348201
represents the second release for these same bindings.
This versioning scheme is in place as of May 2025, any previous version of this crate followed a different versioning scheme based on ROCm version instead of HIP.
Note also that multiple versions of ROCm can ship the same version of HIP.
Add the crate cubecl-hip-sys to the Cargo.toml
file of your project. If no feature is set then cargo will select the HIP
version returned by the hipconfig
utility.
To specify a different version of HIP manually set the environment variable HIP_PATH to a valid HIP installation path. You can
verify that your system points to the expected version with the command hipconfig --version
.
Remark: Don't set manually the hip_xxx
feature for this crate. This is the responsibility of the build.rs
script to set it
accordingly to your hipconfig
output.
Here is the table of currently available bindings:
HIP Version | ROCm Version Range |
---|---|
41134 | 6.2.2~6.2.4 |
42131 | 6.3.0 |
42133 | 6.3.1 |
42134 | 6.3.2~6.3.4 |
43482 | 6.4.0 |
To run tests you need to first meet the expectations for Prerequisites
section.
Then execute the following xtask command:
# test ROCm bindings againt the system default ROCm installation if found
cargo xtask test
# test a specific version that is not the default by providing a value for HIP_PATH using -p
xtask test -p /opt/rocm-6.3.0
-
To generate the bindings you first need to meet the expectations for
Prerequisites
section. -
Make sure that
hipconfig
returns the path of the HIP version you want to wrap. Adapt theHIP_PATH
environment variable to point to the version you are interested in. -
Generate the bindings using the dedicated xtask command
bindgen
:
cargo xtask bindgen
- Declare a new
hip
feature in theCargo.toml
incubecl-hip-sys
crate with the formathip_<patch_version>
. You can retrieve the patch version with the commandhipconfig --version
. For instance for a new HIP patch version which is42131
add the following feature:
[features]
hip_42131 = []
- Add the generated bindings module to the file
crates/cubecl-hip-sys/src/bindings/mod.rs
conditionally to the new feature you just declared as well as the re-exports:
#[cfg(feature = "hip_42131")]
mod bindings_42131;
#[cfg(feature = "hip_42131")]
pub use bindings_42131::*;
-
Run the tests as explain in the previous section.
-
Open a pull request with the modifications, do not forget to add the new generated bindings file in the
crates/cubecl-hip-sys/src/bindings/
directory. -
Note that the CI runner might need to be updated by an administrator so that the new HIP version is available on the runner.