pub struct NvrtcCache { /* private fields */ }Expand description
Read-through disk cache for compiled NVRTC kernels.
Cross-process safe: writes go to a temp file and are atomically
renamed into place. Reads tolerate concurrent writers (a partial
.tmp is invisible to readers; a corrupt .bin returns None).
Implementations§
Source§impl NvrtcCache
impl NvrtcCache
Sourcepub fn new() -> Result<Self, GpuError>
pub fn new() -> Result<Self, GpuError>
Construct a cache rooted at the OS-default location.
Probe order:
$XDG_CACHE_HOME/atomr-accel/nvrtc/$HOME/.cache/atomr-accel/nvrtc/(via [dirs::cache_dir])<temp_dir>/atomr-accel/nvrtc/
Sourcepub fn with_dir(path: PathBuf) -> Result<Self, GpuError>
pub fn with_dir(path: PathBuf) -> Result<Self, GpuError>
Construct a cache rooted at an explicit directory. Creates the directory (recursively) if it does not exist.
Sourcepub fn get(&self, key: NvrtcCacheKey) -> Option<Arc<CachedKernel>>
pub fn get(&self, key: NvrtcCacheKey) -> Option<Arc<CachedKernel>>
Look up a cached kernel.
Returns None if the entry is absent, unreadable, mis-encoded,
or stamped with a non-matching atomr_accel_version. A read
hit on disk but cold in memory promotes the entry into the
in-memory map for subsequent lookups.
Sourcepub fn insert(
&self,
key: NvrtcCacheKey,
value: CachedKernel,
) -> Result<(), GpuError>
pub fn insert( &self, key: NvrtcCacheKey, value: CachedKernel, ) -> Result<(), GpuError>
Store a kernel.
The on-disk write is atomic (write to <name>.tmp then
rename). Concurrent writers race the rename; the loser’s bytes
are silently overwritten — bincode payloads of the same key are
expected to be identical so this is benign.
Sourcepub fn clear_in_memory(&self)
pub fn clear_in_memory(&self)
Drop every in-memory entry. Disk contents are left untouched
— subsequent get calls will re-populate from disk.