Skip to content

Commit cc382d4

Browse files
author
Diptorup Deb
committed
Polis up overview and getting started docs.
1 parent c4b017c commit cc382d4

File tree

2 files changed

+213
-71
lines changed

2 files changed

+213
-71
lines changed

docs/source/getting_started.rst

Lines changed: 171 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,73 +9,213 @@ Getting Started
99
===============
1010

1111

12-
Installation
13-
------------
12+
Installing pre-built packages
13+
-----------------------------
1414

15-
Numba-dpex depends on following components:
15+
``numba-dpex`` along with its dependencies can be installed using ``conda``.
16+
It is recommended to use conda packages from the ``anaconda.org/intel`` channel
17+
to get the latest production releases. Nighly builds of ``numba-dpex`` are
18+
available on the ``dppy/label/dev`` conda channel.
1619

17-
* numba 0.57.*
18-
* dpctl 0.14.*
19-
* dpnp 0.11.*
20-
* dpcpp-cpp-rt
21-
* dpcpp-llvm-spirv
22-
* spirv-tools
23-
24-
It is recommended to use conda packages from the ``anaconda.org/intel`` channel.
20+
.. code-block:: bash
2521
26-
Create conda environment:
22+
conda create -n numba-dpex-env numba-dpex dpnp dpctl dpcpp-llvm-spirv spirv-tools -c intel -c conda-forge
2723
28-
.. code-block:: bash
24+
Building from source
25+
--------------------
2926

30-
conda create -n numba-dpex-env numba-dpex dpnp -c ${ONEAPI_ROOT}/conda_channel
27+
``numba-dpex`` can be built from source using either ``conda-build`` or ``setuptools``.
3128

32-
Build and Install Conda Package
33-
-------------------------------
29+
Steps to build using ``conda-build``:
3430

35-
Create and activate conda build environment:
31+
1. Create a conda environment
3632

3733
.. code-block:: bash
3834
3935
conda create -n build-env conda-build
4036
conda activate build-env
4137
38+
2. Build using the vendored conda recipe
39+
4240
.. code-block:: bash
4341
4442
conda build conda-recipe -c intel -c conda-forge
4543
46-
Install conda package:
44+
3. Install the conda package
4745

4846
.. code-block:: bash
4947
5048
conda install numba-dpex
5149
52-
Build and Install with setuptools
53-
---------------------------------
50+
Steps to build using ``setup.py``:
5451

5552
.. code-block:: bash
5653
57-
conda create -n numba-dpex-env dpctl dpnp numba spirv-tools dpcpp-llvm-spirv llvmdev cython pytest -c intel -c conda-forge
54+
conda create -n numba-dpex-env dpctl dpnp numba spirv-tools dpcpp-llvm-spirv llvmdev pytest -c intel -c conda-forge
5855
conda activate numba-dpex-env
5956
57+
Building inside Docker
58+
----------------------
6059

61-
Testing
62-
-------
60+
A Dockerfile is provided on the GitHub repository to easily build ``numba-dpex``
61+
as well as its direct dependencies: ``dpctl`` and ``dpnp``. Users can either use
62+
one of the pre-built images on the ``numba-dpex`` GitHub page or use the
63+
bundled Dockerfile to build ``numba-dpex`` from source.
64+
65+
Building
66+
~~~~~~~~
67+
68+
Numba dpex ships with multistage Dockerfile, which means there are
69+
different `targets <https://docs.docker.com/build/building/multi-stage/#stop-at-a-specific-build-stage>`_
70+
available for build. The most useful ones:
6371

64-
See folder ``numba_dpex/tests``.
72+
- runtime
73+
- runtime-gpu
74+
- numba-dpex-builder-runtime
75+
- numba-dpex-builder-runtime-gpu
6576

66-
To run the tests:
77+
To build docker image
6778

