Skip to content

Commit

Permalink
Update overview
Browse files Browse the repository at this point in the history
  • Loading branch information
Diptorup Deb committed May 30, 2023
1 parent f201f52 commit bacf326
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions docs/sources/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ A simple vector addition kernel can be expressed using the API as follows:
@dpex.kernel
def sum(a, b, c):
def vecadd_kernel(a, b, c):
i = dpex.get_global_id(0)
c[i] = a[i] + b[i]
Expand All @@ -44,7 +44,7 @@ A simple vector addition kernel can be expressed using the API as follows:
b = dpnp.ones(1024, device="gpu")
c = dpnp.empty_like(a)
sum[dpex.Range(1024)](a, b, c)
vecadd_kernel[dpex.Range(1024)](a, b, c)
print(c)
In the above example, as the programmer allocated arrays on a ``gpu`` device
Expand All @@ -58,7 +58,7 @@ select a default device based on environment flag settings.

`Dpnp`_ is a NumPy-replacement library being developed using SYCL and oneAPI.
The library has an API similar to NumPy, but using SYCL and oneAPI is able to
execute in parallel on different types of hardware.
execute its functions in parallel on different types of hardware.

Numba-dpex extends Numba's type system and compilation pipeline to compile dpnp
functions and expressions in the same manner as Numba compiles NumPy. Unlike
Expand All @@ -69,6 +69,39 @@ option in ``numba.jit``. However, offloading by numba-dpex is not just
restricted to CPUs and supports all devices that are presently supported by the
kernel API.

Numba-dpex provides a decorator ``dpjit`` that behaves identically to
``numba.njit(parallel=True)`` and additionally supports dpnp compilation and
offload. Note that ``dpjit`` is able to handle NumPy and dpnp expressions in the
same function. All NumPy compilation and parallelization is done via the default
Numba code-generation pipeline, whereas dpnp expressions are compiled using the
numba-dpex pipeline.

The vector addition example depicted using the kernel API can be easily
expressed in several different ways using ``dpjit``.

.. code-block:: python
import dpnp
import numba_dpex as dpex
@dpex.dpjit
def vecadd_v1(a, b):
return a + b
@dpex.dpjit
def vecadd_v2(a, b):
return dpnp.add(a, b)
@dpex.dpjit
def vecadd_v3(a, b):
c = dpnp.empty_like(a)
for i in prange(a.shape[0]):
c[i] = a[i] + b[i]
return c
Contributing
------------
Expand Down

0 comments on commit bacf326

Please sign in to comment.