|
20 | 20 | from numba.core.typing import signature |
21 | 21 |
|
22 | 22 | from numba_dpex.core.types import DpctlSyclQueue |
| 23 | +from numba_dpex.core.types.kernel_api.index_space_ids import NdItemType |
23 | 24 |
|
24 | 25 | from .kernel_builder import _print_body # saved for debug |
25 | 26 | from .kernel_builder import ( |
@@ -48,6 +49,7 @@ def create_reduction_main_kernel_for_parfor( |
48 | 49 | """ |
49 | 50 |
|
50 | 51 | loc = parfor_node.init_block.loc |
| 52 | + parfor_dim = len(parfor_node.loop_nests) |
51 | 53 |
|
52 | 54 | for race in parfor_node.races: |
53 | 55 | msg = ( |
@@ -84,7 +86,7 @@ def create_reduction_main_kernel_for_parfor( |
84 | 86 | sentinel_name=sentinel_name, |
85 | 87 | loop_ranges=loop_ranges, |
86 | 88 | param_dict=reductionKernelVar.param_dict, |
87 | | - parfor_dim=len(parfor_node.loop_nests), |
| 89 | + parfor_dim=parfor_dim, |
88 | 90 | redvars=reductionKernelVar.parfor_redvars, |
89 | 91 | parfor_args=reductionKernelVar.parfor_params, |
90 | 92 | parfor_reddict=parfor_reddict, |
@@ -136,6 +138,13 @@ def create_reduction_main_kernel_for_parfor( |
136 | 138 | if not has_aliases: |
137 | 139 | flags.noalias = True |
138 | 140 |
|
| 141 | + # The first argument to a range kernel is a kernel_api.NdItem object. The |
| 142 | + # ``NdItem`` object is used by the kernel_api.spirv backend to generate the |
| 143 | + # correct SPIR-V indexing instructions. Since, the argument is not something |
| 144 | + # available originally in the kernel_param_types, we add it at this point to |
| 145 | + # make sure the kernel signature matches the actual generated code. |
| 146 | + ty_item = NdItemType(parfor_dim) |
| 147 | + kernel_param_types = (ty_item, *kernel_param_types) |
139 | 148 | kernel_sig = signature(types.none, *kernel_param_types) |
140 | 149 |
|
141 | 150 | # FIXME: A better design is required so that we do not have to create a |
|
0 commit comments