6879
.. code-block:: bash
6980
70-
python -m pytest --pyargs numba_dpex.tests
81+
docker build --target runtime -t numba-dpex:runtime ./
7182
72-
Examples
73-
--------
7483
75-
See folder ``numba_dpex/examples``.
84+
To run docker image
85+
86+
.. code-block:: bash
87+
88+
docker run -it --rm numba-dpex:runtime
89+
90+
.. note::
91+
92+
When trying to build a docker image with Intel GPU support, the Dockerfile
93+
will attempt to use the GitHub API to get the latest Intel GPU drivers.
94+
Users may run into an issue related to Github API call limits. The issue
95+
can be bypassed by providing valid GitHub credentials using the
96+
``GITHUB_USER`` and ``GITHUB_PASSWORD``
97+
`build args <https://docs.docker.com/engine/reference/commandline/build/#build-arg>`_
98+
to increase the call limit. A GitHub
99+
`access token <https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token>`
100+
can also be used instead of the password.
101+
102+
.. note::
103+
104+
When building the docker image behind a firewall the proxy server settings
105+
should be provided using the ``http_proxy`` and ``https_proxy`` build args.
106+
These build args must be specified in lowercase.
107+
108+
The bundled Dockerfile supports different python versions that can be specified
109+
via the ``PYTHON_VERSION`` build arg. By default, the docker image is based on
110+
the official python image based on slim debian. The requested python version
111+
must be from the available python docker images.
112+
113+
The ``BASE_IMAGE`` build arg can be used to build the docker image from a
114+
custom image. Note that as the Dockerfile is based on debian any custom base
115+
image should be debian-based, like debian or ubuntu.
116+
117+
The list of other build args are as follows. Please refer the Dockerfile to
118+
see currently all available build args.
119+
120+
- ``PYTHON_VERSION``
121+
- ``CR_TAG``
122+
- ``IGC_TAG``
123+
- ``CM_TAG``
124+
- ``L0_TAG``
125+
- ``ONEAPI_VERSION``
126+
- ``DPCTL_GIT_BRANCH``
127+
- ``DPCTL_GIT_URL``
128+
- ``DPNP_GIT_BRANCH``
129+
- ``DPNP_GIT_URL``
130+
- ``NUMBA_DPEX_GIT_BRANCH``
131+
- ``NUMBA_DPEX_GIT_URL``
132+
- ``CMAKE_VERSION``
133+
- ``CMAKE_VERSION_BUILD``
134+
- ``INTEL_NUMPY_VERSION``
135+
- ``INTEL_NUMBA_VERSION``
136+
- ``CYTHON_VERSION``
137+
- ``SCIKIT_BUILD_VERSION``
138+
- ``http_proxy``
139+
- ``https_proxy``
140+
- ``GITHUB_USER``
141+
- ``GITHUB_PASSWORD``
142+
- ``BASE_IMAGE``
143+
144+
145+
Using the pre-built images
146+
~~~~~~~~~~~~~~~~~~~~~~~~~~
147+
148+
There are several pre-built docker images available:
149+
150+
- ``runtime`` package that provides a pre-built environment with ``numba-dpex``
151+
already installed. It is ideal to quickly setup and try
152+
``numba-dpex``.
153+
154+
.. code-block:: text
155+
156+
ghcr.io/intelpython/numba-dpex/runtime:<numba_dpex_version>-py<python_version>[-gpu]
157+
158+
- ``builder`` package that has all required dependencies pre-installed and is
159+
ideal for building ``numba-dpex`` from source.
160+
161+
.. code-block:: text
162+
163+
ghcr.io/intelpython/numba-dpex/builder:<numba_dpex_version>-py<python_version>[-gpu]
76164
77-
To run the examples:
165+
- ``stages`` package primarily meant for creating a new docker image that is
166+
built on top of one of the pre-built images.
167+
168+
After setting up the docker image, to run ``numba-dpex`` the following snippet
169+
can be used.
170+
171+
.. code-block:: bash
172+
173+
docker run --rm -it ghcr.io/intelpython/numba-dpex/runtime:0.20.0-py3.10 bash
174+
175+
It is advisable to verify the SYCL runtime and driver installation within the
176+
container by either running,
177+
178+
.. code-block:: bash
179+
180+
sycl-ls
181+
182+
or,
183+
184+
.. code-block:: bash
185+
186+
python -m dpctl -f
187+
188+
.. note::
189+
190+
To enable GPU device, the ``device`` argument should be used and one of the
191+
``*-gpu`` images should be used.
192+
193+
For passing GPU into container on linux use arguments ``--device=/dev/dri``.
194+
However if you are using WSL you need to pass
195+
``--device=/dev/dxg -v /usr/lib/wsl:/usr/lib/wsl`` instead.
196+
197+
For example, to run ``numba-dpex`` with GPU support on WSL:
78198

