Skip to main content

kernel_key

Function kernel_key 

Source
pub fn kernel_key(options: &PlaneOptions, layout: FrameLayout) -> u128
Expand description

Identifies the set of kernels a denoiser compiles.

Radii, channel mode, depth and algorithm are all baked into the kernels at compile time, so a change to any of them produces a different set and a warm cache for one set says nothing about another. Processes that would compile different kernels have no reason to wait for each other, and a stamp left by one must not convince the other that its own kernels are cached.

The key is taken from the Debug rendering of both inputs rather than from a hand-written list of the fields that reach a kernel. A hand-written list silently stops covering a field the day someone adds one, and the failure that follows is a process trusting a stamp for kernels it has never compiled. Reading everything keeps the key correct without maintenance.

Including fields that only ever reach the GPU as runtime arguments, such as strength, makes the key finer than it strictly needs to be. Two runs that differ only in strength warm up separately instead of sharing. That costs one extra warm-up and is the safe direction to err in.

This crate’s version goes into the key as well, because a release that changes a kernel changes what CubeCL caches under it, and CubeCL files its own cache under the CubeCL version on top of that. Without the version a stamp written before an upgrade would tell every process after it that a cache emptied by that upgrade is warm, and the whole first wave would compile at once again with nothing said about it. Rebuilding a kernel without changing the version is the one case this misses, and deleting the cache directory clears it.