Skip to content

Commit fe1688d

Browse files
committed
defines an AbstractComputeBackend type
1 parent 8ea1cb4 commit fe1688d

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

pyop2/backends/__init__.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
class _not_implemented: # noqa
2+
"""Not Implemented"""
3+
4+
5+
class AbstractComputeBackend:
6+
"""
7+
Abstract class to record all the backend specific implementation of
8+
:mod:`pyop2`'s data structures.
9+
"""
10+
GlobalKernel = _not_implemented
11+
Parloop = _not_implemented
12+
Set = _not_implemented
13+
ExtrudedSet = _not_implemented
14+
MixedSet = _not_implemented
15+
Subset = _not_implemented
16+
DataSet = _not_implemented
17+
MixedDataSet = _not_implemented
18+
Map = _not_implemented
19+
MixedMap = _not_implemented
20+
Dat = _not_implemented
21+
MixedDat = _not_implemented
22+
DatView = _not_implemented
23+
Mat = _not_implemented
24+
Global = _not_implemented
25+
GlobalDataSet = _not_implemented
26+
PETScVecType = _not_implemented
27+
28+
def _getattr_(self, key):
29+
val = super(AbstractComputeBackend, self)._getattr_(key)
30+
if val is _not_implemented:
31+
raise NotImplementedError("'{}' is not implemented for backend"
32+
" '{}'.".format(val, self.__name__))
33+
return val
34+
35+
def turn_on_offloading(self):
36+
raise NotImplementedError()
37+
38+
def turn_off_offloading(self):
39+
raise NotImplementedError()
40+
41+
@property
42+
def cache_key(self):
43+
raise NotImplementedError()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def run(self):
147147
install_requires=install_requires,
148148
dependency_links=dep_links,
149149
test_requires=test_requires,
150-
packages=['pyop2', 'pyop2.codegen', 'pyop2.types'],
150+
packages=['pyop2', 'pyop2.backends', 'pyop2.codegen', 'pyop2.types'],
151151
package_data={
152152
'pyop2': ['assets/*', '*.h', '*.pxd', '*.pyx', 'codegen/c/*.c']},
153153
scripts=glob('scripts/*'),

0 commit comments

Comments
 (0)