Skip to content

Commit 4f9616b

Browse files
author
Diptorup Deb
committed
Extract inline_threshold value from targetdescr before use.
- Addresses review comments on how to properly set the inline_threshold target option
1 parent ad7cf73 commit 4f9616b

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

numba_dpex/core/descriptor.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from numba.core.cpu import CPUTargetOptions
99
from numba.core.descriptors import TargetDescriptor
1010

11+
from numba_dpex import config
12+
1113
from .targets.dpjit_target import DPEX_TARGET_NAME, DpexTargetContext
1214
from .targets.kernel_target import (
1315
DPEX_KERNEL_TARGET_NAME,
@@ -50,7 +52,12 @@ def finalize(self, flags, options):
5052
_inherit_if_not_set(flags, options, "release_gil", False)
5153
_inherit_if_not_set(flags, options, "no_compile", True)
5254
_inherit_if_not_set(flags, options, "use_mlir", False)
53-
_inherit_if_not_set(flags, options, "inline_threshold", 0)
55+
if config.INLINE_THRESHOLD is not None:
56+
_inherit_if_not_set(
57+
flags, options, "inline_threshold", config.INLINE_THRESHOLD
58+
)
59+
else:
60+
_inherit_if_not_set(flags, options, "inline_threshold", 0)
5461
_inherit_if_not_set(
5562
flags, options, "_compilation_mode", CompilationMode.KERNEL
5663
)

numba_dpex/experimental/kernel_dispatcher.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import numba.core.event as ev
1313
from numba.core import errors, sigutils, types
14-
from numba.core.compiler import CompileResult
14+
from numba.core.compiler import CompileResult, Flags
1515
from numba.core.compiler_lock import global_compiler_lock
1616
from numba.core.dispatcher import Dispatcher, _FunctionCompiler
1717
from numba.core.target_extension import dispatcher_registry, target_registry
@@ -84,14 +84,15 @@ def _compile_to_spirv(
8484
kernel_fn = kernel_targetctx.prepare_spir_kernel(
8585
kernel_func, kernel_fndesc.argtypes
8686
)
87+
# Get the compiler flags that were passed through the target descriptor
88+
flags = Flags()
89+
self.targetdescr.options.parse_as_flags(flags, self.targetoptions)
90+
8791
# If the inline_threshold option was set then set the property in the
8892
# kernel_library to force inlining ``overload`` calls into a kernel.
89-
try:
90-
kernel_library.inline_threshold = self.targetoptions[
91-
"inline_threshold"
92-
]
93-
except KeyError:
94-
pass
93+
inline_threshold = flags.inline_threshold # pylint: disable=E1101
94+
kernel_library.inline_threshold = inline_threshold
95+
9596
# Call finalize on the LLVM module. Finalization will result in
9697
# all linking libraries getting linked together and final optimization
9798
# including inlining of functions if an inlining level is specified.
@@ -202,9 +203,6 @@ class KernelDispatcher(Dispatcher):
202203
an executable binary, the dispatcher compiles it to SPIR-V and then caches
203204
that SPIR-V bitcode.
204205
205-
FIXME: Fix issues identified by pylint with this class.
206-
https://github.com/IntelPython/numba-dpex/issues/1196
207-
208206
"""
209207

210208
targetdescr = dpex_exp_kernel_target
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-FileCopyrightText: 2023 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0

0 commit comments

Comments
 (0)