A lightweight Python wrapper for a subset of SYCL.
Project description
About dpctl
dpctl
(data parallel control) is a lightweight Python package exposing a
subset of the Intel(R) oneAPI DPC++ runtime classes
that is distributed as part of Intel(R) Distribution for Python* and
is included in Intel(R) oneAPI Base ToolKit.
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 from Python.
dpctl
features classes representing SYCL unified shared memory
allocations as well as higher-level objects such as dpctl.tensor.usm_ndarray
on top of USM allocations.
dpctl
assists authors of Python native extensions written in C,
Cython, or pybind11 to use its dpctl.SyclQueue
object to indicate the offload
target as well as objects in dpctl.memory
and dpctl.tensor
submodules to
represent USM allocations that are accessible from within data-parallel code executed
on the target queue.
dpctl.tensor
submodule provides an array container representing an array in a
strided layout on top of a USM allocation. The submodule provides an array-API
conforming oneAPI DPC++ powered library to manipulate the array container.
Requirements
- Install Conda
- Install Intel oneAPI
- Set environment variable
ONEAPI_ROOT
- Windows:
C:\Program Files (x86)\Intel\oneAPI\
- Linux:
/opt/intel/oneapi
- Windows:
- Set environment variable
- Install OpenCL HD graphics drivers
Build and Install Conda Package
- Create and activate conda build environment
conda create -n build-env conda-build
conda activate build-env
- Set environment variable
ONEAPI_ROOT
and build conda package
export ONEAPI_ROOT=/opt/intel/oneapi
conda build conda-recipe -c ${ONEAPI_ROOT}/conda_channel
On Windows to cope with long file names
use croot
with short folder path:
set "ONEAPI_ROOT=C:\Program Files (x86)\Intel\oneAPI\"
conda build --croot=C:/tmp conda-recipe -c "%ONEAPI_ROOT%\conda_channel"
:warning: You could face issues with conda-build=3.20: Use conda-build=3.18!
- Install conda package
conda install dpctl
Build and Install with setuptools
dpctl relies on DPC++ runtime. With Intel oneAPI installed you should activate it.
setup.py
requires environment variable ONEAPI_ROOT
and following packages
installed:
cython
numpy
cmake
- for building C APIninja
- only on Windows
You need DPC++ to build dpctl. If you want to build using the DPC++ in a oneAPI distribution, activate DPC++ compiler as follows:
export ONEAPI_ROOT=/opt/intel/oneapi
source ${ONEAPI_ROOT}/compiler/latest/env/vars.sh
For install:
python setup.py install
For development:
python setup.py develop
It is also possible to build dpctl using DPC++ toolchain instead of oneAPI DPC++. Instead of activating the oneAPI environment, indicate the toolchain installation prefix with --sycl-compiler-prefix
option, e.g.
python setup.py develop --sycl-compiler-prefix=${DPCPP_ROOT}/llvm/build
Please use python setup.py develop --help
for more details.
Install Wheel Package from Pypi
- Install dpctl
python -m pip install --index-url https://pypi.anaconda.org/intel/simple --extra-index-url https://pypi.org/simple dpctl
Note: dpctl wheel package is placed on Pypi, but some of its dependencies (like Intel numpy) are in Anaconda Cloud. That is why install command requires additional intel Pypi channel from Anaconda Cloud.
- Set path to Performance Libraries in case of using venv or system Python: On Linux:
export LD_LIBRARY_PATH=<path_to_your_env>/lib
On Windows:
set PATH=<path_to_your_env>\bin;<path_to_your_env>\Library\bin;%PATH%
Using dpctl
dpctl relies on DPC++ runtime. With Intel oneAPI installed you could activate it.
On Windows:
call "%ONEAPI_ROOT%\compiler\latest\env\vars.bat"
On Linux:
source ${ONEAPI_ROOT}/compiler/latest/env/vars.sh
When dpctl is installed via conda package
then it uses DPC++ runtime from dpcpp_cpp_rt
package
and it is not necessary to activate oneAPI DPC++ compiler environment.
dpcpp_cpp_rt
package is provided by oneAPI conda_channel
.
Examples
See examples in folder examples
.
Run python examples:
for script in `ls examples/python/`; do echo "executing ${script}"; python examples/python/${script}; done
Examples of building Cython extensions with DPC++ compiler, that interoperate
with dpctl can be found in folder cython
.
Each example in cython
folder can be built using
CC=icx CXX=dpcpp python setup.py build_ext --inplace
.
Please refer to run.py
script in respective folders to execute extensions.
Tests
See tests in folder dpctl/tests
.
Run tests:
pytest --pyargs dpctl
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for dpctl-0.11.1-0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d17a021d6f3cf04d312a6ad8db373b1bf9d1d7e9b35ec8111b17fe39f9775e0 |
|
MD5 | 98e63b678e20b85144e8c5f2dd10d7f8 |
|
BLAKE2b-256 | ee15300aee9e870bf5f1acef6ba50a248cc4c6f040f1efca91a45dd2c93e902f |
Hashes for dpctl-0.11.1-0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4407f13b32204ed416801eb38bf702f4713c7be9974344b89781fd953f459d3 |
|
MD5 | 8d4b43d8b17ef539138717ec8f12ef52 |
|
BLAKE2b-256 | edb0873758b7906d29d2eea42f34c99b8637c9d6a14a7ad4a2b66c37b800f110 |
Hashes for dpctl-0.11.1-0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41235770d4b9ab4001f6269b28f20e347bd91f84ffaea9dd8341b080df5ab0a6 |
|
MD5 | 7522b8e21ac4885b30348f7bf99612ce |
|
BLAKE2b-256 | 027eebc50f8e1ec2b4f3eaf23250d0344c8410891e44763ce043bc961ec0a147 |
Hashes for dpctl-0.11.1-0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 209b5e4ee5936a9465616a7289b45b557d65337bde28064d6a55a6236a80ce7a |
|
MD5 | 2c5362ddb033fa5e2f701d1b3055d22b |
|
BLAKE2b-256 | f38816269a939707e8822901be5a9a32e9f7083ab3644793c31187f2e19fd5e4 |
Hashes for dpctl-0.11.1-0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0ed7572ddcec64a58eaa83013a69d4070c49fd139c0d76511c36870792a5453 |
|
MD5 | 9c73e832fe3a96e16379266b99e31e1d |
|
BLAKE2b-256 | 357767d66ed08616eddf0f012fbbec2242be1319a608b8a440892cccb4408e85 |
Hashes for dpctl-0.11.1-0-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f9d090989da7b6d218678384425a4c47380d7bb9b2d8b011f51d8db3897e551 |
|
MD5 | 57c0dd2446f1020ab97af904bb9b4bcf |
|
BLAKE2b-256 | ecdd412a49f47fa1b8bb830483827c8ed24327e15a7cb985348384db7c62bd57 |