79199
.. code-block:: bash
80200
81-
python numba_dpex/examples/sum.py
201+
docker run --rm -it \
202+
--device=/dev/dxg -v /usr/lib/wsl:/usr/lib/wsl \
203+
ghcr.io/intelpython/numba-dpex/runtime:0.20.0-py3.10-gpu
204+
205+
206+
207+
Testing
208+
-------
209+
210+
``numba-dpex`` uses pytest for unit testing and the following example
211+
shows a way to run the unit tests.
212+
213+
.. code-block:: bash
214+
215+
python -m pytest --pyargs numba_dpex.tests
216+
217+
Examples
218+
--------
219+
220+
A set of examples on how to use ``numba-dpex`` can be found in
221+
``numba_dpex/examples``.

docs/source/overview.rst

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
Overview
55
========
66

7-
Data Parallel Extension for Numba* (`numba-dpex`_) is a standalone extension for
8-
the `Numba*`_ Python JIT compiler. ``numba-dpex`` adds two new features to
9-
Numba*: an architecture-agnostic kernel programming API, and a new compilation
10-
target that adds typing and compilation support for the Data Parallel Extension
11-
for Numpy* (`dpnp`_) library. ``dpnp`` is a Python package for numerical
12-
computing that provides a data-parallel reimplementation of `NumPy*`_'s API.
13-
``numba-dpex``'s support for ``dpnp`` compilation is a new way for Numba* users to write
14-
code in a NumPy-like API that is already supported by Numba*, while at the same
15-
time automatically running such code parallelly on various types of
16-
architecture.
17-
18-
``numba-dpex`` is being developed as part of `Intel AI Analytics Toolkit`_ and is
19-
distributed with the `Intel Distribution for Python*`_. The extension is also
7+
Data Parallel Extension for Numba* (`numba-dpex`_) is an extension to
8+
the `Numba*`_ Python JIT compiler adding an architecture-agnostic kernel
9+
programming API, and a new front-end to compile the Data Parallel Extension
10+
for Numpy* (`dpnp`_) library. The ``dpnp`` Python library is a data-parallel
11+
implementation of `NumPy*`_'s API using the `SYCL*`_ language.
12+
13+
.. ``numba-dpex``'s support for ``dpnp`` compilation is a new way for Numba* users
14+
.. to write code in a NumPy-like API that is already supported by Numba*, while at
15+
.. the same time automatically running such code parallelly on various types of
16+
.. architecture.
17+
18+
``numba-dpex`` is developed as part of `Intel AI Analytics Toolkit`_ and
19+
is distributed with the `Intel Distribution for Python*`_. The extension is
2020
available on Anaconda cloud and as a Docker image on GitHub. Please refer the
2121
:doc:`getting_started` page to learn more.
2222

@@ -26,14 +26,15 @@ Main Features
2626
Portable Kernel Programming
2727
~~~~~~~~~~~~~~~~~~~~~~~~~~~
2828

29-
The kernel API has a design and API similar to Numba's ``cuda.jit`` module.
30-
However, the API uses the `SYCL*`_ language runtime and as such is extensible to
31-
various hardware types supported by a SYCL runtime. Presently, ``numba-dpex`` uses
32-
the `DPC++`_ SYCL runtime and only supports SPIR-V-based OpenCL and `oneAPI
33-
Level Zero`_ devices CPU and GPU devices.
29+
The ``numba-dpex`` kernel API has a design and API similar to Numba's
30+
``cuda.jit`` sub-module. The API is modeled after the `SYCL*`_ language and uses
31+
the `DPC++`_ SYCL runtime. Currently, compilation of kernels is supported for
32+
SPIR-V-based OpenCL and `oneAPI Level Zero`_ devices CPU and GPU devices. In the
33+
future, the API can be extended to other architectures that are supported by
34+
DPC++.
3435

