Skip to content

Add CI workflow to build and test dpnp with the open source LLVM SYCL compiler #2522

Add CI workflow to build and test dpnp with the open source LLVM SYCL compiler

Add CI workflow to build and test dpnp with the open source LLVM SYCL compiler #2522

Workflow file for this run

name: Test oneAPI Math Library (oneMath)
on:
push:
branches:
- master
pull_request:
permissions: read-all
env:
environment-file: 'environments/environment.yml'
environment-file-name: 'environment.yml'
environment-file-loc: '${{ github.workspace }}/environments'
build-with-oneapi-env: 'environments/build_with_oneapi.yml'
dpctl-pkg-env: 'environments/dpctl_pkg.yml'
oneapi-pkgs-env: 'environments/oneapi_pkgs.yml'
python-pkg-env: 'environments/python.yml'
test-pkg-env: 'environments/test.yml'
test-env-name: 'test_onemath'
rerun-tests-on-failure: 'true'
rerun-tests-max-attempts: 2
rerun-tests-timeout: 20
jobs:
build_env_file:
name: Build conda env file
permissions:
# Needed to cancel any previous runs that are not completed for a given workflow
actions: write
strategy:
fail-fast: false
matrix:
python: ['3.14']
python_spec: ['3.14.* *_cp314', '3.14.* *_cp314t']
runs-on: 'ubuntu-latest'
timeout-minutes: 5
env:
python-label: ${{ endsWith(matrix.python_spec, 't') && format('{0}t', matrix.python) || matrix.python }}
python-install-spec: "python ${{ matrix.python_spec || format('{0}.*', matrix.python) }}"
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@d07a454dad7609a92316b57b23c9ccfd4f59af66 # 0.13.1
with:
access_token: ${{ github.token }}
- name: Checkout DPNP repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Install conda-merge tool
uses: BSFishy/pip-action@8f2d471d809dc20b6ada98c91910b6ae6243f318 # v1
with:
packages: conda-merge
- name: Build Python env file
run: |
cat > ${{ env.python-pkg-env }} <<EOF
name: Python interpreter to test with
channels:
- conda-forge
dependencies:
- ${{ env.python-install-spec }}
EOF
- name: Merge conda env files
run: |
conda-merge ${{ env.dpctl-pkg-env }} \
${{ env.oneapi-pkgs-env }} \
${{ env.build-with-oneapi-env }} \
${{ env.test-pkg-env }} \
${{ env.python-pkg-env }} > ${{ env.environment-file }}
cat ${{ env.environment-file }}
- name: Upload artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ env.environment-file-name }}-${{ env.python-label }}
path: ${{ env.environment-file }}
test_by_tag:
name: Run tests with OneMath tag
needs: build_env_file
strategy:
fail-fast: false
matrix:
python: ['3.14']
python_spec: ['3.14.* *_cp314', '3.14.* *_cp314t']
os: [ubuntu-latest] # windows-2022 - no DFT support for Windows in oneMKL
runs-on: ${{ matrix.os }}
timeout-minutes: 120
defaults:
run:
shell: ${{ matrix.os == 'windows-2022' && 'cmd /C CALL {0}' || 'bash -el {0}' }}
env:
python-label: ${{ endsWith(matrix.python_spec, 't') && format('{0}t', matrix.python) || matrix.python }}
steps:
- name: Checkout DPNP repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Download artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ env.environment-file-name }}-${{ env.python-label }}
path: ${{ env.environment-file-loc }}
- name: Setup miniconda
id: setup_miniconda
continue-on-error: true
uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
with:
miniforge-version: latest
use-mamba: 'true'
conda-remove-defaults: 'true'
environment-file: ${{ env.environment-file }}
activate-environment: ${{ env.test-env-name }}
- name: ReSetup miniconda
if: steps.setup_miniconda.outcome == 'failure'
uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
with:
miniforge-version: latest
use-mamba: 'true'
conda-remove-defaults: 'true'
environment-file: ${{ env.environment-file }}
activate-environment: ${{ env.test-env-name }}
- name: Conda info
run: |
mamba info
mamba list
- name: Build and install DPNP package
run: |
python scripts/build_locally.py --onemath --verbose
- name: Smoke test
run: |
python -m dpctl -f
python -c "import dpnp; print(dpnp.__version__)"
- name: Run tests
if: env.rerun-tests-on-failure != 'true'
run: |
python -m pytest -ra --pyargs dpnp.tests
env:
SKIP_TENSOR_TESTS: 1
SYCL_CACHE_PERSISTENT: 1
- name: Run tensor tests
if: env.rerun-tests-on-failure != 'true'
run: |
python -m pytest -ra --pyargs dpnp.tests.tensor
env:
SYCL_CACHE_PERSISTENT: 1
- name: ReRun tests on Linux
if: env.rerun-tests-on-failure == 'true'
id: run_tests
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
with:
timeout_minutes: ${{ env.rerun-tests-timeout }}
max_attempts: ${{ env.rerun-tests-max-attempts }}
retry_on: any
command: |
. $CONDA/etc/profile.d/conda.sh
. $CONDA/etc/profile.d/mamba.sh
mamba activate ${{ env.test-env-name }}
python -m pytest -ra --pyargs dpnp.tests
env:
SKIP_TENSOR_TESTS: 1
SYCL_CACHE_PERSISTENT: 1
- name: ReRun tensor tests on Linux
if: env.rerun-tests-on-failure == 'true'
id: run_tensor_tests
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
with:
timeout_minutes: ${{ env.rerun-tests-timeout }}
max_attempts: ${{ env.rerun-tests-max-attempts }}
retry_on: any
command: |
. $CONDA/etc/profile.d/conda.sh
. $CONDA/etc/profile.d/mamba.sh
mamba activate ${{ env.test-env-name }}
python -m pytest -ra --pyargs dpnp.tests.tensor
env:
SYCL_CACHE_PERSISTENT: 1
test_by_branch:
name: Run tests with oneMath develop branch
needs: build_env_file
strategy:
fail-fast: false
matrix:
python: ['3.14']
python_spec: ['3.14.* *_cp314', '3.14.* *_cp314t']
os: [ubuntu-latest] # windows-2022 - no DFT support for Windows in oneMKL
runs-on: ${{ matrix.os }}
timeout-minutes: 60
defaults:
run:
shell: ${{ matrix.os == 'windows-2022' && 'cmd /C CALL {0}' || 'bash -el {0}' }}
env:
onemkl-source-dir: '${{ github.workspace }}/onemkl/'
python-label: ${{ endsWith(matrix.python_spec, 't') && format('{0}t', matrix.python) || matrix.python }}
steps:
- name: Checkout DPNP repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Download artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ env.environment-file-name }}-${{ env.python-label }}
path: ${{ env.environment-file-loc }}
- name: Checkout oneMKL repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: 'oneapi-src/oneMKL'
ref: 'develop'
path: ${{ env.onemkl-source-dir }}
fetch-depth: 0
- name: oneMKL ls info
run: |
ls -la ${{ env.onemkl-source-dir }}
- name: Setup miniconda
id: setup_miniconda
continue-on-error: true
uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
with:
miniforge-version: latest
use-mamba: 'true'
conda-remove-defaults: 'true'
environment-file: ${{ env.environment-file }}
activate-environment: ${{ env.test-env-name }}
- name: ReSetup miniconda
if: steps.setup_miniconda.outcome == 'failure'
uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
with:
miniforge-version: latest
use-mamba: 'true'
conda-remove-defaults: 'true'
environment-file: ${{ env.environment-file }}
activate-environment: ${{ env.test-env-name }}
- name: Conda info
run: |
mamba info
mamba list
- name: Build and install DPNP package
run: |
python scripts/build_locally.py --onemath --onemath-dir=${{ env.onemkl-source-dir }} --verbose
- name: Smoke test
run: |
python -m dpctl -f
python -c "import dpnp; print(dpnp.__version__)"
- name: Run tests
if: env.rerun-tests-on-failure != 'true'
run: |
python -m pytest -ra --pyargs dpnp.tests
env:
SKIP_TENSOR_TESTS: 1
SYCL_CACHE_PERSISTENT: 1
- name: Run tensor tests
if: env.rerun-tests-on-failure != 'true'
run: |
python -m pytest -ra --pyargs dpnp.tests.tensor
env:
SYCL_CACHE_PERSISTENT: 1
- name: ReRun tests on Linux
if: env.rerun-tests-on-failure == 'true'
id: run_tests
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
with:
timeout_minutes: ${{ env.rerun-tests-timeout }}
max_attempts: ${{ env.rerun-tests-max-attempts }}
retry_on: any
command: |
. $CONDA/etc/profile.d/conda.sh
. $CONDA/etc/profile.d/mamba.sh
mamba activate ${{ env.test-env-name }}
python -m pytest -ra --pyargs dpnp.tests
env:
SKIP_TENSOR_TESTS: 1
SYCL_CACHE_PERSISTENT: 1
- name: ReRun tensor tests on Linux
if: env.rerun-tests-on-failure == 'true'
id: run_tensor_tests_branch
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
with:
timeout_minutes: ${{ env.rerun-tests-timeout }}
max_attempts: ${{ env.rerun-tests-max-attempts }}
retry_on: any
command: |
. $CONDA/etc/profile.d/conda.sh
. $CONDA/etc/profile.d/mamba.sh
mamba activate ${{ env.test-env-name }}
python -m pytest -ra --pyargs dpnp.tests.tensor
env:
SYCL_CACHE_PERSISTENT: 1