Skip to content

Commit

Permalink
Merge pull request #979 from IntelPython/dpcpp_llvm_spirv_clean
Browse files Browse the repository at this point in the history
Replaced llvm_spirv from oneAPI path by dpcpp-llvm-spirv package.
  • Loading branch information
Diptorup Deb authored Mar 28, 2023
2 parents 9d3d507 + 98f0546 commit de2a895
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 51 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
run: |
CHANNELS="-c $GITHUB_WORKSPACE/channel $CHANNELS"
conda list
conda create -n numba_dpex_env $PACKAGE_NAME pytest dpcpp_linux-64 python=${{ matrix.python }} numba=${{ matrix.numba }} dpctl dpnp=${{ matrix.dpnp }} $CHANNELS
conda create -n numba_dpex_env $PACKAGE_NAME pytest dpcpp_linux-64 python=${{ matrix.python }} numba=${{ matrix.numba }} dpctl dpnp=${{ matrix.dpnp }} dpcpp-llvm-spirv $CHANNELS
# Test installed packages
conda list
- name: Check DPNP
Expand All @@ -130,6 +130,12 @@ jobs:
conda activate numba_dpex_env
export OCL_ICD_FILENAMES=libintelocl.so
python -c "import dpnp"
- name: Check dpcpp-llvm-spirv
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate numba_dpex_env
export OCL_ICD_FILENAMES=libintelocl.so
python -c "import dpcpp_llvm_spirv as p; print(p.get_llvm_spirv_path())"
- name: Run tests
run: |
source $CONDA/etc/profile.d/conda.sh
Expand Down Expand Up @@ -207,7 +213,7 @@ jobs:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
- name: Install numba-dpex
run: |
conda install ${{ env.PACKAGE_NAME }} pytest dpcpp_win-64 python=${{ matrix.python }} dpctl ${{ matrix.dependencies }} -c $env:GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}
conda install ${{ env.PACKAGE_NAME }} pytest dpcpp_win-64 dpcpp-llvm-spirv python=${{ matrix.python }} dpctl ${{ matrix.dependencies }} -c $env:GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}
# Test installed packages
conda list
- name: Install opencl_rt
Expand Down Expand Up @@ -252,6 +258,8 @@ jobs:
run: echo "NUMBA_DPEX_TESTING_SKIP_NO_DPNP=1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Smoke test
run: python -c "import numba_dpex.core.runtime._dpexrt_python"
- name: Smoke test for dpcpp-llvm-spirv
run: python -c "import dpcpp_llvm_spirv as p; print(p.get_llvm_spirv_path())"
- name: Run tests
run: |
python -m pytest -q -ra --disable-warnings --pyargs ${{ env.MODULE_NAME }} -vv
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased] - 2023-03-28

### Added
* Replaced llvm_spirv from oneAPI path by dpcpp-llvm-spirv package.

## [0.20.0] - 2023-03-06

### Added
Expand Down
5 changes: 3 additions & 2 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ requirements:
- {{ compiler('dpcpp') }} # [not osx]
host:
- python
- setuptools
- setuptools >=63.*
- cython
- numba 0.56*
- dpctl >=0.14*
- dpnp >=0.11*
- dpcpp-llvm-spirv
- wheel
run:
- python
- numba >=0.56*
- dpctl >=0.14*
- spirv-tools
- llvm-spirv 11.*
- dpcpp-llvm-spirv
- dpnp >=0.11*
- packaging

Expand Down
12 changes: 0 additions & 12 deletions conda-recipe/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ set -euxo pipefail

pytest -q -ra --disable-warnings --pyargs numba_dpex -vv

if [[ -v ONEAPI_ROOT ]]; then
set +u
# shellcheck disable=SC1091
source "${ONEAPI_ROOT}/compiler/latest/env/vars.sh"
set -u

export NUMBA_DPEX_LLVM_SPIRV_ROOT="${ONEAPI_ROOT}/compiler/latest/linux/bin"
echo "Using llvm-spirv from oneAPI"
else
echo "Using llvm-spirv from dpcpp package in conda testing environment"
fi

export NUMBA_DPEX_ACTIVATE_ATOMICS_FP_NATIVE=1

