numba_vulkan.kernelcache#
On-disk cache of compiled kernels.
Turning a kernel’s LLVM IR into SPIR-V (linking libclc, optimising, restructuring, running the backend) is the larger part of compiling it. The result depends only on the IR that Numba’s lowering produces and on this package, so it is stored under a hash of both and reused by later processes. Numba’s own pipeline still runs every time, which is what makes the cache safe: a change to a kernel, to a function it calls or to a global it reads changes the IR and therefore the hash.
Entries live in kernels/ below numba_vulkan.libclc.cache_directory
and can be deleted at any time. Setting NUMBA_VULKAN_CACHE=0 turns the
cache off.
Kernels compiled with @nv.jit(cache=True) are stored whole as well, in
functions/, which skips Numba’s pipeline too. They are found by their
bytecode, the timestamps of their source files and those of the @nv.jit
functions they call, as with Numba’s cache=True; see
numba_vulkan.dispatcher.VulkanDispatcher.compile.
Attributes#
Functions#
|
Whether kernels are cached on disk. |
Hash of everything besides a kernel's IR that shapes its SPIR-V. |
|
|
Remove what differs between processes from unoptimised LLVM IR. |
|
Name of the cache entry for a kernel. |
|
Read an entry. |
|
Write an entry; failures to write are ignored. |
|
What identifies a Python function's code across processes. |
|
Name of the cache entry for a compiled kernel. |
|
Read a cached kernel. |
|
Write a cached kernel; failures to write are ignored. |
Module Contents#
- numba_vulkan.kernelcache.ENV_VAR = 'NUMBA_VULKAN_CACHE'#
- numba_vulkan.kernelcache.fingerprint()#
Hash of everything besides a kernel’s IR that shapes its SPIR-V.
That is the source of this package, the version of llvmlite (and with it of LLVM), the libclc file in use, and the
llcprogram if one replaces llvmlite’s backend.- Return type:
- numba_vulkan.kernelcache.normalise(source)#
Remove what differs between processes from unoptimised LLVM IR.
- numba_vulkan.kernelcache.key(source, *settings)#
Name of the cache entry for a kernel.
- numba_vulkan.kernelcache.load(name)#
Read an entry.
- numba_vulkan.kernelcache.store(name, entry)#
Write an entry; failures to write are ignored.
- numba_vulkan.kernelcache.source_stamp(function)#
What identifies a Python function’s code across processes.
- Parameters:
function (function) – A Python function.
- Returns:
Its bytecode with the name, size and modification time of its source file, or
Noneif it has no source file (it was defined interactively or withexec), and cannot be cached.- Return type:
bytes or None
- numba_vulkan.kernelcache.kernel_key(stamps, *settings)#
Name of the cache entry for a compiled kernel.