|
2 | 2 | [](https://pycqa.github.io/isort/)
|
3 | 3 | [](https://coveralls.io/github/IntelPython/dpctl?branch=master)
|
4 | 4 |
|
5 |
| -About dpctl |
6 |
| -=========== |
7 |
| - |
8 |
| -<img align="left" src="https://spec.oneapi.io/oneapi-logo-white-scaled.jpg" alt="oneAPI logo" /> |
9 |
| - |
10 |
| -`dpctl` (data parallel control) is a lightweight [Python package](https://intelpython.github.io/dpctl) exposing a |
11 |
| -subset of the Intel(R) oneAPI DPC++ [runtime classes](https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#_sycl_runtime_classes) |
12 |
| -that is distributed as part of [Intel(R) Distribution for Python*](https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/distribution-for-python.html) and |
13 |
| -is included in Intel(R) [oneAPI](https://oneapi.io) [Base ToolKit](https://software.intel.com/content/www/us/en/develop/tools/oneapi/base-toolkit.html). |
14 |
| -`dpctl` lets Python users query SYCL platforms, discover and represent SYCL devices, and construct SYCL queues to control data-parallel code execution on [Intel(R) XPUs](https://www.intel.com/content/www/us/en/newsroom/news/xpu-vision-oneapi-server-gpu.html) from Python. |
15 |
| - |
16 |
| -`dpctl` features classes representing [SYCL unified shared memory](https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:usm) |
17 |
| -allocations as well as higher-level objects such as [`dpctl.tensor.usm_ndarray`](https://intelpython.github.io/dpctl/latest/docfiles/dpctl.tensor_api.html#module-dpctl.tensor) on top of USM allocations. |
18 |
| - |
19 |
| -`dpctl` assists authors of Python native extensions written in C, |
20 |
| -Cython, or pybind11 to use its `dpctl.SyclQueue` object to indicate the offload |
21 |
| -target as well as objects in `dpctl.memory` and `dpctl.tensor` submodules to |
22 |
| -represent USM allocations that are accessible from within data-parallel code executed |
23 |
| -on the target queue. |
24 |
| - |
25 |
| -`dpctl.tensor` submodule provides an array container representing an array in a |
26 |
| -strided layout on top of a USM allocation. The submodule provides an array-API |
27 |
| -conforming oneAPI DPC++ powered library to manipulate the array container. |
28 |
| - |
29 |
| -Requirements |
30 |
| -============ |
31 |
| -- Install Conda |
32 |
| -- Install Intel oneAPI |
33 |
| - - Set environment variable `ONEAPI_ROOT` |
34 |
| - - Windows: `C:\Program Files (x86)\Intel\oneAPI\` |
35 |
| - - Linux: `/opt/intel/oneapi` |
36 |
| -- Install OpenCL HD graphics drivers |
37 |
| - |
38 |
| -Build and Install Conda Package |
39 |
| -================================== |
40 |
| -1. Create and activate conda build environment |
41 |
| -```bash |
42 |
| -conda create -n build-env conda-build |
43 |
| -conda activate build-env |
44 |
| -``` |
45 |
| -2. Set environment variable `ONEAPI_ROOT` and build conda package |
46 |
| -```bash |
47 |
| -export ONEAPI_ROOT=/opt/intel/oneapi |
48 |
| -conda build conda-recipe -c ${ONEAPI_ROOT}/conda_channel |
49 |
| -``` |
50 |
| -On Windows to cope with [long file names](https://github.com/IntelPython/dpctl/issues/15) |
51 |
| -use `croot` with short folder path: |
52 |
| -```cmd |
53 |
| -set "ONEAPI_ROOT=C:\Program Files (x86)\Intel\oneAPI\" |
54 |
| -conda build --croot=C:/tmp conda-recipe -c "%ONEAPI_ROOT%\conda_channel" |
55 |
| -``` |
56 |
| - |
57 |
| -:warning: **You could face issues with conda-build=3.20**: Use conda-build=3.18! |
| 5 | +About |
| 6 | +===== |
58 | 7 |
|
59 |
| -3. Install conda package |
60 |
| -```bash |
61 |
| -conda install dpctl |
62 |
| -``` |
| 8 | +<img align="left" src="https://spec.oneapi.io/oneapi-logo-white-scaled.jpg" alt="oneAPI logo" width="75"/> |
| 9 | + |
| 10 | +Data Parallel Control (`dpctl`) is a Python library that allows a user |
| 11 | +to *control* the execution placement of a [compute |
| 12 | +kernel](https://en.wikipedia.org/wiki/Compute_kernel) on an |
| 13 | +[XPU](https://www.intel.com/content/www/us/en/newsroom/news/xpu-vision-oneapi-server-gpu.html). |
| 14 | +The compute kernel can be either a code written by the user, *e.g.*, |
| 15 | +using `numba-dppy`, or a code that is part of a library like oneMKL. The `dpctl` |
| 16 | +library is built upon the [SYCL |
| 17 | +standard](https://www.khronos.org/sycl/) and implements Python |
| 18 | +bindings for a subset of the standard [runtime |
| 19 | +classes](https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#_sycl_runtime_classes) |
| 20 | +that allow users to query platforms, discover and represent devices |
| 21 | +and sub-devices, and construct contexts and queues. In addition, |
| 22 | +`dpctl` features classes for [SYCL Unified Shared Memory |
| 23 | +(USM)](https://link.springer.com/chapter/10.1007/978-1-4842-5574-2_6) |
| 24 | +management and implements a tensor [array |
| 25 | +API](https://data-apis.org/array-api/latest/). |
| 26 | + |
| 27 | +The library also assists authors of Python native extensions written |
| 28 | +in C, Cython, or pybind11 to access `dpctl` objects representing SYCL |
| 29 | +devices, queues, memory, and tensors. |
| 30 | + |
| 31 | +`Dpctl` is the core part of a larger family of [data-parallel Python |
| 32 | +libraries and |
| 33 | +tools](https://www.intel.com/content/www/us/en/developer/tools/oneapi/distribution-for-python.html) |
| 34 | +to program XPUs. The library is available via |
| 35 | +[conda](https://anaconda.org/intel/dpctl) and |
| 36 | +[pip](https://pypi.org/project/dpctl/). It is included in the [Intel(R) |
| 37 | +Distribution for |
| 38 | +Python*](https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/distribution-for-python.html) |
| 39 | +(IDP). |
| 40 | + |
| 41 | +Installing |
| 42 | +========== |
| 43 | + |
| 44 | +From Intel oneAPI |
| 45 | +----------------- |
| 46 | + |
| 47 | +`dpctl` is packaged as part of the quarterly Intel oneAPI releases. To |
| 48 | +get the library from the latest oneAPI release please follow the |
| 49 | +instructions from Intel's [oneAPI installation |
| 50 | +guide](https://www.intel.com/content/www/us/en/developer/articles/guide/installation-guide-for-oneapi-toolkits.html). |
| 51 | +Note that you will need to install the Intel BaseKit toolkit to get |
| 52 | +IDP and `dpctl`. |
| 53 | + |
| 54 | +From Conda |
| 55 | +---------- |
| 56 | + |
| 57 | +`dpctl` package is available on the Intel channel on Annaconda |
| 58 | +cloud. You an use the following to install `dpctl` from there: |
63 | 59 |
|
64 |
| -Build and Install with setuptools |
65 |
| -================================= |
66 |
| -dpctl relies on DPC++ runtime. With Intel oneAPI installed you should activate it. |
67 |
| -`setup.py` requires environment variable `ONEAPI_ROOT` and following packages |
68 |
| -installed: |
69 |
| -- `cython` |
70 |
| -- `numpy` |
71 |
| -- `cmake` - for building C API |
72 |
| -- `ninja` - only on Windows |
73 |
| - |
74 |
| -You need DPC++ to build dpctl. If you want to build using the DPC++ in a |
75 |
| -oneAPI distribution, activate DPC++ compiler as follows: |
76 | 60 | ```bash
|
77 |
| -export ONEAPI_ROOT=/opt/intel/oneapi |
78 |
| -source ${ONEAPI_ROOT}/compiler/latest/env/vars.sh |
| 61 | +conda install dpctl -c intel |
79 | 62 | ```
|
80 | 63 |
|
81 |
| -For install: |
82 |
| -```cmd |
83 |
| -python setup.py install |
84 |
| -``` |
85 |
| - |
86 |
| -For development: |
87 |
| -```cmd |
88 |
| -python setup.py develop |
89 |
| -``` |
| 64 | +From PyPi |
| 65 | +--------- |
90 | 66 |
|
91 |
| -It is also possible to build dpctl using [DPC++ toolchain](https://github.com/intel/llvm/blob/sycl/sycl/doc/GetStartedGuide.md) instead of oneAPI DPC++. Instead of activating the oneAPI environment, indicate the toolchain installation prefix with `--sycl-compiler-prefix` option, e.g. |
| 67 | +`dpctl` is also available from PyPi and can be installed using: |
92 | 68 |
|
93 |
| -```cmd |
94 |
| -python setup.py develop --sycl-compiler-prefix=${DPCPP_ROOT}/llvm/build |
95 |
| -``` |
96 |
| - |
97 |
| -Please use `python setup.py develop --help` for more details. |
98 |
| - |
99 |
| -Install Wheel Package from Pypi |
100 |
| -================================== |
101 |
| -1. Install dpctl |
102 |
| -```cmd |
103 |
| -python -m pip install --index-url https://pypi.anaconda.org/intel/simple --extra-index-url https://pypi.org/simple dpctl |
| 69 | +```bash |
| 70 | +pip3 install dpctl |
104 | 71 | ```
|
105 |
| -Note: dpctl wheel package is placed on Pypi, but some of its dependencies (like Intel numpy) are in Anaconda Cloud. |
106 |
| -That is why install command requires additional intel Pypi channel from Anaconda Cloud. |
107 | 72 |
|
108 |
| -2. Set path to Performance Libraries in case of using venv or system Python: |
109 |
| -On Linux: |
110 |
| -```cmd |
111 |
| -export LD_LIBRARY_PATH=<path_to_your_env>/lib |
112 |
| -``` |
113 |
| -On Windows: |
114 |
| -```cmd |
115 |
| -set PATH=<path_to_your_env>\bin;<path_to_your_env>\Library\bin;%PATH% |
116 |
| -``` |
| 73 | +Installing the bleeding edge |
| 74 | +------------------------ |
117 | 75 |
|
118 |
| -Using dpctl |
119 |
| -=========== |
120 |
| -dpctl relies on DPC++ runtime. With Intel oneAPI installed you could activate it. |
| 76 | +If you want to try out the current master, you can install it from our |
| 77 | +development channel on Anaconda cloud: |
121 | 78 |
|
122 |
| -On Windows: |
123 |
| -```cmd |
124 |
| -call "%ONEAPI_ROOT%\compiler\latest\env\vars.bat" |
125 |
| -``` |
126 |
| -On Linux: |
127 | 79 | ```bash
|
128 |
| -source ${ONEAPI_ROOT}/compiler/latest/env/vars.sh |
| 80 | +conda install dpctl -c dppy\label\dev |
129 | 81 | ```
|
130 | 82 |
|
131 |
| -When dpctl is installed via conda package |
132 |
| -then it uses DPC++ runtime from `dpcpp_cpp_rt` package |
133 |
| -and it is not necessary to activate oneAPI DPC++ compiler environment. |
| 83 | +Building |
| 84 | +======== |
134 | 85 |
|
135 |
| -`dpcpp_cpp_rt` package is provided by oneAPI `conda_channel`. |
| 86 | +Please refer our [getting started user |
| 87 | +guide](https://intelpython.github.io/dpctl) for more information on |
| 88 | +setting up a development environment and building `dpctl` from source. |
136 | 89 |
|
137 |
| -Examples |
138 |
| -======== |
| 90 | +Running Examples |
| 91 | +================ |
139 | 92 | See examples in folder `examples`.
|
140 | 93 |
|
141 | 94 | Run python examples:
|
| 95 | + |
142 | 96 | ```bash
|
143 | 97 | for script in `ls examples/python/`; do echo "executing ${script}"; python examples/python/${script}; done
|
144 | 98 | ```
|
145 | 99 |
|
146 | 100 | Examples of building Cython extensions with DPC++ compiler, that interoperate
|
147 |
| -with dpctl can be found in folder `cython`. |
| 101 | +with `dpctl` can be found in folder `cython`. |
148 | 102 |
|
149 | 103 | Each example in `cython` folder can be built using
|
150 | 104 | `CC=clang CXX=dpcpp python setup.py build_ext --inplace`.
|
151 | 105 | Please refer to `run.py` script in respective folders to execute extensions.
|
152 | 106 |
|
153 |
| -Tests |
154 |
| -===== |
155 |
| -See tests in folder `dpctl/tests`. |
| 107 | +Running Tests |
| 108 | +============= |
| 109 | +Tests are located in folder `dpctl/tests`. |
156 | 110 |
|
157 | 111 | Run tests:
|
158 | 112 | ```bash
|
|
0 commit comments