numba_vulkan.compiler#
Compilation pipeline of the Vulkan target.
Attributes#
Classes#
Compile result whose entry point is a synthetic identifier. |
|
Final compiler pass: package the lowering output in a compile result. |
|
Give every call that creates an array an identity. |
|
Numba compiler pipeline of the Vulkan target. |
Functions#
|
Run |
|
Wrap a compiled function in a shader entry point and emit SPIR-V. |
Module Contents#
- numba_vulkan.compiler.LOCAL_SIZES#
- class numba_vulkan.compiler.VulkanCompileResult#
Compile result whose entry point is a synthetic identifier.
Numba’s dispatchers and target contexts key compiled functions by their entry point, normally a native address. Nothing is compiled to native code here, so the identity of the result is used instead.
- class numba_vulkan.compiler.VulkanBackend#
Final compiler pass: package the lowering output in a compile result.
Give every call that creates an array an identity.
Shared arrays become workgroup variables, and local arrays (including
np.zerosand its relatives) private variables, which must be the same for every execution of the call and different from that of any other call. The pass passes a literal derived from the function and the position of the call as a hidden first argument, which typing turns into the array’s “binding” (see numba_vulkan.vkdecl.SharedArray). Being derived from the source, it is the same in every process, as the kernel cache needs.Add the hidden argument to the calls.
- Parameters:
state (numba.core.compiler.StateDict) – Compiler state.
- Returns:
Whether the IR changed.
- Return type:
- class numba_vulkan.compiler.VulkanCompiler#
Numba compiler pipeline of the Vulkan target.
Numba’s untyped and typed passes are used unchanged, followed by its native lowering and VulkanBackend. No machine code is generated.
- numba_vulkan.compiler.compile_vulkan(pyfunc, return_type, args, narrow_math=False, fast_math=False, boundscheck=False, error_model='numpy')#
Run
pyfuncthrough Numba’s pipeline down to LLVM IR.- Parameters:
pyfunc (function) – The Python function.
return_type (numba.types.Type or None) – Return type, or
Noneto infer it.args (tuple of numba.types.Type) – Argument types.
narrow_math (bool) – Compute float64 transcendental functions in float32 when libclc is not available.
fast_math (bool) – Use the device’s built-in float32 math functions instead of libclc.
boundscheck (bool) – Raise
IndexErrorfor array indices that are out of bounds.error_model ({'numpy', 'python'}) – Numba’s error model:
'python'raisesZeroDivisionErrorfor divisions by zero,'numpy'gives NumPy’s results.
- Return type:
- numba_vulkan.compiler.PUSH_CONSTANT_BYTES = 128#
- numba_vulkan.compiler.compile_kernel(cres, ndim, exact=True, local_size=None, aliases=())#
Wrap a compiled function in a shader entry point and emit SPIR-V.
- Parameters:
cres (VulkanCompileResult) – The compiled kernel body; it must return
None.ndim (int) – Dimensionality of the dispatch grid (selects the default workgroup size).
exact (bool) – Whether drivers must keep float arithmetic as written; see numba_vulkan.codegen.mark_exact.
local_size (tuple of int, optional) – Workgroup size; by default 64 invocations, shaped by ndim.
aliases (tuple of tuple) –
(index, earlier)for array arguments launched with the same buffer as an earlier one: they use its binding, so that the kernel sees that they share memory (as the checks of array expressions assigned to arrays they read need to).
- Return type: