Skip to content

Commit 8464ce1

Browse files
author
Diptorup Deb
committed
Move llvm_codegen_helpers.py into core.utils and rename to cgutils_extra
1 parent 77397fe commit 8464ce1

File tree

5 files changed

+18
-38
lines changed

5 files changed

+18
-38
lines changed

numba_dpex/core/parfors/reduction_helper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
from numba.parfors import parfor
1818
from numba.parfors.parfor_lowering_utils import ParforLoweringBuilder
1919

20-
from numba_dpex import utils
2120
from numba_dpex.core.datamodel.models import (
2221
dpex_data_model_manager as kernel_dmm,
2322
)
23+
from numba_dpex.core.utils.cgutils_extra import get_llvm_type
2424
from numba_dpex.core.utils.kernel_launcher import KernelLaunchIRBuilder
2525
from numba_dpex.dpctl_iface import libsyclinterface_bindings as sycl
2626

@@ -431,11 +431,11 @@ def copy_final_sum_to_host(self, parfor_kernel):
431431

432432
dest = builder.bitcast(
433433
lowerer.getvar(redvar),
434-
utils.get_llvm_type(context=context, type=types.voidptr),
434+
get_llvm_type(context=context, type=types.voidptr),
435435
)
436436
src = builder.bitcast(
437437
builder.load(array_attr),
438-
utils.get_llvm_type(context=context, type=types.voidptr),
438+
get_llvm_type(context=context, type=types.voidptr),
439439
)
440440

441441
args = [

numba_dpex/core/utils/kernel_flattened_args_builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
from numba.core import cgutils, types
1717
from numba.core.cpu import CPUContext
1818

19-
from numba_dpex import utils
2019
from numba_dpex.core.types import USMNdArray
2120
from numba_dpex.core.types.kernel_api.local_accessor import (
2221
DpctlMDLocalAccessorType,
2322
LocalAccessorType,
2423
)
24+
from numba_dpex.core.utils import cgutils_extra as utils
2525
from numba_dpex.dpctl_iface._helpers import numba_type_to_dpctl_typenum
2626

2727

numba_dpex/core/utils/kernel_launcher.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,17 @@
1717
from numba.core.datamodel import DataModelManager
1818
from numba.core.types.containers import UniTuple
1919

20-
from numba_dpex import utils
2120
from numba_dpex.core import config
2221
from numba_dpex.core.exceptions import UnreachableError
2322
from numba_dpex.core.runtime.context import DpexRTContext
2423
from numba_dpex.core.types import USMNdArray
2524
from numba_dpex.core.types.kernel_api.local_accessor import LocalAccessorType
2625
from numba_dpex.core.types.kernel_api.ranges import NdRangeType, RangeType
26+
from numba_dpex.core.utils import cgutils_extra
2727
from numba_dpex.core.utils.kernel_flattened_args_builder import (
2828
KernelFlattenedArgsBuilder,
2929
)
3030
from numba_dpex.dpctl_iface import libsyclinterface_bindings as sycl
31-
from numba_dpex.utils import create_null_ptr
3231

3332
MAX_SIZE_OF_SYCL_RANGE = 3
3433

@@ -142,10 +141,15 @@ def _build_nullptr(self):
142141
143142
Returns: An LLVM Value storing a null pointer
144143
"""
145-
zero = cgutils.alloca_once(self.builder, utils.LLVMTypes.int64_t)
144+
zero = cgutils.alloca_once(
145+
self.builder, cgutils_extra.LLVMTypes.int64_t
146+
)
146147
self.builder.store(self.context.get_constant(types.int64, 0), zero)
147148
return self.builder.bitcast(
148-
zero, utils.get_llvm_type(context=self.context, type=types.voidptr)
149+
zero,
150+
cgutils_extra.get_llvm_type(
151+
context=self.context, type=types.voidptr
152+
),
149153
)
150154

151155
# TODO: remove, not part of the builder
@@ -159,7 +163,9 @@ def get_queue(self, exec_queue: dpctl.SyclQueue) -> llvmir.Instruction:
159163
# Allocate a stack var to store the queue created from the filter string
160164
sycl_queue_val = cgutils.alloca_once(
161165
self.builder,
162-
utils.get_llvm_type(context=self.context, type=types.voidptr),
166+
cgutils_extra.get_llvm_type(
167+
context=self.context, type=types.voidptr
168+
),
163169
)
164170
# Insert a global constant to store the filter string
165171
device = self.context.insert_const_string(
@@ -256,8 +262,8 @@ def _create_sycl_range(self, idx_range):
256262
"""
257263
int64_range = [
258264
(
259-
self.builder.sext(rext, utils.LLVMTypes.int64_t)
260-
if rext.type != utils.LLVMTypes.int64_t
265+
self.builder.sext(rext, cgutils_extra.LLVMTypes.int64_t)
266+
if rext.type != cgutils_extra.LLVMTypes.int64_t
261267
else rext
262268
)
263269
for rext in idx_range
@@ -334,7 +340,7 @@ def set_kernel_from_spirv(
334340
)
335341
else:
336342
spv_compiler_options = self.builder.load(
337-
create_null_ptr(self.builder, self.context)
343+
cgutils_extra.create_null_ptr(self.builder, self.context)
338344
)
339345

340346
# build_or_get_kernel steals reference to context and device cause it

numba_dpex/utils/__init__.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)