|
28 | 28 | from numba_dpex import config
|
29 | 29 |
|
30 | 30 | from ..descriptor import dpex_kernel_target
|
31 |
| -from ..types.dpnp_ndarray_type import DpnpNdArray |
| 31 | +from ..types import DpnpNdArray, USMNdArray |
32 | 32 | from ..utils.kernel_templates import RangeKernelTemplate
|
33 | 33 |
|
34 | 34 |
|
@@ -70,6 +70,30 @@ def _compile_kernel_parfor(
|
70 | 70 | func_ir, kernel_name
|
71 | 71 | )
|
72 | 72 |
|
| 73 | + # A cast from DpnpNdArray type to USMNdArray is needed for all arguments of |
| 74 | + # DpnpNdArray type. Although, DpnpNdArray derives from USMNdArray the two |
| 75 | + # types use different data models. USMNdArray uses the |
| 76 | + # numba_dpex.core.datamodel.models.ArrayModel data model that defines all |
| 77 | + # CPointer type members in the GLOBAL address space. The DpnpNdArray uses |
| 78 | + # Numba's default ArrayModel that does not define pointers in any specific |
| 79 | + # address space. For OpenCL HD Graphics devices, defining a kernel function |
| 80 | + # (spir_kernel calling convention) with pointer arguments that have no |
| 81 | + # address space qualifier causes a run time crash. By casting the argument |
| 82 | + # type for parfor arguments from DpnpNdArray type to the USMNdArray type the |
| 83 | + # generated kernel always has an address space qualifier, avoiding the issue |
| 84 | + # on OpenCL HD graphics devices. |
| 85 | + |
| 86 | + for i, argty in enumerate(argtypes): |
| 87 | + if isinstance(argty, DpnpNdArray): |
| 88 | + new_argty = USMNdArray( |
| 89 | + ndim=argty.ndim, |
| 90 | + layout=argty.layout, |
| 91 | + dtype=argty.dtype, |
| 92 | + usm_type=argty.usm_type, |
| 93 | + queue=argty.queue, |
| 94 | + ) |
| 95 | + argtypes[i] = new_argty |
| 96 | + |
73 | 97 | # compile the kernel
|
74 | 98 | kernel.compile(
|
75 | 99 | args=argtypes,
|
|
0 commit comments