Skip to content
This repository was archived by the owner on Jan 25, 2023. It is now read-only.

Commit 8e92a78

Browse files
committed
remove dppy dispatcher and create a new file cpu_dispatcher to avoid circular imports
1 parent 203e2c8 commit 8e92a78

11 files changed

+97
-107
lines changed

numba/decorators.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from . import config, sigutils
1313
from .errors import DeprecationError, NumbaDeprecationWarning
1414
from .targets import registry
15+
from .targets import cpu_dispatcher
1516
from .stencil import stencil
1617

1718

numba/dppy/dispatcher.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import numpy as np
44

5-
from numba.targets.descriptors import TargetDescriptor
6-
from numba.targets.options import TargetOptions
7-
from numba import dppy
5+
#from numba.targets.descriptors import TargetDescriptor
6+
#from numba.targets.options import TargetOptions
7+
#from numba import dppy
88
from numba.dppy import kernel, autojit
99
from .descriptor import dppy_target
1010
#from numba.npyufunc.deviceufunc import (UFuncMechanism, GenerializedUFunc,
@@ -13,14 +13,9 @@
1313
from .. import dispatcher, utils, typing
1414
from .compiler import DPPyCompiler
1515

16-
''' OLD IMPL '''
17-
'''
1816
class DPPyDispatcher(dispatcher.Dispatcher):
19-
targetdescr = cpu_target
17+
targetdescr = dppy_target
2018

21-
def __init__(self, py_func, locals={}, targetoptions={}):
22-
dispatcher.Dispatcher.__init__(self, py_func, locals=locals,
23-
targetoptions=targetoptions, pipeline_class=DPPyCompiler)
2419

2520
def __init__(self, py_func, locals={}, targetoptions={}):
2621
assert not locals
@@ -34,7 +29,7 @@ def compile(self, sig, locals={}, **targetoptions):
3429
assert not locals
3530
options = self.targetoptions.copy()
3631
options.update(targetoptions)
37-
kernel = jit(sig, **options)(self.py_func)
32+
kernel = kernel(sig, **options)(self.py_func)
3833
self._compiled = kernel
3934
if hasattr(kernel, "_npm_context_"):
4035
self._npm_context_ = kernel._npm_context_
@@ -230,4 +225,3 @@ def broadcast_device(self, ary, shape):
230225
strides=strides,
231226
dtype=ary.dtype,
232227
gpu_data=ary.gpu_data)
233-
'''

numba/dppy/initialize.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ def init_jit():
99
return DPPyDispatcher
1010

1111
def initialize_all():
12-
#from numba.targets.registry import dispatcher_registry
13-
#dispatcher_registry.ondemand['dppy'] = init_jit
12+
from numba.targets.registry import dispatcher_registry
13+
dispatcher_registry.ondemand['dppy'] = init_jit
14+
1415
dir_path = os.path.dirname(os.path.realpath(__file__)) + "/dppy_driver"
1516
dpgluelib = 'libdpglue_so.so'
1617
if os.path.isfile(dir_path + "/libdpglue_so.so"):
@@ -38,4 +39,3 @@ def init_guvectorize():
3839
return OclGUFuncVectorize
3940

4041
GUVectorize.target_registry.ondemand['dppy'] = init_guvectorize
41-

numba/dppy/tests/dppy/test_numpy_bit_twiddling_functions.py

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

1212
class TestNumpy_bit_twiddling_functions(DPPYTestCase):
1313
def test_bitwise_and(self):
14-
@njit(target='dppy')
14+
@njit(parallel={'spirv':True})
1515
def f(a, b):
1616
c = np.bitwise_and(a, b)
1717
return c
@@ -25,7 +25,7 @@ def f(a, b):
2525

2626

2727
def test_bitwise_or(self):
28-
@njit(target='dppy')
28+
@njit(parallel={'spirv':True})
2929
def f(a, b):
3030
c = np.bitwise_or(a, b)
3131
return c
@@ -39,7 +39,7 @@ def f(a, b):
3939

4040

4141
def test_bitwise_xor(self):
42-
@njit(target='dppy')
42+
@njit(parallel={'spirv':True})
4343
def f(a, b):
4444
c = np.bitwise_xor(a, b)
4545
return c
@@ -53,7 +53,7 @@ def f(a, b):
5353

5454

5555
def test_bitwise_not(self):
56-
@njit(target='dppy')
56+
@njit(parallel={'spirv':True})
5757
def f(a):
5858
c = np.bitwise_not(a)
5959
return c
@@ -66,7 +66,7 @@ def f(a):
6666

6767

6868
def test_invert(self):
69-
@njit(target='dppy')
69+
@njit(parallel={'spirv':True})
7070
def f(a):
7171
c = np.invert(a)
7272
return c
@@ -79,7 +79,7 @@ def f(a):
7979

8080

8181
def test_left_shift(self):
82-
@njit(target='dppy')
82+
@njit(parallel={'spirv':True})
8383
def f(a, b):
8484
c = np.left_shift(a, b)
8585
return c
@@ -93,7 +93,7 @@ def f(a, b):
9393

9494

9595
def test_right_shift(self):
96-
@njit(target='dppy')
96+
@njit(parallel={'spirv':True})
9797
def f(a, b):
9898
c = np.right_shift(a, b)
9999
return c

