|
4 | 4 |
|
5 | 5 | from functools import cached_property
|
6 | 6 |
|
7 |
| -from numba.core import typing |
| 7 | +from numba.core import options, targetconfig, typing |
8 | 8 | from numba.core.cpu import CPUTargetOptions
|
9 | 9 | from numba.core.descriptors import TargetDescriptor
|
10 | 10 |
|
|
15 | 15 | DpexKernelTypingContext,
|
16 | 16 | )
|
17 | 17 |
|
| 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 | + |
18 | 47 |
|
19 | 48 | class DpexKernelTarget(TargetDescriptor):
|
20 | 49 | """
|
21 | 50 | Implements a target descriptor for numba_dpex.kernel decorated functions.
|
22 | 51 | """
|
23 | 52 |
|
24 |
| - options = CPUTargetOptions |
| 53 | + options = DpexTargetOptions |
25 | 54 |
|
26 | 55 | @cached_property
|
27 | 56 | def _toplevel_target_context(self):
|
|
0 commit comments