numba_dpex.core.runtime.context module

class numba_dpex.core.runtime.context.DpexRTContext(context)

Bases: object

An object providing access to DPEXRT API in the lowering pass.

arraystruct_from_python(pyapi, obj, ptr)

Generates a call to DPEXRT_sycl_usm_ndarray_from_python C function defined in the _DPREXRT_python Python extension.

copy_queue(builder, queue_ref)

Calls DPCTLQueue_Copy to create a copy of the DpctlSyclQueueRef pointer passed in to the function.

Args:

builder: The llvmlite.IRBuilder used to generate the LLVM IR for the call. queue_ref: An LLVM value for a DpctlSyclQueueRef pointer that will be passed to the DPCTLQueue_Copy function.

Returns: A DPCTLSyclQueueRef pointer.

get_queue_from_filter_string(builder, device)

Calls DPEXRTQueue_CreateFromFilterString to create a new sycl::queue from a given filter string.

Args:
device (llvmlite.ir.values.FormattedConstant): An LLVM ArrayType

storing a const string for a DPC++ filter selector string.

Returns: A DPCTLSyclQueueRef pointer.

meminfo_alloc(builder, size, usm_type, queue_ref)

Wrapper to call meminfo_alloc_unchecked() with null checking of the returned value.

meminfo_alloc_unchecked(builder, size, usm_type, queue_ref)

Allocate a new MemInfo with a data payload of size bytes.

The result of the call is checked and if it is NULL, i.e. allocation failed, then a MemoryError is raised. If the allocation succeeded then a pointer to the MemInfo is returned.

Args:

builder (llvmlite.ir.builder.IRBuilder): LLVM IR builder. size (llvmlite.ir.values.Argument): LLVM uint64 value specifying

the size in bytes for the data payload, i.e. i64 %”arg.allocsize”

usm_type (llvmlite.ir.values.Argument): An LLVM Argument object

specifying the type of the usm allocator. The constant value should match the values in dpctl's libsyclinterface::DPCTLSyclUSMType enum, i.e. i64 %”arg.usm_type”.

queue_ref (llvmlite.ir.values.Argument): An LLVM argument value storing

the pointer to the address of the queue object, the object can be dpctl.SyclQueue(), i.e. i8* %”arg.queue”.

Returns:
ret (llvmlite.ir.instructions.CallInstr): A pointer to the MemInfo

is returned from the DPEXRT_MemInfo_alloc C function call.

meminfo_fill(builder, meminfo, itemsize, dest_is_float, value_is_float, value, queue_ref)

Wrapper to call meminfo_fill_unchecked() with null checking of the returned value.

meminfo_fill_unchecked(builder, meminfo, itemsize, dest_is_float, value_is_float, value, queue_ref)

Fills an allocated MemInfo with the value specified.

The result of the call is checked and if it is NULL, i.e. the fill operation failed, then a MemoryError is raised. If the fill operation is succeeded then a pointer to the MemInfo is returned.

Args:

builder (llvmlite.ir.builder.IRBuilder): LLVM IR builder. meminfo (llvmlite.ir.instructions.LoadInstr): LLVM uint64 value

specifying the size in bytes for the data payload.

itemsize (llvmlite.ir.values.Constant): An LLVM Constant value

specifying the size of the each data item allocated by the usm allocator.

dest_is_float (llvmlite.ir.values.Constant): An LLVM Constant

value specifying if the destination array type is floating point.

value_is_float (llvmlite.ir.values.Constant): An LLVM Constant

value specifying if the input value is a floating point.

value (llvmlite.ir.values.Constant): An LLVM Constant value

specifying if the input value that will be used to fill the array.

queue_ref (llvmlite.ir.instructions.ExtractValue): An LLVM ExtractValue

instruction object to extract the pointer to the queue from the DpctlSyclQueue type, i.e. %”.74” = extractvalue {i8*, i8*} %”.73”, 1.

Returns:
ret (llvmlite.ir.instructions.CallInstr): A pointer to the MemInfo

is returned from the DPEXRT_MemInfo_fill C function call.

queuestruct_from_python(pyapi, obj, ptr)

Calls the c function DPEXRT_sycl_queue_from_python

queuestruct_to_python(pyapi, val)

Calls the c function DPEXRT_sycl_queue_to_python

submit_ndrange(builder, kref, qref, args, argtys, nargs, grange, lrange, ndims, depevents, ndepevents)

Calls DPEXRTQueue_CreateFromFilterString to create a new sycl::queue from a given filter string.

Returns: A LLVM IR call inst.

submit_range(builder, kref, qref, args, argtys, nargs, range, nrange, depevents, ndepevents)

Calls DPEXRTQueue_CreateFromFilterString to create a new sycl::queue from a given filter string.

Returns: A DPCTLSyclQueueRef pointer.

usm_ndarray_to_python_acqref(pyapi, aryty, ary, dtypeptr)

Boxes a DpnpNdArray native object into a Python dpnp.ndarray.

Args:

pyapi (_type_): _description_ aryty (_type_): _description_ ary (_type_): _description_ dtypeptr (_type_): _description_

Returns:

_type_: _description_