numba_dpex.core.utils.call_kernel_builder

Module that contains numba style wrapper around sycl kernel submit.

Overview

Classes

SPIRVKernelModule

Represents SPIRV binary code and function name in this binary

KernelLaunchIRBuilder

Helper class to build the LLVM IR for the submission of a kernel.

Function

get_queue_from_llvm_values(ctx, builder, ty_kernel_args, ll_kernel_args)

Get the sycl queue from the first USMNdArray argument. Prior passes

Classes

class SPIRVKernelModule

Bases: NamedTuple

Represents SPIRV binary code and function name in this binary

Overview

Attributes

kernel_name

-

kernel_bitcode

-

Members

kernel_name: str
kernel_bitcode: bytes
class KernelLaunchIRBuilder(context: numba.core.cpu.CPUContext, builder: llvmlite.ir.builder.IRBuilder, kernel_dmm: numba.core.datamodel.DataModelManager)

Helper class to build the LLVM IR for the submission of a kernel.

The class generates LLVM IR inside the current LLVM module that is needed for submitting kernels. The LLVM Values that

Overview

Methods

dpexrt()

Dpex runtime context.

get_queue(exec_queue)

Allocates memory on the stack to store a DPCTLSyclQueueRef.

set_kernel(sycl_kernel_ref)

Sets kernel to the argument list.

set_kernel_from_spirv(kernel_module, debug)

Sets kernel to the argument list from the SPIRV bytecode.

set_queue(sycl_queue_ref)

Sets queue to the argument list.

set_queue_from_arguments()

Sets the sycl queue from the first USMNdArray argument provided

set_range(global_range, local_range)

Sets global and local range if provided to the argument list.

set_range_from_indexer(ty_indexer_arg, ll_index_arg)

Returns two lists of LLVM IR Values that hold the unboxed extents of

set_arguments(ty_kernel_args, kernel_args)

Sets flattened kernel args, kernel arg types and number of those

set_arguments_form_tuple(ty_kernel_args_tuple, ll_kernel_args_tuple)

Sets flattened kernel args, kernel arg types and number of those

set_dependent_events(dep_events)

Sets dependent events to the argument list.

set_dependent_events_from_tuple(ty_dependent_events, ll_dependent_events)

Set’s dependent events from tuple represented by LLVM IR.

submit()

Submits kernel by calling sycl.dpctl_queue_submit_range or

acquire_meminfo_and_submit_release()

Schedule sycl host task to release nrt meminfo of the arguments used

Members

dpexrt()

Dpex runtime context.

get_queue(exec_queue: dpctl.SyclQueue) llvmlite.ir.Instruction

Allocates memory on the stack to store a DPCTLSyclQueueRef.

Returns: A LLVM Value storing the pointer to the SYCL queue created using the filter string for the Python exec_queue (dpctl.SyclQueue).

set_kernel(sycl_kernel_ref: llvmlite.ir.Instruction)

Sets kernel to the argument list.

set_kernel_from_spirv(kernel_module: SPIRVKernelModule, debug=False)

Sets kernel to the argument list from the SPIRV bytecode.

It pastes bytecode as a constant string and create kernel bundle from it using SYCL API. It caches kernel, so it won’t be sent to device second time.

set_queue(sycl_queue_ref: llvmlite.ir.Instruction)

Sets queue to the argument list.

set_queue_from_arguments()

Sets the sycl queue from the first USMNdArray argument provided earlier.

set_range(global_range: list, local_range: list = None)

Sets global and local range if provided to the argument list.

set_range_from_indexer(ty_indexer_arg: RangeType | NdRangeType, ll_index_arg: llvmlite.ir.BaseStructType)

Returns two lists of LLVM IR Values that hold the unboxed extents of a Python Range or NdRange object.

set_arguments(ty_kernel_args: list[numba.core.types.Type], kernel_args: list[llvmlite.ir.Instruction])

Sets flattened kernel args, kernel arg types and number of those arguments to the argument list.

set_arguments_form_tuple(ty_kernel_args_tuple: numba.core.types.containers.UniTuple, ll_kernel_args_tuple: llvmlite.ir.Instruction)

Sets flattened kernel args, kernel arg types and number of those arguments to the argument list based on the arguments stored in tuple.

set_dependent_events(dep_events: list[llvmlite.ir.Instruction])

Sets dependent events to the argument list.

set_dependent_events_from_tuple(ty_dependent_events: numba.core.types.containers.UniTuple, ll_dependent_events: llvmlite.ir.Instruction)

Set’s dependent events from tuple represented by LLVM IR.

Parameters:

ll_dependent_events – tuple of numba’s data models.

submit() llvmlite.ir.Instruction

Submits kernel by calling sycl.dpctl_queue_submit_range or sycl.dpctl_queue_submit_ndrange. Must be called after all arguments set.

acquire_meminfo_and_submit_release() llvmlite.ir.Instruction

Schedule sycl host task to release nrt meminfo of the arguments used to run job. Use it to keep arguments alive during kernel execution.

Functions

get_queue_from_llvm_values(ctx: numba.core.cpu.CPUContext, builder: llvmlite.ir.builder.IRBuilder, ty_kernel_args: list[numba.core.types.Type], ll_kernel_args: list[llvmlite.ir.Instruction])

Get the sycl queue from the first USMNdArray argument. Prior passes before lowering make sure that compute-follows-data is enforceable for a specific call to a kernel. As such, at the stage of lowering the queue from the first USMNdArray argument can be extracted.

Attributes

MAX_SIZE_OF_SYCL_RANGE = 3
OPEN_CL_OPT_DISABLE_FLAG = '-cl-opt-disable'
L0_OPT_DISABLE_FLAG = '-g'