numba_vulkan.target#
The Vulkan target, registered with Numba’s target extension API.
Attributes#
Classes#
Marks the Vulkan target in Numba's target hierarchy. |
|
Typing context: which functions and operations type-check on Vulkan. |
|
Calling convention of functions compiled for Vulkan. |
|
Target context: how typed operations are lowered to LLVM IR. |
|
Options accepted by the target; none beyond Numba's defaults. |
|
Target descriptor: gives access to the typing and target contexts. |
Module Contents#
- numba_vulkan.target.TARGET_NAME = 'vulkan'#
- class numba_vulkan.target.Vulkan#
Marks the Vulkan target in Numba’s target hierarchy.
It derives from Numba’s generic
GPUtarget, so overloads registered fortarget="gpu"ortarget="generic"apply to it as well.
- class numba_vulkan.target.VulkanTypingContext#
Typing context: which functions and operations type-check on Vulkan.
- load_additional_registries()#
Install the typing registries beyond Numba’s built-in one.
These are the Vulkan-specific declarations and Numba’s
math,cmath, NumPy and enum declarations.
- resolve_value_type(val)#
Type a Python value used as a global or closure variable.
A function compiled for the CPU (
numba.njit) is replaced by a Vulkan dispatcher for the same Python function, so that calling it from a kernel recompiles it for Vulkan.- Parameters:
val (object) – The value.
- Return type:
numba.types.Type
- numba_vulkan.target.exception_table#
- class numba_vulkan.target.VulkanCallConv#
Calling convention of functions compiled for Vulkan.
Numba’s minimal convention: the return value is written through a pointer argument and the function returns a status code. It never reaches the shader, because everything is inlined; the status of the kernel itself is stored for the host by the entry point (see numba_vulkan.compiler.compile_kernel).
- class numba_vulkan.target.VulkanTargetContext(typingctx, target=TARGET_NAME)#
Target context: how typed operations are lowered to LLVM IR.
- Parameters:
typingctx (VulkanTypingContext) – The typing context.
target (str, optional) – Name of the target in Numba’s registry.
- Variables:
narrow_math (bool) – Whether float64 transcendental functions are evaluated in float32 when libclc is unavailable. Set per compiled function through subtarget.
fast_math (bool) – Whether float32 math uses the device’s built-in functions instead of libclc. Set per compiled function through subtarget.
- implement_powi_as_math_call = True#
- strict_alignment = True#
- narrow_math = False#
- fast_math = False#
- data_model_manager#
- create_module(name)#
Create an empty LLVM module for this target.
- Parameters:
name (str) – Module name.
- Return type:
llvmlite.ir.Module
- init()#
Create the code generator. Called once by Numba’s base context.
- load_additional_registries()#
Install the lowering registries beyond Numba’s built-in one.
Importing Numba’s implementation modules fills its built-in registry with number, tuple, range and array metadata operations. The Vulkan registries add array element access,
global_idandmath.
- get_function(fn, sig, _firstcall=True)#
Find the implementation of a function for a signature.
- Parameters:
fn (callable or numba.types.Type) – The function.
sig (numba.core.typing.Signature) – Signature of the call.
_firstcall (bool, optional) – Used internally by Numba.
- Returns:
impl(builder, args)emitting the call.- Return type:
callable
Notes
Integer-exponent powers are intercepted here; see numba_vulkan.mathimpl.power_override.
- get_ufunc_info(ufunc_key)#
Look up how a NumPy ufunc is lowered.
- Parameters:
ufunc_key (numpy.ufunc) – The ufunc.
- Returns:
Loop signature to implementation; see numba_vulkan.ufuncs.
- Return type:
- Raises:
KeyError – If the ufunc is not supported on Vulkan.
- make_constant_array(builder, aryty, arr)#
Build the value of a NumPy array used as a global constant.
The data is not emitted into the shader. The array’s type names a buffer that the runtime fills once per kernel (see numba_vulkan.buffers.constant_binding); the value built here is the metadata that goes with it.
- Parameters:
builder (llvmlite.ir.IRBuilder) – Builder positioned where the code is emitted.
aryty (VulkanArray) – Type of the array.
arr (numpy.ndarray) – The array.
- Return type:
llvmlite.ir.Value
- codegen()#
The code generator of this context.
- Return type:
- property target_data#
LLVM data layout of the SPIR-V target, used for type sizes.
- Return type:
llvmlite.binding.TargetData
- property call_conv#
The calling convention of compiled functions.
- Return type:
- mangler(name, argtypes, *, abi_tags=(), uid=None)#
Mangle a function name with its argument types.
- class numba_vulkan.target.VulkanTargetOptions#
Options accepted by the target; none beyond Numba’s defaults.
- class numba_vulkan.target.VulkanTarget(name)#
Target descriptor: gives access to the typing and target contexts.
The contexts are created on first use, so importing the package does not initialise LLVM.
- Parameters:
name (str) – Name of the target in Numba’s registry.
- options#
- property typing_context#
The shared typing context.
- Return type:
- property target_context#
The shared target context.
- Return type:
- numba_vulkan.target.vulkan_target#