Skip to content

Commit e45a4eb

Browse files
committed
Merge branch 'main' into gold/2021
2 parents 6594b30 + 5adaa41 commit e45a4eb

File tree

222 files changed

+3105
-2262
lines changed

Some content is hidden

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

222 files changed

+3105
-2262
lines changed

.flake8

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ exclude =
1717
.git,
1818
__pycache__,
1919
_version.py,
20-
numpy_usm_shared.py,
2120
lowerer.py,

.github/workflows/conda-package.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
run: ./scripts/build_conda_package.sh ${{ matrix.python }}
3737

3838
- name: Upload artifact
39-
uses: actions/upload-artifact@v2
39+
uses: actions/upload-artifact@v3
4040
with:
4141
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
4242
path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.tar.bz2
@@ -64,7 +64,7 @@ jobs:
6464
activate-environment: ""
6565

6666
- name: Cache conda packages
67-
uses: actions/cache@v2
67+
uses: actions/cache@v3
6868
env:
6969
CACHE_NUMBER: 0 # Increase to reset cache
7070
with:
@@ -79,7 +79,7 @@ jobs:
7979
- name: Build conda package
8080
run: conda build --no-test --python ${{ matrix.python }} ${{ env.CHANNELS }} conda-recipe
8181
- name: Upload artifact
82-
uses: actions/upload-artifact@v2
82+
uses: actions/upload-artifact@v3
8383
with:
8484
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} ${{ matrix.artifact_name }}
8585
path: ${{ env.conda-bld }}${{ env.PACKAGE_NAME }}-*.tar.bz2
@@ -96,7 +96,7 @@ jobs:
9696

9797
steps:
9898
- name: Download artifact
99-
uses: actions/download-artifact@v2
99+
uses: actions/download-artifact@v3
100100
with:
101101
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
102102

@@ -146,7 +146,7 @@ jobs:
146146
conda activate numba_dpex_env
147147
# echo "libintelocl.so" | tee /etc/OpenCL/vendors/intel-cpu.icd
148148
export OCL_ICD_FILENAMES=libintelocl.so
149-
for script in $(find . \( -not -name "_*" -not "vector_sum2D.py" -not -name "vectorize.py" -not -name "scan.py" -and -name "*.py" \))
149+
for script in $(find . \( -not -name "_*" -not -name "vector_sum2D.py" -not -name "vectorize.py" -not -name "scan.py" -and -name "*.py" \))
150150
do
151151
echo "Executing ${script}"
152152
python ${script} || exit 1
@@ -195,7 +195,7 @@ jobs:
195195
- name: Collect dependencies
196196
run: conda install ${{ env.PACKAGE_NAME }} python=${{ matrix.python }} -c $env:GITHUB_WORKSPACE/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile
197197
- name: Cache conda packages
198-
uses: actions/cache@v2
198+
uses: actions/cache@v3
199199
env:
200200
CACHE_NUMBER: 1 # Increase to reset cache
201201
with:
@@ -250,6 +250,8 @@ jobs:
250250
251251
- name: Add dpnp skip variable
252252
run: echo "NUMBA_DPEX_TESTING_SKIP_NO_DPNP=1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
253+
- name: Smoke test
254+
run: python -c "import numba_dpex.core.runtime._dpexrt_python"
253255
- name: Run tests
254256
run: |
255257
python -m pytest -q -ra --disable-warnings --pyargs ${{ env.MODULE_NAME }} -vv
@@ -263,7 +265,7 @@ jobs:
263265
python: ["3.8", "3.9", "3.10"]
264266
steps:
265267
- name: Download artifact
266-
uses: actions/download-artifact@v2
268+
uses: actions/download-artifact@v3
267269
with:
268270
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
269271

@@ -291,7 +293,7 @@ jobs:
291293
python: ["3.8", "3.9", "3.10"]
292294
steps:
293295
- name: Download artifact
294-
uses: actions/download-artifact@v2
296+
uses: actions/download-artifact@v3
295297
with:
296298
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
297299

numba_dpex/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
# SPDX-FileCopyrightText: 2020 - 2022 Intel Corporation
1+
# SPDX-FileCopyrightText: 2020 - 2023 Intel Corporation
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

55
"""
66
The numba-dpex extension module adds data-parallel offload support to Numba.
77
"""
8-
import numba.testing
98

9+
import numba_dpex.core.dpjit_dispatcher
1010
import numba_dpex.core.offload_dispatcher
1111

12+
# Initialize the _dpexrt_python extension
13+
import numba_dpex.core.runtime
14+
import numba_dpex.core.targets.dpjit_target
15+
1216
# Re-export types itself
1317
import numba_dpex.core.types as types
1418
from numba_dpex.core.kernel_interface.utils import *

