rocm-rt
Safe ROCm wrappers around rocm-sys, using rocm-build to find available libraries.
Disclaimer
This project is not affiliated with, endorsed by, or sponsored by Advanced Micro Devices, Inc. (AMD).
ROCm and AMD are trademarks of Advanced Micro Devices, Inc.
Usage
This API is very limited and only covers a small subset of HIP and hipRTC, but no Linear Algebra libraries (hipBLAS, rocFFT, rocSOLVER, etc.).
The example shown below compiles and launches a simple program:
use transmute;
use ;
const SRC: &str = r#"
extern "C" __global__
void vec_add(float* out, const float* a, const float* b, int n) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n) out[i] = a[i] + b[i];
}
"#;
const LEN: usize = 1024;
const BYTES: u32 = as u32;
const A_VAL: f32 = 3.0;
const B_VAL: f32 = 2.0;
let dev = current.unwrap;
let arch = dev.gfx_version.unwrap;
let opts = CompileOptions ;
let func = ;
let stream = create.unwrap;
let out = stream.alloc.unwrap;
let a = stream.alloc.unwrap;
let b = stream.alloc.unwrap;
let a_host = ;
let b_host = ;
a.copy_from_host_async.unwrap;
b.copy_from_host_async.unwrap;
let mut out_ptr = out.as_ptr;
let mut a_ptr = a.as_ptr;
let mut b_ptr = b.as_ptr;
let mut n = LEN as i32;
let mut args = ;
let conf = LaunchConfig ;
unsafe
let out_host = stream.alloc_host.unwrap;
stream.sync.unwrap;
out.copy_to_host.unwrap;
for chunk in out_host.as_slice.chunks