pub struct ModuleBinaryCache { /* private fields */ }Expand description
An in-memory cache mapping (SPIR-V, build flags) to compiled native
binaries, with hit/miss accounting.
A backend looks up a key before calling zeModuleCreate; on a miss it JITs
the SPIR-V, retrieves the native binary, and inserts it so
later identical modules skip the JIT. The cache is the host-side half of
zeModuleGetNativeBinary persistence — serialising the map to disk (a
trivial extension) gives cross-run reuse.
Implementations§
Source§impl ModuleBinaryCache
impl ModuleBinaryCache
Sourcepub fn lookup(
&mut self,
spirv: &[u32],
build_flags: &str,
) -> Option<&NativeBinary>
pub fn lookup( &mut self, spirv: &[u32], build_flags: &str, ) -> Option<&NativeBinary>
Look up a compiled binary for spirv + build_flags, recording a
hit or miss. Returns None on a miss (the caller must JIT and insert).
Sourcepub fn insert(&mut self, spirv: &[u32], binary: NativeBinary) -> u64
pub fn insert(&mut self, spirv: &[u32], binary: NativeBinary) -> u64
Insert a compiled native binary for spirv, returning its cache key.
The binary’s own build_flags are folded into the key so two builds of
the same SPIR-V with different flags do not collide.
Sourcepub fn get(&self, key: u64) -> Option<&NativeBinary>
pub fn get(&self, key: u64) -> Option<&NativeBinary>
Fetch a binary by its precomputed key without affecting statistics.
Sourcepub fn total_bytes(&self) -> usize
pub fn total_bytes(&self) -> usize
Total bytes occupied by all cached native binaries.