pytest -q -ra --disable-warnings -vv \
Expand Down
6 changes: 3 additions & 3 deletions docs/user_guides/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Numba-dpex depends on following components:
* numba 0.54.* or 0.55.* (`Numba`_)
* dpctl 0.13.* (`Intel Python dpctl`_)
* dpnp 0.10.1 (`Intel Python DPNP`_)
* `llvm-spirv`_ (SPIRV generation from LLVM IR)
* `dpcpp-llvm-spirv`_ (SPIRV generation from LLVM IR)
* `llvmdev`_ (LLVM IR generation)
* `spirv-tools`_
* `packaging`_
Expand Down Expand Up @@ -60,7 +60,7 @@ installed in conda environment:
.. code-block:: bash
export ONEAPI_ROOT=/opt/intel/oneapi
conda create -n numba-dpex-env -c ${ONEAPI_ROOT}/conda_channel python=3.7 dpctl dpnp numba spirv-tools llvm-spirv llvmdev cython pytest
conda create -n numba-dpex-env -c ${ONEAPI_ROOT}/conda_channel python=3.7 dpctl dpnp numba spirv-tools dpcpp-llvm-spirv llvmdev cython pytest
conda activate numba-dpex-env
Activate DPC++ compiler:
Expand Down Expand Up @@ -149,7 +149,7 @@ Refer to :ref:`Docker <docker>` section for more options.
.. _`Intel Python Numba`: https://github.com/IntelPython/numba
.. _`Intel Python dpctl`: https://github.com/IntelPython/dpctl
.. _`Intel Python dpnp`: https://github.com/IntelPython/dpnp
.. _`llvm-spirv`: https://anaconda.org/intel/llvm-spirv
.. _`dpcpp-llvm-spirv`: https://github.com/IntelPython/dpcpp-llvm-spirv
.. _`llvmdev`: https://anaconda.org/intel/llvmdev
.. _`spirv-tools`: https://anaconda.org/intel/spirv-tools
.. _`packaging`: https://packaging.pypa.io/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ This feature is experimental. Users will need to provide
the following environment variables to activate it.

NUMBA_DPEX_ACTIVATE_ATOMICS_FP_NATIVE=1
NUMBA_DPEX_LLVM_SPIRV_ROOT=/path/to/dpcpp/provided/llvm_spirv

Example command:

.. code-block:: bash
NUMBA_DPEX_ACTIVATE_ATOMICS_FP_NATIVE=1 \
NUMBA_DPEX_LLVM_SPIRV_ROOT=/path/to/dpcpp/provided/llvm_spirv \
python program.py
Full examples
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies:
- dpnp >=0.11*
- mkl >=2021.3.0 # for dpnp
- spirv-tools
- dpcpp-llvm-spirv
- packaging
- pytest
- pip
Expand Down
1 change: 1 addition & 0 deletions environment/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies:
- dpctl >=0.14*
- dpnp >=0.10.2
- spirv-tools
- dpcpp-llvm-spirv
- packaging
- pytest
- pip
Expand Down
1 change: 1 addition & 0 deletions environment/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies:
- dpctl 0.14*
- dpnp >=0.10.2
- spirv-tools
- dpcpp-llvm-spirv
- packaging
- pytest
- pip
Expand Down
1 change: 0 additions & 1 deletion numba_dpex/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def __getattr__(name):
# Activate Native floating point atomcis support for supported devices.
# Requires llvm-spirv supporting the FP atomics extension
NATIVE_FP_ATOMICS = _readenv("NUMBA_DPEX_ACTIVATE_ATOMICS_FP_NATIVE", int, 0)
LLVM_SPIRV_ROOT = _readenv("NUMBA_DPEX_LLVM_SPIRV_ROOT", str, "")
# Emit debug info
DEBUG = _readenv("NUMBA_DPEX_DEBUG", int, config.DEBUG)
DEBUGINFO_DEFAULT = _readenv(
Expand Down
21 changes: 5 additions & 16 deletions numba_dpex/spirv_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,13 @@ def generate(self, llvm_spirv_args, ipath, opath):
@staticmethod
def _llvm_spirv():
"""Return path to llvm-spirv executable."""
result = None

if config.LLVM_SPIRV_ROOT:
result = shutil.which("llvm-spirv", path=config.LLVM_SPIRV_ROOT)

if result is None:
# use llvm-spirv from dpcpp package.
# assume dpcpp from .../bin folder.
# assume llvm-spirv from .../bin-llvm folder.
dpcpp_path = shutil.which("icx")
if dpcpp_path is not None:
bin_llvm = os.path.dirname(dpcpp_path) + "/../bin-llvm/"
bin_llvm = os.path.normpath(bin_llvm)
result = shutil.which("llvm-spirv", path=bin_llvm)

if result is None:
result = "llvm-spirv"
try:
import dpcpp_llvm_spirv as dls
except ImportError:
raise ImportError("Cannot import dpcpp-llvm-spirv package")

result = dls.get_llvm_spirv_path()
return result

def link(self, opath, binaries):
Expand Down
20 changes: 7 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,13 @@ def spirv_compile():

def _llvm_spirv():
"""Return path to llvm-spirv executable."""
result = None

# use llvm-spirv from dpcpp package.
# assume dpcpp from .../bin folder.
# assume llvm-spirv from .../bin-llvm folder.
dpcpp_path = shutil.which("icx")
if dpcpp_path is not None:
bin_llvm = os.path.dirname(dpcpp_path) + "/../bin-llvm/"
bin_llvm = os.path.normpath(bin_llvm)
result = shutil.which("llvm-spirv", path=bin_llvm)

if result is None:
result = "llvm-spirv"

try:
import dpcpp_llvm_spirv as dls
except ImportError:
raise ImportError("Cannot import dpcpp-llvm-spirv package")

result = dls.get_llvm_spirv_path()

return result

Expand Down

0 comments on commit de2a895

Please sign in to comment.