numba_dpex.core.kernel_launcher

Provides a helper function to call a numba_dpex.kernel decorated function from either CPython or a numba_dpex.dpjit decorated function.

Overview

Function

call_kernel(kernel_fn, index_space, *kernel_args)

Compiles and synchronously executes a kernel function.

call_kernel_async(kernel_fn, index_space, dependent_events, *kernel_args)

Compiles and asynchronously executes a kernel function.

Functions

call_kernel(kernel_fn, index_space, *kernel_args) None

Compiles and synchronously executes a kernel function.

Kernel execution happens in synchronous way, so the main thread will be blocked till the kernel done execution.

Parameters:
  • kernel_fn (numba_dpex.experimental.KernelDispatcher) – A numba_dpex.experimental.kernel() decorated function that is compiled to a KernelDispatcher.

  • index_space (Range | NdRange) – A Range or NdRange type object that specifies the index space for the kernel.

  • kernel_args – List of objects that are passed to the numba_dpex.kernel decorated function.

call_kernel_async(kernel_fn, index_space, dependent_events: list[dpctl.SyclEvent], *kernel_args) tuple[dpctl.SyclEvent, dpctl.SyclEvent]

Compiles and asynchronously executes a kernel function.

Calls a numba_dpex.experimental.kernel() decorated function asynchronously from CPython or from a numba_dpex.dpjit() function. As the kernel execution happens asynchronously, so the main thread will not be blocked till the kernel done execution. Instead the function returns back to caller a handle for an event to track kernel execution. It is a user’s responsibility to properly track kernel execution completion and not use any data that may still be used by the kernel prior to the kernel’s completion.

Parameters:
  • kernel_fn (KernelDispatcher) – A numba_dpex.experimental.kernel() decorated function that is compiled to a KernelDispatcher.

  • index_space (Range | NdRange) – A Range or NdRange type object that specifies the index space for the kernel.

  • kernel_args – List of objects that are passed to the numba_dpex.kernel decorated function.

Returns:

A pair of dpctl.SyclEvent objects. The pair of events constitute of a host task and an event associated with the kernel execution. The event associated with the kernel execution indicates the execution status of the submitted kernel function. The host task manages the lifetime of any PyObject passed in as a kernel argument and automatically decrements the reference count of the object on kernel execution completion.