35-
The following vector addition example illustrates the basic features of the
36-
interface.
36+
The following example illustrates a vector addition kernel written with
37+
``numba-dpex`` kernel API.
3738

3839
.. code-block:: python
3940
@@ -54,33 +55,34 @@ interface.
5455
vecadd_kernel[dpex.Range(1024)](a, b, c)
5556
print(c)
5657
57-
In the above example, we allocated three arrays on a default ``gpu`` device
58-
using the ``dpnp`` library. These arrays are then passed as input arguments to the
59-
kernel function. The compilation target and the subsequent execution of the
58+
In the above example, three arrays are allocated on a default ``gpu`` device
59+
using the ``dpnp`` library. These arrays are then passed as input arguments to
60+
the kernel function. The compilation target and the subsequent execution of the
6061
kernel is determined completely by the input arguments and follow the
6162
"compute-follows-data" programming model as specified in the `Python* Array API
6263
Standard`_. To change the execution target to a CPU, the device keyword needs to
63-
be changed to ``cpu`` when allocating the ``dpnp`` arrays. It is also possible to
64-
leave the ``device`` keyword undefined and let the ``dpnp`` library select a default
65-
device based on environment flag settings. Refer the
64+
be changed to ``cpu`` when allocating the ``dpnp`` arrays. It is also possible
65+
to leave the ``device`` keyword undefined and let the ``dpnp`` library select a
66+
default device based on environment flag settings. Refer the
6667
:doc:`user_manual/kernel_programming/index` for further details.
6768

68-
``dpnp`` compilation and offload
69+
``dpnp`` compilation support
6970
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7071

71-
``numba-dpex`` extends Numba's type system and compilation pipeline to compile ``dpnp``
72-
functions and expressions in the same way as NumPy. Unlike Numba's NumPy
73-
compilation that is serial by default, ``numba-dpex`` always compiles ``dpnp``
74-
expressions into offloadable kernels and executes them in parallel. The feature
75-
is provided using a decorator ``dpjit`` that behaves identically to
76-
``numba.njit(parallel=True)`` with the addition of ``dpnp`` compilation and offload.
77-
Offloading by ``numba-dpex`` is not just restricted to CPUs and supports all devices
78-
that are presently supported by the kernel API. ``dpjit`` allows using NumPy and
79-
``dpnp`` expressions in the same function. All NumPy compilation and parallelization
80-
is done via the default Numba code-generation pipeline, whereas ``dpnp`` expressions
81-
are compiled using the ``numba-dpex`` pipeline.
82-
83-
The vector addition example depicted using the kernel API can be easily
72+
``numba-dpex`` extends Numba's type system and compilation pipeline to compile
73+
``dpnp`` functions and expressions in the same way as NumPy. Unlike Numba's
74+
NumPy compilation that is serial by default, ``numba-dpex`` always compiles
75+
``dpnp`` expressions into data-parallel kernels and executes them in parallel.
76+
The ``dpnp`` compilation feature is provided using a decorator ``dpjit`` that
77+
behaves identically to ``numba.njit(parallel=True)`` with the addition of
78+
``dpnp`` compilation and kernel offloading. Offloading by ``numba-dpex`` is not
79+
just restricted to CPUs and supports all devices that are presently supported by
80+
the kernel API. ``dpjit`` allows using NumPy and ``dpnp`` expressions in the
81+
same function. All NumPy compilation and parallelization is done via the default
82+
Numba code-generation pipeline, whereas ``dpnp`` expressions are compiled using
83+
the ``numba-dpex`` pipeline.
84+
85+
The vector addition example depicted using the kernel API can also be
8486
expressed in several different ways using ``dpjit``.
8587

8688
.. code-block:: python

0 commit comments

Comments
 (0)