Skip to content

Commit 60c5523

Browse files
Merge branch 'master' into dpctl_c_api-constructors
2 parents 3a19c84 + a0b840b commit 60c5523

23 files changed

+1958
-31
lines changed

.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ per-file-ignores =
2323
dpctl/memory/_memory.pyx: E999, E225, E226, E227
2424
dpctl/program/_program.pyx: E999, E225, E226, E227
2525
dpctl/tensor/_usmarray.pyx: E999, E225, E226, E227
26+
dpctl/tensor/_dlpack.pyx: E999, E225, E226, E227
2627
dpctl/tensor/numpy_usm_shared.py: F821
2728
dpctl/tests/_cython_api.pyx: E999, E225, E227, E402
2829
dpctl/utils/_compute_follows_data.pyx: E999, E225, E227

.github/workflows/conda-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ jobs:
215215
216216
upload_linux:
217217
needs: test_linux
218-
if: ${{github.ref == 'refs/heads/master' || (startsWith(github.ref, 'refs/heads/release') == true)}}
218+
if: ${{github.ref == 'refs/heads/master' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/')}}
219219
runs-on: ubuntu-latest
220220
strategy:
221221
matrix:
@@ -240,7 +240,7 @@ jobs:
240240
241241
upload_windows:
242242
needs: test_windows
243-
if: ${{github.ref == 'refs/heads/master' || (startsWith(github.ref, 'refs/heads/release') == true)}}
243+
if: ${{github.ref == 'refs/heads/master' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/')}}
244244
runs-on: windows-latest
245245
strategy:
246246
matrix:

.github/workflows/os-llvm-sycl-build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ jobs:
1010
runs-on: ubuntu-20.04
1111

1212
env:
13-
OCLCPUEXP_FN: oclcpuexp-2021.12.6.0.19_rel.tar.gz
14-
FPGAEMU_FN: fpgaemu-2021.12.6.0.19_rel.tar.gz
13+
OCLCPUEXP_FN: oclcpuexp-2021.12.9.0.24_rel.tar.gz
14+
FPGAEMU_FN: fpgaemu-2021.12.9.0.24_rel.tar.gz
1515
TBB_FN: oneapi-tbb-2021.4.0-lin.tgz
1616

1717
steps:
@@ -48,8 +48,8 @@ jobs:
4848
export DOWNLOAD_URL_PREFIX=https://github.com/intel/llvm/releases/download
4949
rm -rf dpcpp-compiler.tar.gz
5050
wget ${DOWNLOAD_URL_PREFIX}/${NIGHTLY_TAG}/dpcpp-compiler.tar.gz && echo ${LATEST_LLVM_TAG_SHA} > bundle_id.txt || rm -rf bundle_id.txt
51-
[ -f ${OCLCPUEXP_FN} ] || wget ${DOWNLOAD_URL_PREFIX}/2021-07/${OCLCPUEXP_FN} || rm -rf bundle_id.txt
52-
[ -f ${FPGAEMU_FN} ] || wget ${DOWNLOAD_URL_PREFIX}/2021-07/${FPGAEMU_FN} || rm -rf bundle_id.txt
51+
[ -f ${OCLCPUEXP_FN} ] || wget ${DOWNLOAD_URL_PREFIX}/2021-09/${OCLCPUEXP_FN} || rm -rf bundle_id.txt
52+
[ -f ${FPGAEMU_FN} ] || wget ${DOWNLOAD_URL_PREFIX}/2021-09/${FPGAEMU_FN} || rm -rf bundle_id.txt
5353
[ -f ${TBB_FN} ] || wget https://github.com/oneapi-src/oneTBB/releases/download/v2021.4.0/${TBB_FN} || rm -rf bundle_id.txt
5454
rm -rf dpcpp_compiler
5555
tar xf dpcpp-compiler.tar.gz

CHANGELOG.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,29 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Next Release] - TBD
7+
## [Unreleased]
88

9+
### Added
10+
- `dpctl.tensor.asarray`, `dpctl.tensor.empty` implemented (#646).
11+
- `dpctl.tensor.usm_ndarray` adds support for DLPack protocol. `dpctl.tensor.from_dlpack` implemented (#682).
12+
13+
### Changed
914
- dpctl-capi is now renamed to `libsyclinterface` (#666).
1015

16+
## [0.11.3] - 11/30/2021
17+
18+
### Fixed
19+
20+
- Set the last byte in allocated char array to zero [cherry picked from #650] (#699)
21+
22+
## [0.11.2] - 11/29/2021
23+
24+
### Added
25+
- Extending `dpctl.device_context` with nested contexts (#678)
26+
27+
### Fixed
28+
- Fixed issue #649 about incorrect behavior of `.T` method on sliced arrays (#653)
29+
1130
## [0.11.1] - 11/10/2021
1231

1332
### Changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ include dpctl/memory/_memory.h
1414
include dpctl/memory/_memory_api.h
1515
include dpctl/tensor/_usmarray.h
1616
include dpctl/tensor/_usmarray_api.h
17+
recursive-include dpctl/tensor/include *
1718
include dpctl/tests/input_files/*
1819
include dpctl/tests/*.pyx

dpctl/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
get_current_queue,
6262
get_num_activated_queues,
6363
is_in_device_context,
64+
nested_context_factories,
6465
set_global_queue,
6566
)
6667

@@ -111,6 +112,7 @@
111112
"get_current_queue",
112113
"get_num_activated_queues",
113114
"is_in_device_context",
115+
"nested_context_factories",
114116
"set_global_queue",
115117
]
116118
__all__ += [

dpctl/_sycl_queue_manager.pyx

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# cython: linetrace=True
2020

2121
import logging
22-
from contextlib import contextmanager
22+
from contextlib import ExitStack, contextmanager
2323

2424
from .enum_types import backend_type, device_type
2525

@@ -210,6 +210,22 @@ cpdef get_current_backend():
210210
return _mgr.get_current_backend()
211211

212212

213+
nested_context_factories = []
214+
215+
216+
def _get_nested_contexts(ctxt):
217+
_help_numba_dppy()
218+
return (factory(ctxt) for factory in nested_context_factories)
219+
220+
221+
def _help_numba_dppy():
222+
"""Import numba-dppy for registering nested contexts"""
223+
try:
224+
import numba_dppy
225+
except Exception:
226+
pass
227+
228+
213229
@contextmanager
214230
def device_context(arg):
215231
"""
@@ -223,6 +239,9 @@ def device_context(arg):
223239
the context manager's scope. The yielded queue is removed as the currently
224240
usable queue on exiting the context manager.
225241
242+
You can register context factory in the list of factories.
243+
This context manager uses context factories to create and activate nested contexts.
244+
226245
Args:
227246
arg : A :class:`dpctl.SyclQueue` object, or a :class:`dpctl.SyclDevice`
228247
object, or a filter selector string.
@@ -244,11 +263,26 @@ def device_context(arg):
244263
with dpctl.device_context("level0:gpu:0"):
245264
do_something_on_gpu0()
246265
266+
The following example registers nested context factory:
267+
268+
.. code-block:: python
269+
270+
import dctl
271+
272+
def factory(sycl_queue):
273+
...
274+
return context
275+
276+
dpctl.nested_context_factories.append(factory)
277+
247278
"""
248279
ctxt = None
249280
try:
250281
ctxt = _mgr._set_as_current_queue(arg)
251-
yield ctxt
282+
with ExitStack() as stack:
283+
for nested_context in _get_nested_contexts(ctxt):
284+
stack.enter_context(nested_context)
285+
yield ctxt
252286
finally:
253287
# Code to release resource
254288
if ctxt:

dpctl/tensor/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,20 @@
3333
from dpctl.tensor._copy_utils import copy_from_numpy as from_numpy
3434
from dpctl.tensor._copy_utils import copy_to_numpy as asnumpy
3535
from dpctl.tensor._copy_utils import copy_to_numpy as to_numpy
36+
from dpctl.tensor._ctors import asarray, empty
37+
from dpctl.tensor._dlpack import from_dlpack
3638
from dpctl.tensor._reshape import reshape
3739
from dpctl.tensor._usmarray import usm_ndarray
3840

3941
__all__ = [
4042
"usm_ndarray",
43+
"asarray",
4144
"astype",
4245
"copy",
46+
"empty",
4347
"reshape",
4448
"from_numpy",
4549
"to_numpy",
4650
"asnumpy",
51+
"from_dlpack",
4752
]

dpctl/tensor/_copy_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ def copy_to_numpy(ary):
9393
)
9494

9595

96-
def copy_from_numpy(np_ary, usm_type="device", queue=None):
96+
def copy_from_numpy(np_ary, usm_type="device", sycl_queue=None):
9797
"Copies numpy array `np_ary` into a new usm_ndarray"
9898
# This may peform a copy to meet stated requirements
9999
Xnp = np.require(np_ary, requirements=["A", "O", "C", "E"])
100-
if queue:
101-
ctor_kwargs = {"queue": queue}
100+
if sycl_queue:
101+
ctor_kwargs = {"queue": sycl_queue}
102102
else:
103103
ctor_kwargs = dict()
104104
Xusm = dpt.usm_ndarray(

0 commit comments

Comments
 (0)