Skip to content

Commit

Permalink
Refactor TargetConfig naming.
Browse files Browse the repository at this point in the history
As title.

Closes numba#7276
  • Loading branch information
stuartarchibald committed Sep 29, 2021
1 parent e617b39 commit 792aa8b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions numba/core/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import numba.core.event as ev


class TargetConfig:
class TargetConfigurationStack:
"""The target configuration stack.
Uses the BORG pattern and stores states in threadlocal storage.
Expand Down Expand Up @@ -1067,17 +1067,18 @@ def _get_retarget_dispatcher(self):
"""Returns a dispatcher for the retarget request.
"""
# Check TLS target configuration
tc = TargetConfig()
tc = TargetConfigurationStack()
retarget = tc.get()
retarget.check_compatible(self)
disp = retarget.retarget(self)
return disp

def _get_dispatcher_for_current_target(self):
"""Returns a dispatcher for the current target registered in `TargetConfig`.
`self` is returned if no target is specified.
"""Returns a dispatcher for the current target registered in
`TargetConfigurationStack`. `self` is returned if no target is
specified.
"""
tc = TargetConfig()
tc = TargetConfigurationStack()
if tc:
return self._get_retarget_dispatcher()
else:
Expand Down
4 changes: 2 additions & 2 deletions numba/tests/parfors_max_label_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np

from numba import njit
from numba.core.dispatcher import TargetConfig
from numba.core.dispatcher import TargetConfigurationStack
from numba.core.target_extension import (
dispatcher_registry,
CPUDispatcher,
Expand Down Expand Up @@ -58,7 +58,7 @@ def f(a):

def main():
a = np.ones(20)
with TargetConfig.switch_target(retarget):
with TargetConfigurationStack.switch_target(retarget):
r = f(a)
np.testing.assert_equal(r, f.py_func(a))
print("TEST PASSED")
Expand Down
4 changes: 2 additions & 2 deletions numba/tests/test_retargeting.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from numba import njit
from numba.core import errors, cpu, utils, typing
from numba.core.descriptors import TargetDescriptor
from numba.core.dispatcher import TargetConfig
from numba.core.dispatcher import TargetConfigurationStack
from numba.core.retarget import BasicRetarget
from numba.core.extending import overload
from numba.core.target_extension import (
Expand Down Expand Up @@ -154,7 +154,7 @@ def flex_target(x):
self.retarget = CustomCPURetarget()

def switch_target(self):
return TargetConfig.switch_target(self.retarget)
return TargetConfigurationStack.switch_target(self.retarget)

@contextmanager
def check_retarget_error(self):
Expand Down

0 comments on commit 792aa8b

Please sign in to comment.