numba_dpex.core.runtime.context

Overview

Classes

DpexRTContext

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

Classes

class DpexRTContext(context)

Bases: object

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

Overview

Methods

meminfo_alloc(builder, size, usm_type, queue_ref)

Wrapper to call meminfo_alloc_unchecked()

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

Wrapper to call meminfo_fill_unchecked()

meminfo_alloc_unchecked(builder, size, usm_type, queue_ref)

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

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

Fills an allocated MemInfo with the value specified.

arraystruct_from_python(pyapi, obj, ptr)

Generates a call to DPEXRT_sycl_usm_ndarray_from_python C function

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

eventstruct_from_python(pyapi, obj, ptr)

Calls the c function DPEXRT_sycl_event_from_python

eventstruct_to_python(pyapi, val)

Calls the c function DPEXRT_sycl_event_to_python

eventstruct_init(pyapi, event, struct)

Calls the c function DPEXRT_sycl_event_init

usm_ndarray_to_python_acqref(pyapi, aryty, ary, dtypeptr)

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

get_queue_from_filter_string(builder, device)

Calls DPEXRTQueue_CreateFromFilterString to create a new sycl::queue

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

Calls DPEXRTQueue_CreateFromFilterString to create a new sycl::queue

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

Calls DPEXRTQueue_CreateFromFilterString to create a new sycl::queue

acquire_meminfo_and_schedule_release(builder, args)

Inserts LLVM IR to call nrt_acquire_meminfo_and_schedule_release.

build_or_get_kernel(builder, args)

Inserts LLVM IR to call build_or_get_kernel.

kernel_cache_size(builder)

Inserts LLVM IR to call kernel_cache_size.

Members

meminfo_alloc(builder, size, usm_type, queue_ref)

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

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_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.

Parameters:
  • 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:

A pointer to the MemInfo

is returned from the DPEXRT_MemInfo_alloc C function call.

Return type:

ret (llvmlite.ir.instructions.CallInstr)

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.

Parameters:
  • 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:

A pointer to the MemInfo

is returned from the DPEXRT_MemInfo_fill C function call.

Return type:

ret (llvmlite.ir.instructions.CallInstr)

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.

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

eventstruct_from_python(pyapi, obj, ptr)

Calls the c function DPEXRT_sycl_event_from_python

eventstruct_to_python(pyapi, val)

Calls the c function DPEXRT_sycl_event_to_python

eventstruct_init(pyapi, event, struct)

Calls the c function DPEXRT_sycl_event_init

usm_ndarray_to_python_acqref(pyapi, aryty, ary, dtypeptr)

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

Parameters:
  • pyapi (_type_) – _description_

  • aryty (_type_) – _description_

  • ary (_type_) – _description_

  • dtypeptr (_type_) – _description_

Returns:

_description_

Return type:

_type_

get_queue_from_filter_string(builder, device)

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

Parameters:

device (llvmlite.ir.values.FormattedConstant) – An LLVM ArrayType storing a const string for a DPC++ filter selector string.

Returns: A DPCTLSyclQueueRef pointer.

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.

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.

acquire_meminfo_and_schedule_release(builder: llvmlite.ir.IRBuilder, args)

Inserts LLVM IR to call nrt_acquire_meminfo_and_schedule_release.

DPCTLSyclEventRef
DPEXRT_nrt_acquire_meminfo_and_schedule_release(
    NRT_api_functions *nrt,
    DPCTLSyclQueueRef QRef,
    NRT_MemInfo **meminfo_array,
    size_t meminfo_array_size,
    DPCTLSyclEventRef *depERefs,
    size_t nDepERefs,
    int *status,
);
build_or_get_kernel(builder: llvmlite.ir.IRBuilder, args)

Inserts LLVM IR to call build_or_get_kernel.

DPCTLSyclKernelRef
DPEXRT_build_or_get_kernel(
    const DPCTLSyclContextRef ctx,
    const DPCTLSyclDeviceRef dev,
    size_t il_hash,
    const char *il,
    size_t il_length,
    const char *compile_opts,
    const char *kernel_name,
);
kernel_cache_size(builder: llvmlite.ir.IRBuilder)

Inserts LLVM IR to call kernel_cache_size.

size_t DPEXRT_kernel_cache_size();