Skip to content

Commit c873896

Browse files
Added comments, and updated README.md
1 parent 49efb61 commit c873896

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

examples/pybind11/use_dpctl_sycl_kernel/README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
## Description
44

55
This extension demonstrates how you can use dpctl Python types,
6-
such as ``dpctl.SyclQueue``, in Pybind11
7-
extensions.
6+
such as ``dpctl.SyclQueue`` and ``dpctl.program.SyclKernel``, in
7+
Pybind11 extensions.
88

99

1010
## Building
@@ -20,10 +20,6 @@ python example.py
2020
# Sample output
2121

2222
```
23-
(idp) [17:25:27 ansatnuc04 use_dpctl_syclqueue]$ python example.py
24-
EU count returned by Pybind11 extension 24
25-
EU count computed by dpctl 24
26-
27-
Computing modular reduction using SYCL on a NumPy array
28-
Offloaded result agrees with reference one computed by NumPy
23+
(dpctl) [17:25:27 ubuntu_vm use_dpctl_syclkernel]$ python example.py
24+
[ 0 2 4 6 8 10 12 14 16 18 20 22 24]
2925
```

examples/pybind11/use_dpctl_sycl_kernel/example.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,26 @@
2222
import dpctl.program as dppr
2323
import dpctl.tensor as dpt
2424

25+
# create execution queue, targeting default selected device
2526
q = dpctl.SyclQueue()
2627

28+
# read SPIR-V: a program in Khronos standardized intermediate form
2729
with open("resource/double_it.spv", "br") as fh:
2830
il = fh.read()
2931

32+
# Build the program for the selected device
3033
pr = dppr.create_program_from_spirv(q, il, "")
3134
assert pr.has_sycl_kernel("double_it")
3235

36+
# Retrieve the kernel from the problem
3337
krn = pr.get_sycl_kernel("double_it")
3438
assert krn.num_args == 2
3539

40+
# Construct the argument, and allocate memory for the result
3641
x = dpt.arange(0, stop=13, step=1, dtype="i4", sycl_queue=q)
3742
y = dpt.empty_like(x)
3843

39-
eg.submit_custom_kernel(q, krn, x, y)
44+
eg.submit_custom_kernel(q, krn, src=x, dst=y)
4045

46+
# output the result
4147
print(dpt.asnumpy(y))

0 commit comments

Comments
 (0)