pub struct OpCache { /* private fields */ }Expand description
2026-09-25: Memoized kernel handles and scratch allocations for one backend.
Implementations§
Source§impl OpCache
impl OpCache
pub fn new() -> Self
Sourcepub fn record_n_tile(&self, kernel: KernelHandle, n_tile: u32)
pub fn record_n_tile(&self, kernel: KernelHandle, n_tile: u32)
2026-09-29: Record the N tile kernel publishes; a later value for the same
handle replaces it.
Sourcepub fn n_tile(&self, kernel: KernelHandle) -> Option<u32>
pub fn n_tile(&self, kernel: KernelHandle) -> Option<u32>
2026-09-29: The N tile recorded for kernel, or None when it publishes none.
Sourcepub fn record_a_e4m3(&self, kernel: KernelHandle)
pub fn record_a_e4m3(&self, kernel: KernelHandle)
2026-09-29: Record that kernel casts its A operand to E4M3 with no scale.
Sourcepub fn a_e4m3(&self, kernel: KernelHandle) -> bool
pub fn a_e4m3(&self, kernel: KernelHandle) -> bool
2026-09-29: Whether kernel was recorded as casting its A operand to E4M3.
Sourcepub fn kernel(
&self,
gpu: &dyn GpuBackend,
module: &'static str,
func: &'static str,
) -> Result<KernelHandle>
pub fn kernel( &self, gpu: &dyn GpuBackend, module: &'static str, func: &'static str, ) -> Result<KernelHandle>
2026-09-25: Resolve module::func, memoized: gpu.kernel(..) on a miss, a
map read on a hit.
Sourcepub fn scratch(
&self,
gpu: &dyn GpuBackend,
tag: &'static str,
bytes: usize,
) -> Result<DevicePtr>
pub fn scratch( &self, gpu: &dyn GpuBackend, tag: &'static str, bytes: usize, ) -> Result<DevicePtr>
2026-09-25: A scratch allocation of at least bytes, memoized under tag.
Grow-only: a larger request allocates a new buffer and drops the old pointer
from the cache without freeing it. On the CUDA backend the old buffer stays
on the allocation ledger until sweep_unreleased frees it when the backend
drops.
Sourcepub fn alloc_fell_back(&self) -> bool
pub fn alloc_fell_back(&self) -> bool
2026-09-25: Whether a loader latched the managed-memory fallback on this backend. The latch is per backend, so the next model’s load tries device memory again.
Sourcepub fn note_alloc_fallback(&self)
pub fn note_alloc_fallback(&self)
2026-09-25: Latch the managed-memory fallback for the rest of this backend’s life.
Sourcepub fn first_n(&self, key: &'static str, n: u32) -> bool
pub fn first_n(&self, key: &'static str, n: u32) -> bool
2026-09-25: true for the first n times this backend reaches key.
Counted per backend, so a second model reports its own.
Trait Implementations§
Source§impl ModelResource<dyn GpuBackend> for OpCache
2026-09-25: Frees every scratch allocation and empties the scratch map.
impl ModelResource<dyn GpuBackend> for OpCache
2026-09-25: Frees every scratch allocation and empties the scratch map.
Kernel handles need no release here: they point into the modules of the
backend’s MetraleRegistry, which unloads them when it is dropped or passed
to cuda_host::release.