numba/dppy/tests/dppy/test_numpy_comparison_functions.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TestNumpy_comparison_functions(DPPYTestCase):
1313
a = np.array([4,5,6])
1414
b = np.array([2,6,6])
1515
def test_greater(self):
16-
@njit(target='dppy')
16+
@njit(parallel={'spirv':True})
1717
def f(a, b):
1818
c = np.greater(a, b)
1919
return c
@@ -24,7 +24,7 @@ def f(a, b):
2424

2525

2626
def test_greater_equal(self):
27-
@njit(target='dppy')
27+
@njit(parallel={'spirv':True})
2828
def f(a, b):
2929
c = np.greater_equal(a, b)
3030
return c
@@ -35,7 +35,7 @@ def f(a, b):
3535

3636

3737
def test_less(self):
38-
@njit(target='dppy')
38+
@njit(parallel={'spirv':True})
3939
def f(a, b):
4040
c = np.less(a, b)
4141
return c
@@ -46,7 +46,7 @@ def f(a, b):
4646

4747

4848
def test_less_equal(self):
49-
@njit(target='dppy')
49+
@njit(parallel={'spirv':True})
5050
def f(a, b):
5151
c = np.less_equal(a, b)
5252
return c
@@ -57,7 +57,7 @@ def f(a, b):
5757

5858

5959
def test_not_equal(self):
60-
@njit(target='dppy')
60+
@njit(parallel={'spirv':True})
6161
def f(a, b):
6262
c = np.not_equal(a, b)
6363
return c
@@ -68,7 +68,7 @@ def f(a, b):
6868

6969

7070
def test_equal(self):
71-
@njit(target='dppy')
71+
@njit(parallel={'spirv':True})
7272
def f(a, b):
7373
c = np.equal(a, b)
7474
return c
@@ -79,7 +79,7 @@ def f(a, b):
7979

8080

8181
def test_logical_and(self):
82-
@njit(target='dppy')
82+
@njit(parallel={'spirv':True})
8383
def f(a, b):
8484
c = np.logical_and(a, b)
8585
return c
@@ -93,7 +93,7 @@ def f(a, b):
9393

9494

9595
def test_logical_or(self):
96-
@njit(target='dppy')
96+
@njit(parallel={'spirv':True})
9797
def f(a, b):
9898
c = np.logical_or(a, b)
9999
return c
@@ -107,7 +107,7 @@ def f(a, b):
107107

108108

109109
def test_logical_xor(self):
110-
@njit(target='dppy')
110+
@njit(parallel={'spirv':True})
111111
def f(a, b):
112112
c = np.logical_xor(a, b)
113113
return c
@@ -121,7 +121,7 @@ def f(a, b):
121121

122122

123123
def test_logical_not(self):
124-
@njit(target='dppy')
124+
@njit(parallel={'spirv':True})
125125
def f(a):
126126
c = np.logical_not(a)
127127
return c
@@ -134,7 +134,7 @@ def f(a):
134134

135135

136136
def test_maximum(self):
137-
@njit(target='dppy')
137+
@njit(parallel={'spirv':True})
138138
def f(a, b):
139139
c = np.maximum(a, b)
140140
return c
@@ -148,7 +148,7 @@ def f(a, b):
148148

149149

150150
def test_minimum(self):
151-
@njit(target='dppy')
151+
@njit(parallel={'spirv':True})
152152
def f(a, b):
153153
c = np.minimum(a, b)
154154
return c
@@ -162,7 +162,7 @@ def f(a, b):
162162

163163

164164
def test_fmax(self):
165-
@njit(target='dppy')
165+
@njit(parallel={'spirv':True})
166166
def f(a, b):
167167
c = np.fmax(a, b)
168168
return c
@@ -176,7 +176,7 @@ def f(a, b):
176176

177177

178178
def test_fmin(self):
179-
@njit(target='dppy')
179+
@njit(parallel={'spirv':True})
180180
def f(a, b):
181181
c = np.fmin(a, b)
182182
return c

numba/dppy/tests/dppy/test_numpy_floating_functions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class TestNumpy_floating_functions(DPPYTestCase):
1212
def test_isfinite(self):
13-
@njit(target='dppy')
13+
@njit(parallel={'spirv':True})
1414
def f(a):
1515
c = np.isfinite(a)
1616
return c
@@ -24,7 +24,7 @@ def f(a):
2424

2525

2626
def test_isinf(self):
27-
@njit(target='dppy')
27+
@njit(parallel={'spirv':True})
2828
def f(a):
2929
c = np.isinf(a)
3030
return c
@@ -37,7 +37,7 @@ def f(a):
3737
self.assertTrue(np.all(c == d))
3838

3939
def test_isnan(self):
40-
@njit(target='dppy')
40+
@njit(parallel={'spirv':True})
4141
def f(a):
4242
c = np.isnan(a)
4343
return c
@@ -51,7 +51,7 @@ def f(a):
5151

5252

5353
def test_floor(self):
54-
@njit(target='dppy')
54+
@njit(parallel={'spirv':True})
5555
def f(a):
5656
c = np.floor(a)
5757
return c
@@ -64,7 +64,7 @@ def f(a):
6464

6565

6666
def test_ceil(self):
67-
@njit(target='dppy')
67+
@njit(parallel={'spirv':True})
6868
def f(a):
6969
c = np.ceil(a)
7070
return c
@@ -77,7 +77,7 @@ def f(a):
7777

7878

7979
def test_trunc(self):
80-
@njit(target='dppy')
80+
@njit(parallel={'spirv':True})
8181
def f(a):
8282
c = np.trunc(a)
8383
return c

0 commit comments

Comments
 (0)