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

Commit 57b6890

Browse files
committed
Add 'dppl/' from commit 'fa996e3adbfef446d97c4f3b7f6565f57abc9e40'
git-subtree-dir: dppl git-subtree-mainline: c144045 git-subtree-split: fa996e3
2 parents c144045 + fa996e3 commit 57b6890

74 files changed

Lines changed: 10538 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎dppl/.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.bc
2+
*.ll
3+
*.spirv

‎dppl/CHANGE_LOG‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
NUMBA Version 0.48.0 + DPPL Version 0.3.0 (June 29, 2020)
2+
--------------------------------------------------------
3+
4+
This release includes:
5+
6+
* Caching of dppl.kernels which will improve performance.
7+
* Addition of support for Intel Advisor which will help in profiling applications.

‎dppl/__init__.py‎

Lines changed: 519 additions & 0 deletions
Large diffs are not rendered by default.

‎dppl/codegen.py‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
from llvmlite import binding as ll
2+
from llvmlite.llvmpy import core as lc
3+
4+
from numba.core.codegen import BaseCPUCodegen, CodeLibrary
5+
from numba.core import utils
6+
7+
8+
SPIR_TRIPLE = {32: ' spir-unknown-unknown',
9+
64: 'spir64-unknown-unknown'}
10+
11+
SPIR_DATA_LAYOUT = {
12+
32 : ('e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:'
13+
'256-v512:512-v1024:1024'),
14+
64 : ('e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-'
15+
'v512:512-v1024:1024')
16+
}
17+
18+
19+
class SPIRVCodeLibrary(CodeLibrary):
20+
def _optimize_functions(self, ll_module):
21+
pass
22+
23+
def _optimize_final_module(self):
24+
# Run some lightweight optimization to simplify the module.
25+
pmb = ll.PassManagerBuilder()
26+
pmb.opt_level = 1
27+
pmb.disable_unit_at_a_time = False
28+
pmb.disable_unroll_loops = True
29+
pmb.loop_vectorize = False
30+
pmb.slp_vectorize = False
31+
32+
pm = ll.ModulePassManager()
33+
pmb.populate(pm)
34+
pm.run(self._final_module)
35+
36+
def _finalize_specific(self):
37+
# Fix global naming
38+
for gv in self._final_module.global_variables:
39+
if '.' in gv.name:
40+
gv.name = gv.name.replace('.', '_')
41+
42+
def get_asm_str(self):
43+
# Return nothing: we can only dump assembler code when it is later
44+
# generated (in numba.dppl.compiler).
45+
return None
46+
47+
48+
class JITSPIRVCodegen(BaseCPUCodegen):
49+
"""
50+
This codegen implementation generates optimized SPIR 2.0
51+
"""
52+
53+
_library_class = SPIRVCodeLibrary
54+
55+
def _init(self, llvm_module):
56+
assert list(llvm_module.global_variables) == [], "Module isn't empty"
57+
self._data_layout = SPIR_DATA_LAYOUT[utils.MACHINE_BITS]
58+
self._target_data = ll.create_target_data(self._data_layout)
59+
60+
def _create_empty_module(self, name):
61+
ir_module = lc.Module(name)
62+
ir_module.triple = SPIR_TRIPLE[utils.MACHINE_BITS]
63+
if self._data_layout:
64+
ir_module.data_layout = self._data_layout
65+
return ir_module
66+
67+
def _module_pass_manager(self):
68+
raise NotImplementedError
69+
70+
def _function_pass_manager(self, llvm_module):
71+
raise NotImplementedError
72+
73+
def _add_module(self, module):
74+
pass

0 commit comments

Comments
 (0)