Skip to content

fcharras/numba-dpex

 
 

Repository files navigation

Code style: black Coverage Status pre-commit

oneAPI logo





What?

The data-parallel extension to Numba (Numba-dpex) adds data-parallel kernel programming and auto-offload capabilities to Numba. The extension uses the Intel® DPC++ runtime and supports various OpenCL and Level Zero devices. Refer the user guide for more details.

Installing

Numba-dpex is part of the Intel® Distribution of Python (IDP) and Intel® oneAPI BaseKit, and can be installed along with oneAPI. Additionally, we support installing it from Anaconda cloud and PyPi. Please refer the instructions on our documentation page for more details.

Getting started

A good starting point is to run the test suite that includes the unit tests inside the numba_dpex/tests module. To run the tests, invoke:

python -m pytest --pyargs numba_dpex.tests

or

pytest

Once you run the tests and make sure your numba-dpex installation is up and running, try out the examples inside the numba_dpex/examples folder. For example, you can try the vector addition example as follows:

python numba_dpex/examples/sum.py

Known Issue

Floor division operator // is not supported inside the numba_dpex.kernel kernel programming API. The below code snippet will result in error reported in this Issue.

import numpy as np, numba_dpex
@numba_dpex.kernel
def div_kernel(dst, src, m):
    i = numba_dpex.get_global_id(0)
    dst[i] = src[i] // m

import dpctl
with dpctl.device_context(dpctl.SyclQueue()):
    X = np.arange(10)
    Y = np.arange(10)
    div_kernel[10, numba_dpex.DEFAULT_LOCAL_SIZE](Y, X, 5)
    D = X//5
    print(Y, D)

To bypass this issue, the llvm-spirv tool from the dpcpp conda package needs to be used.

For linux: conda install dpcpp_linux-64 For Windows: conda install dpcpp_win-64

Learn more?

Detailed documentation including user guides are hosted on our documentation site.

Found a bug?

Please report issues and bugs directly on github.

Test Matrix:

# OS Distribution Python Architecture Test type IntelOneAPI Build Commands Dependencies Backend
1 Linux Ubuntu 20.04 3.7, 3.8 Gen9 Integrated CI 2021.3, 2021.4 (1) Numba, NumPy, dpnp OCL, L0-1.1
2 Linux Ubuntu 20.04 3.7, 3.8 Gen12 Discrete Manual 2021.3, 2021.4 (1) Numba, NumPy, dpnp OCL, L0-1.1
3 Linux Ubuntu 20.04 3.7, 3.8 i7-10710U CI 2021.3, 2021.4 (1) Numba, NumPy, dpnp OCL, L0-1.1
4 Windows 10 3.7, 3.8 Gen9 Integrated CI 2021.3, 2021.4 (1) Numba, NumPy OCL
5 Windows 10 3.7, 3.8 i7-10710 CI 2021.3, 2021.4 (1) Numba, NumPy OCL

(1): python setup.py install; pytest -q -ra --disable-warnings --pyargs numba_dpex -vv

Packages

No packages published

Languages

  • Python 96.5%
  • C 1.7%
  • Other 1.8%