Skip to content

Commit 004ca5f

Browse files
author
Diptorup Deb
committed
Add kernel-specific DpexTargetOptions
1 parent 1ece135 commit 004ca5f

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

numba_dpex/core/descriptor.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from functools import cached_property
66

7-
from numba.core import typing
7+
from numba.core import options, targetconfig, typing
88
from numba.core.cpu import CPUTargetOptions
99
from numba.core.descriptors import TargetDescriptor
1010

@@ -15,13 +15,42 @@
1515
DpexKernelTypingContext,
1616
)
1717

18+
_option_mapping = options._mapping
19+
20+
21+
def _inherit_if_not_set(flags, options, name, default=targetconfig._NotSet):
22+
if name in options:
23+
setattr(flags, name, options[name])
24+
return
25+
26+
cstk = targetconfig.ConfigStack()
27+
if cstk:
28+
# inherit
29+
top = cstk.top()
30+
if hasattr(top, name):
31+
setattr(flags, name, getattr(top, name))
32+
return
33+
34+
if default is not targetconfig._NotSet:
35+
setattr(flags, name, default)
36+
37+
38+
class DpexTargetOptions(CPUTargetOptions):
39+
experimental = _option_mapping("experimental")
40+
release_gil = _option_mapping("release_gil")
41+
42+
def finalize(self, flags, options):
43+
super().finalize(flags, options)
44+
_inherit_if_not_set(flags, options, "experimental", False)
45+
_inherit_if_not_set(flags, options, "release_gil", False)
46+
1847

1948
class DpexKernelTarget(TargetDescriptor):
2049
"""
2150
Implements a target descriptor for numba_dpex.kernel decorated functions.
2251
"""
2352

24-
options = CPUTargetOptions
53+
options = DpexTargetOptions
2554

2655
@cached_property
2756
def _toplevel_target_context(self):

0 commit comments

Comments
 (0)