Skip to content

Commit 458f502

Browse files
Removed uses of device_context
1 parent 6770f73 commit 458f502

File tree

3 files changed

+17
-24
lines changed

3 files changed

+17
-24
lines changed

doc/dpctl.rst

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,23 @@ Interplay with the Data Parallel Control Library
1010
An example below demonstrates how the Data Parallel Extension for NumPy* can be
1111
easily combined with the device management interface provided by dpctl package.
1212

13-
Literally, the SYCL* queue manager interface from the dpctl package allows
14-
to set an input queue as the currently usable queue inside the context
15-
manager's scope. This way an array creation function from the dpnp package
16-
which is defined inside the context will allocate the data using that queue.
17-
1813
.. code-block:: python
1914
:linenos:
2015
21-
import dpctl
22-
import dpnp as np
16+
import dpctl
17+
import dpnp
18+
19+
d = dpctl.select_cpu_device()
20+
x = dpnp.array([1, 2, 3], device=d)
21+
s = dpnp.sum(x)
22+
23+
y = dpnp.linspace(0, dpnp.pi, num=10**6, device="gpu")
24+
f = 1 + y * dpnp.sin(y)
2325
24-
with dpctl.device_context("opencl:gpu"):
25-
x = np.array([1, 2, 3])
26-
s = np.sum(x)
26+
# locate argument where function attains global maximum
27+
max_arg = x[dpnp.argmax(f)]
28+
max_val = dpnp.max(f)
29+
2730
2831
For more information please refer to `Data Parallel Control Library`_
2932
documentation.

examples/example10.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,7 @@ def example():
8787

8888

8989
if __name__ == "__main__":
90-
try:
91-
import dpctl
90+
import dpctl
9291

93-
with dpctl.device_context("opencl:gpu") as gpu_queue:
94-
gpu_queue.get_sycl_device().print_device_info()
95-
example()
96-
97-
except ImportError:
98-
example()
92+
dpctl.select_default_device().print_device_info()
93+
example()

tests/third_party/intel/zero-copy-test1.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,7 @@ def dppy_f(array_like_obj):
6262
hb = np.arange(0, global_size, dtype="i4")
6363
da = DuckUSMArray(hb.shape, dtype=hb.dtype, host_buffer=hb)
6464

65-
if dpctl.has_gpu_queues(dpctl.backend_type.level_zero):
66-
print("\nScheduling on OpenCL GPU\n")
67-
with dpctl.device_context("opencl:gpu") as gpu_queue:
68-
dppy_f[global_size, dppy.DEFAULT_LOCAL_SIZE](da)
69-
else:
70-
print("\nSkip scheduling on OpenCL GPU\n")
65+
dppy_f[global_size, dppy.DEFAULT_LOCAL_SIZE](da)
7166

7267
assert da[0] == 10
7368

0 commit comments

Comments
 (0)