Skip to content

Commit 27715a0

Browse files
Added examples/README.md, and more readme files to sub-directories
Also added `dpctl/tensor/__init__.pxd` so that one can do `cimport dpctl.tensor`. Used that in `cython/usm_memory` example.
1 parent 22d59d7 commit 27715a0

File tree

8 files changed

+110
-1
lines changed

8 files changed

+110
-1
lines changed

dpctl/tensor/__init__.pxd

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Data Parallel Control (dpctl)
2+
#
3+
# Copyright 2020-2023 Intel Corporation
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
""" This file declares the extension types and functions for the Cython API
18+
implemented in _usmarray.pyx file.
19+
"""
20+
21+
# distutils: language = c++
22+
# cython: language_level=3
23+
24+
from dpctl.tensor._usmarray cimport *

examples/README.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Examples of using `dpctl`
2+
3+
The `dpctl` is a foundational package facilitating use of [SYCL](sycl) to extend Python's reach to heterogeneous systems.
4+
5+
## Python
6+
7+
The `dpctl` provides Python API to SYCL runtime permitting user to
8+
inspect the heterogeneous [platform],
9+
[select](device_seelection) amongst available devices,
10+
query [properties](device_descriptors) of created devices,
11+
and construct [queues] to specify execution placement of offloaded computation.
12+
13+
Additionally, `dpctl.tensor` submodule allows to create ND-arrays on devices and manipulate them using `dpctl.tensor` library of array computation operations specified in [Python Array API standard](array_api).
14+
15+
Examples of this functionality are located in the [python](python) folder.
16+
17+
## Cython
18+
19+
The `dpctl` integrates with [Cython], a native extension generator, to facilitate building
20+
SYCL-powered Python extensions.
21+
22+
Examples of Python extensions written using Cython are located in the [cython](cython) folder.
23+
24+
## Pybind11
25+
26+
Since [SYCL](sycl) is based on C++, [pybind11] is a natural tool of choice to author SYCL-powered
27+
Python extensions. The `dpctl` provides `dpctl4pybind11.hpp` integration header to provide natural
28+
mapping between SYCL C++ classes and `dpctl` Python types.
29+
30+
Examples of Python extensions created with `pybind11` are located in the [pybind11](pybind11) folder.
31+
32+
## C
33+
34+
The `dpctl` implements `DPCTLSyclInterface` C library and C-API to work with Python objects and types
35+
implemented in `dpctl`. Use integration headers `dpctl_sycl_interface.h` and `dpctl_capi.h` to access
36+
this functionality.
37+
38+
Examples of Python extensions created using C are located in [c](c) folder.
39+
40+
41+
[platform]: https://intelpython.github.io/dpctl/latest/docfiles/user_guides/manual/dpctl/platforms.html
42+
[device_selection]: https://intelpython.github.io/dpctl/latest/docfiles/user_guides/manual/dpctl/device_selection.html
43+
[device_descriptors]: https://intelpython.github.io/dpctl/latest/docfiles/user_guides/manual/dpctl/devices.html#device-aspects-and-information-descriptors
44+
[queues]: https://intelpython.github.io/dpctl/latest/docfiles/user_guides/manual/dpctl/queues.html
45+
[array_api]: https://data-apis.org/array-api/
46+
[sycl]: https://registry.khronos.org/SYCL/
47+
[Cython]: https://cython.org/
48+
[pybind11]: https://pybind11.readthedocs.io

examples/c/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Examples C-based Python extensions using `dpctl`
2+
3+
The `dpctl` implements `DPCTLSyclInterface` C library as well as provides C-API to work with Python objects
4+
and types implemented in `dpctl`. Use integration headers `dpctl_sycl_interface.h` and `dpctl_capi.h` to access
5+
this functionality.
6+
7+
Use `python -m dpctl --includes` to get include compiler options and `python -m dpctl --library` to get linking options to link
8+
to `SyclInterface` library.

examples/c/py_sycl_ls/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Python module to enumerate SYCL devices
2+
3+
## Building
4+
5+
```bash
6+
python setup.py build_ext --inplace
7+
```
8+
9+
## Testing
10+
11+
```
12+
pytest -m tests
13+
```
14+
15+
## Running
16+
17+
```
18+
python -m py_sycl_ls
19+
```

examples/cython/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Examples of data-parallel Python extensions written in Cython
2+
3+
The `dpctl` package provides Cython definition files for types it defines.
4+
5+
Use `cimport dpctl as c_dpctl`, `cimport dpctl.memory as c_dpm`, or `cimport dpctl.tensor as c_dpt`
6+
to use these definitions.
7+
8+
Cython definition fille `dpctl.sycl` provides incomplete definitions of core SYCL runtime classes as
9+
well as conversion routine between `SyclInterface` reference types and SYCL runtime classes.

examples/cython/usm_memory/blackscholes/blackscholes.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ cimport numpy as cnp
2121
from cython cimport floating
2222

2323
cimport dpctl as c_dpctl
24-
cimport dpctl.tensor._usmarray as c_dpt
24+
cimport dpctl.tensor as c_dpt
2525
from dpctl.sycl cimport queue as dpcpp_queue
2626
from dpctl.sycl cimport unwrap_queue
2727

examples/pybind11/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Examples of data-parallel Python extensions written with pybind11

examples/python/README.md

Whitespace-only changes.

0 commit comments

Comments
 (0)