numba_dpex/_version.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# SPDX-FileCopyrightText: 2023 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
14

25
# This file helps to compute a version number in source trees obtained from
36
# git-archive tarball (such as those provided by githubs download-from-tag

numba_dpex/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2020 - 2022 Intel Corporation
1+
# SPDX-FileCopyrightText: 2020 - 2023 Intel Corporation
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

numba_dpex/core/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
# SPDX-FileCopyrightText: 2020 - 2022 Intel Corporation
1+
# SPDX-FileCopyrightText: 2020 - 2023 Intel Corporation
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
65
from .datamodel import *
7-
from .dpnp_ndarray import dpnp_empty
86
from .types import *
97
from .typing import *

numba_dpex/core/caching.py

Lines changed: 8 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,13 @@
1-
# SPDX-FileCopyrightText: 2020 - 2022 Intel Corporation
1+
# SPDX-FileCopyrightText: 2020 - 2023 Intel Corporation
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
import hashlib
65
import sys
76
from abc import ABCMeta, abstractmethod
87

98
from numba.core.caching import CacheImpl, IndexDataCacheFile
10-
from numba.core.serialize import dumps
119

1210
from numba_dpex import config
13-
from numba_dpex.core.types import USMNdArray
14-
15-
16-
def build_key(argtypes, pyfunc, codegen, backend=None, device_type=None):
17-
"""Constructs a key from python function, context, backend and the device
18-
type.
19-
20-
Compute index key for the given argument types and codegen. It includes a
21-
description of the OS, target architecture and hashes of the bytecode for
22-
the function and, if the function has a __closure__, a hash of the
23-
cell_contents.type
24-
25-
Args:
26-
argtypes : A tuple of numba types corresponding to the arguments to the
27-
compiled function.
28-
pyfunc : The Python function that is to be compiled and cached.
29-
codegen (numba.core.codegen.Codegen):
30-
The codegen object found from the target context.
31-
backend (enum, optional): A 'backend_type' enum.
32-
Defaults to None.
33-
device_type (enum, optional): A 'device_type' enum.
34-
Defaults to None.
35-
36-
Returns:
37-
tuple: A tuple of return type, argtpes, magic_tuple of codegen
38-
and another tuple of hashcodes from bytecode and cell_contents.
39-
"""
40-
41-
codebytes = pyfunc.__code__.co_code
42-
if pyfunc.__closure__ is not None:
43-
try:
44-
cvars = tuple([x.cell_contents for x in pyfunc.__closure__])
45-
# Note: cloudpickle serializes a function differently depending
46-
# on how the process is launched; e.g. multiprocessing.Process
47-
cvarbytes = dumps(cvars)
48-
except:
49-
cvarbytes = b"" # a temporary solution for function template
50-
else:
51-
cvarbytes = b""
52-
53-
argtylist = list(argtypes)
54-
for i, argty in enumerate(argtylist):
55-
if isinstance(argty, USMNdArray):
56-
# Convert the USMNdArray to an abridged type that disregards the
57-
# usm_type, device, queue, address space attributes.
58-
argtylist[i] = (argty.ndim, argty.dtype, argty.layout)
59-
60-
argtypes = tuple(argtylist)
61-
62-
return (
63-
argtypes,
64-
codegen.magic_tuple(),
65-
backend,
66-
device_type,
67-
(
68-
hashlib.sha256(codebytes).hexdigest(),
69-
hashlib.sha256(cvarbytes).hexdigest(),
70-
),
71-
)
7211

7312

7413
class _CacheImpl(CacheImpl):
@@ -471,8 +410,13 @@ def put(self, key, value):
471410
self._name, len(self._lookup), str(key)
472411
)
473412
)
474-
self._lookup[key].value = value
475-
self.get(key)
413+
node = self._lookup[key]
414+
node.value = value
415+
416+
if node is not self._tail:
417+
self._unlink_node(node)
418+
self._append_tail(node)
419+
476420
return
477421

478422
if key in self._evicted:

numba_dpex/core/codegen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2020 - 2022 Intel Corporation
1+
# SPDX-FileCopyrightText: 2020 - 2023 Intel Corporation
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

numba_dpex/core/compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2022 Intel Corporation
1+
# SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

numba_dpex/core/datamodel/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# SPDX-FileCopyrightText: 2022 Intel Corporation
1+
# SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation
22
#
33
# SPDX-License-Identifier: Apache-2.0

0 commit comments

Comments
 (0)