[HIP] add synchronize + vram_used profiling bindings (hipDeviceSynchronize / hipMemGetInfo) for batched-forward phase + VRAM instrumentation
This commit is contained in:
1 parent
c059a20aa9
commit
66a40631ee
2 files changed
+32
No files matched your search
@@ -31,6 +31,8 @@ mod ffi {
|
||||
pub fn vetta_buf_d2h(dst: *mut c_void, src: *const c_void, bytes: usize) -> c_int;
|
||||
pub fn vetta_buf_copy(dst: *mut c_void, src: *const c_void, bytes: usize) -> c_int;
|
||||
pub fn vetta_buf_copy2d(dst: *mut c_void, dpitch: usize, src: *const c_void, spitch: usize, width: usize, height: usize) -> c_int;
|
||||
pub fn vetta_synchronize() -> c_int;
|
||||
pub fn vetta_vram_used(out: *mut usize) -> c_int;
|
||||
pub fn vetta_rms_norm_f32(
|
||||
x: *const c_float, w: *const c_float, y: *mut c_float,
|
||||
rows: c_int, d: c_int, eps: c_float, stream: *mut c_void,
|
||||
@@ -210,6 +212,23 @@ pub fn set_buf_pool_enabled(on: bool) {
|
||||
POOL_ENABLED.store(on, std::sync::atomic::Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// Block until all queued GPU work completes. Used at profiling phase boundaries
|
||||
/// (the batched forward is fully async otherwise); not on the hot path.
|
||||
#[cfg(feature = "hip")]
|
||||
pub fn synchronize() -> Result<(), String> {
|
||||
let rc = unsafe { ffi::vetta_synchronize() };
|
||||
if rc != 0 { return Err("hipDeviceSynchronize failed".into()); }
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// VRAM used bytes (total - free via hipMemGetInfo), for allocation profiling.
|
||||
#[cfg(feature = "hip")]
|
||||
pub fn vram_used() -> usize {
|
||||
let mut used = 0usize;
|
||||
unsafe { ffi::vetta_vram_used(&mut used) };
|
||||
used
|
||||
}
|
||||
|
||||
#[cfg(feature = "hip")]
|
||||
fn pool_enabled() -> bool {
|
||||
POOL_ENABLED.load(std::sync::atomic::Ordering::Relaxed)
|
||||
|
||||
Reference in new issue
Block a user