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

Commit b5bdbab

Browse files
authored
Merge pull request #117 from PokhodenkoSA/numba-dppy
Add subtree numba-dppy
2 parents 943884f + 97130d9 commit b5bdbab

Some content is hidden

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

76 files changed

+10581
-0
lines changed

numba-dppy/LICENSE

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Copyright (c) 2019-2020, Intel Corporation
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
2. Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

numba-dppy/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# numba-dppy
2+
3+
## Numba + dpCtl + dpNP = numba-dppy
4+
5+
`numba-dppy` extends Numba with new backend for support compilation
6+
for Intel CPU and GPU architectures.
7+
8+
For more information about Numba, see the Numba homepage:
9+
http://numba.pydata.org
10+
11+
For more information about dpCtl, see the dpCtl homepage:
12+
https://intelpython.github.io/dpctl/
13+
14+
For more information about dpNP, see the dpNP homepage:
15+
https://intelpython.github.io/dpnp/
16+
17+
## Dependencies
18+
19+
* numba
20+
* dpCtl
21+
* dpNP (optional)

numba-dppy/numba_dppy/.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

numba-dppy/numba_dppy/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.

numba-dppy/numba_dppy/__init__.py

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

numba-dppy/numba_dppy/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)