numba_dpex.core.parfors.kernel_builder module

class numba_dpex.core.parfors.kernel_builder.ParforKernel(name, kernel, signature, kernel_args, kernel_arg_types, queue)

Bases: object

numba_dpex.core.parfors.kernel_builder.create_kernel_for_parfor(lowerer, parfor_node, typemap, flags, loop_ranges, has_aliases, races, parfor_outputs)

Creates a numba_dpex.kernel function for a parfor node.

There are two parts to this function:

  1. Code to iterate across the iteration space as defined by the schedule.

  2. The parfor body that does the work for a single point in the iteration space.

Part 1 is created as Python text for simplicity with a sentinel assignment to mark the point in the IR where the parfor body should be added. This Python text is ‘exec’ed into existence and its IR retrieved with run_frontend. The IR is scanned for the sentinel assignment where that basic block is split and the IR for the parfor body inserted.

numba_dpex.core.parfors.kernel_builder.update_sentinel(kernel_ir, sentinel_name, kernel_body, new_label)

Searched all the blocks in the IR generated from a kernel template and replaces the __sentinel__ instruction with the actual op for the parfor.

Args:

kernel_ir : Numba FunctionIR that was generated from a kernel template sentinel_name : The name of the sentinel instruction that is to be replaced. kernel_body : The function body of the kernel template generated numba_dpex.kernel function new_label: The new label to be used for the basic block created to store the instructions that replaced the sentinel