@@ -371,3 +371,344 @@ jobs:
371371 working-directory : ${{ env.workdir }}\test_tmp
372372 run : >-
373373 conda activate ${{ env.TEST_ENV_NAME }} && python -m pytest -v -s --pyargs ${{ env.MODULE_NAME }}
374+
375+ test_examples_linux :
376+ needs : build_linux
377+ runs-on : ${{ matrix.runner }}
378+ strategy :
379+ matrix :
380+ python : ['3.14']
381+ python_spec : ['3.14.* *_cp314']
382+ runner : [ubuntu-latest]
383+ include :
384+ - python : ' 3.14'
385+ python_spec : ' 3.14.* *_cp314t'
386+ runner : ubuntu-latest
387+ timeout-minutes : 60
388+ env :
389+ EXAMPLES_ENV_NAME : examples
390+ BUILD_ENV_NAME : build_env
391+ DPCPP_CMPLR : " dpcpp_linux-64>=2026.0"
392+ # keep in sync with conda-recipe-cf/conda_build_config.yaml
393+ GCC_CMPLR_VERSION : ' 15'
394+
395+ steps :
396+ - name : Install conda-index
397+ # Needed to be able to run conda index
398+ run : |
399+ conda update -n base --all
400+ conda install conda-index=${{ env.CONDA_INDEX_VERSION }} ${{ env.CHANNELS }}
401+ - name : Checkout dpctl repo
402+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
403+ with :
404+ persist-credentials : false
405+ fetch-depth : 0
406+ - name : Download artifact
407+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
408+ with :
409+ name : ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python == '3.14' && (contains(matrix.python_spec, 'cp314t') && '3.14t' || '3.14') || matrix.python }}
410+ - name : Add conda to system path
411+ run : echo "$CONDA/bin" >> "$GITHUB_PATH"
412+ - name : Create conda channel
413+ run : |
414+ mkdir -p "$GITHUB_WORKSPACE/channel/linux-64"
415+ conda index "$GITHUB_WORKSPACE/channel" || exit 1
416+ mv "${{ env.PACKAGE_NAME }}"-*.conda "$GITHUB_WORKSPACE/channel/linux-64" || exit 1
417+ conda index "$GITHUB_WORKSPACE/channel" || exit 1
418+ # Test channel
419+ conda search "$PACKAGE_NAME" -c "$GITHUB_WORKSPACE/channel" --override-channels --info --json > "$GITHUB_WORKSPACE/ver.json"
420+ cat ver.json
421+ - name : Collect dependencies
422+ run : |
423+ CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
424+ export CHANNELS
425+ PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
426+ export PACKAGE_VERSION
427+ PYTHON_VER="${{ matrix.python_spec }}"
428+ if [ -z "${PYTHON_VER}" ]; then
429+ PYTHON_VER="${{ matrix.python }}"
430+ fi
431+ export PYTHON_VER
432+ # shellcheck disable=SC2086
433+ conda create -n ${{ env.EXAMPLES_ENV_NAME }} ${{ env.PACKAGE_NAME }}=${PACKAGE_VERSION} python="${PYTHON_VER}" $CHANNELS --only-deps --dry-run > lockfile
434+ cat lockfile
435+ - name : Set pkgs_dirs
436+ run : |
437+ echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
438+ - name : Cache conda packages
439+ uses : actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
440+ env :
441+ CACHE_NUMBER : 3 # Increase to reset cache
442+ with :
443+ path : ~/.conda/pkgs
444+ key :
445+ ${{ runner.os }}-conda-cf-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-spec-${{ matrix.python == '3.14' && contains(matrix.python_spec, 'cp314t') && 't' || '' }}-${{hashFiles('lockfile') }}
446+ restore-keys : |
447+ ${{ runner.os }}-conda-cf-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-spec-${{ matrix.python == '3.14' && contains(matrix.python_spec, 'cp314t') && 't' || '' }}-
448+ ${{ runner.os }}-conda-cf-${{ env.CACHE_NUMBER }}-
449+ - name : Install example requirements
450+ shell : bash -ex -l {0}
451+ run : |
452+ CHANNELS="${{ env.CHANNELS }}"
453+ export CHANNELS
454+ . "$CONDA/etc/profile.d/conda.sh"
455+ PYTHON_VER="${{ matrix.python_spec }}"
456+ if [ -z "${PYTHON_VER}" ]; then
457+ PYTHON_VER="${{ matrix.python }}"
458+ fi
459+ # shellcheck disable=SC2086
460+ conda create -n ${{ env.EXAMPLES_ENV_NAME }} -y pytest python="${PYTHON_VER}" "setuptools<72.2.0" $CHANNELS
461+ echo "Environment created"
462+ # shellcheck disable=SC2086
463+ conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y cmake ninja $CHANNELS || exit 1
464+ echo "Cmake and Ninja installed"
465+ # shellcheck disable=SC2086
466+ conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y pybind11 cython scikit-build $CHANNELS || exit 1
467+ echo "scikit-build installed"
468+ # tbb-devel carries TBBConfig.cmake, which the oneMKL example looks for,
469+ # and intel-opencl-rt provides the OpenCL CPU device to run examples on
470+ # shellcheck disable=SC2086
471+ conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y mkl-dpcpp mkl-devel-dpcpp \
472+ tbb-devel intel-opencl-rt $CHANNELS || exit 1
473+ echo "IPL installed"
474+ # shellcheck disable=SC2086
475+ conda create -y -n ${{ env.BUILD_ENV_NAME }} $CHANNELS \
476+ "gcc_linux-64=${{ env.GCC_CMPLR_VERSION }}" "gxx_linux-64=${{ env.GCC_CMPLR_VERSION }}" \
477+ "${{ env.DPCPP_CMPLR }}" "sysroot_linux-64>=2.28"
478+ echo "Compiler installed"
479+ conda list -n "${{ env.BUILD_ENV_NAME }}"
480+ - name : Install dpctl
481+ shell : bash -l {0}
482+ run : |
483+ source "$CONDA/etc/profile.d/conda.sh"
484+ CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
485+ export CHANNELS
486+ PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
487+ export PACKAGE_VERSION
488+ # shellcheck disable=SC2086
489+ conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y $CHANNELS ${{ env.PACKAGE_NAME }}=${PACKAGE_VERSION} || exit 1
490+ conda list -n ${{ env.EXAMPLES_ENV_NAME }}
491+ - name : Build and run examples of pybind11 extensions
492+ shell : bash -l {0}
493+ run : |
494+ source "$CONDA/etc/profile.d/conda.sh"
495+ conda activate "${{ env.EXAMPLES_ENV_NAME }}"
496+ cd examples/pybind11
497+ while IFS= read -r d; do
498+ pushd "$d" > /dev/null
499+ conda activate --stack "${{ env.BUILD_ENV_NAME }}"
500+ CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja || exit 1
501+ conda deactivate
502+ if [ -e tests ]; then
503+ LD_LIBRARY_PATH="${CONDA_PREFIX}/lib" python -m pytest tests || exit 1
504+ else
505+ LD_LIBRARY_PATH="${CONDA_PREFIX}/lib" python example.py || exit 1
506+ fi
507+ popd > /dev/null
508+ done < <(find . -maxdepth 1 -type d -not -path ".")
509+ - name : Build and run examples of Cython extensions
510+ shell : bash -l {0}
511+ run : |
512+ source "$CONDA/etc/profile.d/conda.sh"
513+ conda activate "${{ env.EXAMPLES_ENV_NAME }}"
514+ cd examples/cython
515+ while IFS= read -r d; do
516+ pushd "$d" > /dev/null
517+ conda activate --stack "${{ env.BUILD_ENV_NAME }}"
518+ CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja || exit 1
519+ conda deactivate
520+ python -m pytest tests || exit 1
521+ popd > /dev/null
522+ done < <(find . -maxdepth 1 -type d -not -path ".")
523+ - name : Build and run examples of C-extensions
524+ shell : bash -l {0}
525+ run : |
526+ source "$CONDA/etc/profile.d/conda.sh"
527+ conda activate "${{ env.EXAMPLES_ENV_NAME }}"
528+ cd examples/c
529+ while IFS= read -r d; do
530+ pushd "$d" > /dev/null
531+ conda activate --stack "${{ env.BUILD_ENV_NAME }}"
532+ python setup.py build_ext --inplace || exit 1
533+ conda deactivate
534+ python -m pytest tests || exit 1
535+ popd > /dev/null
536+ done < <(find . -maxdepth 1 -type d -not -path ".")
537+ - name : Run Python examples
538+ shell : bash -l {0}
539+ run : |
540+ cd examples/python
541+ source "$CONDA/etc/profile.d/conda.sh"
542+ conda activate "${{ env.EXAMPLES_ENV_NAME }}"
543+ while IFS= read -r script; do
544+ echo "Executing ${script}"
545+ python "${script}" --run all || exit 1
546+ done < <(find . \( -not -name "_*" -and -name "*.py" \))
547+
548+ test_examples_windows :
549+ needs : build_windows
550+ runs-on : ${{ matrix.runner }}
551+ defaults :
552+ run :
553+ shell : cmd /C CALL {0}
554+ strategy :
555+ matrix :
556+ python : ['3.14']
557+ python_spec : ['3.14.* *_cp314']
558+ runner : [windows-latest]
559+ include :
560+ - python : ' 3.14'
561+ python_spec : ' 3.14.* *_cp314t'
562+ runner : windows-latest
563+ timeout-minutes : 120
564+ env :
565+ EXAMPLES_ENV_NAME : examples
566+ BUILD_ENV_NAME : build_env
567+ DPCPP_CMPLR : " dpcpp_win-64>=2026.0"
568+ workdir : ' ${{ github.workspace }}'
569+
570+ steps :
571+ - name : Checkout dpctl repo
572+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
573+ with :
574+ persist-credentials : false
575+ fetch-depth : 0
576+
577+ - name : Download artifact
578+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
579+ with :
580+ name : ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python == '3.14' && (contains(matrix.python_spec, 'cp314t') && '3.14t' || '3.14') || matrix.python }}
581+
582+ - uses : conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
583+ with :
584+ auto-update-conda : true
585+ miniforge-version : latest
586+ channels : conda-forge
587+ conda-remove-defaults : true
588+ activate-environment : ${{ env.EXAMPLES_ENV_NAME }}
589+ python-version : ${{ matrix.python }}
590+
591+ - name : Install conda-index
592+ run : |
593+ conda install -n base conda-index=${{ env.CONDA_INDEX_VERSION }}
594+
595+ - name : Create conda channel with the artifact bit
596+ run : |
597+ @echo on
598+ mkdir ${{ env.workdir }}\channel\win-64
599+ move ${{ env.PACKAGE_NAME }}-*.conda ${{ env.workdir }}\channel\win-64
600+ conda index ${{ env.workdir }}\channel
601+ dir ${{ env.workdir }}\channel\win-64\
602+
603+ - name : Dump dpctl version info from created channel into ver.json
604+ run : |
605+ @echo on
606+ conda search ${{ env.PACKAGE_NAME }} -c ${{ env.workdir }}/channel --override-channels --info --json > ${{ env.workdir }}\ver.json
607+
608+ - name : Output content of produced ver.json
609+ shell : pwsh
610+ run : Get-Content -Path ${{ env.workdir }}\ver.json
611+
612+ - name : Install example requirements
613+ run : |
614+ @echo on
615+ SET "PYTHON_VER=${{ matrix.python_spec }}"
616+ IF "%PYTHON_VER%"=="" SET "PYTHON_VER=${{ matrix.python }}"
617+ REM intel-opencl-rt provides the OpenCL CPU device to run the examples on
618+ conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y python="%PYTHON_VER%" pytest ^
619+ "setuptools<72.2.0" cmake ninja pybind11 cython scikit-build ^
620+ mkl-dpcpp mkl-devel-dpcpp tbb-devel intel-opencl-rt ${{ env.CHANNELS }} || exit /b 1
621+ REM the compiler lives in its own environment, stacked on top of the
622+ REM examples environment while extensions are being built
623+ conda create -n ${{ env.BUILD_ENV_NAME }} -y "${{ env.DPCPP_CMPLR }}" vs2022_win-64 ${{ env.CHANNELS }} || exit /b 1
624+ conda list -n ${{ env.BUILD_ENV_NAME }}
625+
626+ - name : Install dpctl
627+ run : |
628+ @echo on
629+ set "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
630+ FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
631+ SET PACKAGE_VERSION=%%F
632+ )
633+ conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% ^
634+ -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} || exit /b 1
635+ conda list -n ${{ env.EXAMPLES_ENV_NAME }}
636+
637+ - name : Register the OpenCL CPU driver with the ICD loader
638+ shell : pwsh
639+ run : |
640+ $vendors = "HKLM:\SOFTWARE\Khronos\OpenCL\Vendors"
641+ $drivers = @(Get-ChildItem -Recurse -ErrorAction SilentlyContinue -Filter intelocl64.dll -Path "$env:CONDA_PREFIX\Library\bin")
642+ if ($drivers.Count -eq 0) { throw "intel-opencl-rt installed no OpenCL CPU driver under $env:CONDA_PREFIX" }
643+ if (-not (Test-Path $vendors)) { New-Item -Path $vendors -Force | Out-Null }
644+ foreach ($driver in $drivers) {
645+ New-ItemProperty -Path $vendors -Name $driver.FullName -Value 0 -PropertyType DWord -Force | Out-Null
646+ }
647+ Get-ItemProperty -Path $vendors
648+
649+ - name : Smoke test
650+ run : >-
651+ conda activate ${{ env.EXAMPLES_ENV_NAME }} && python -m dpctl -f
652+
653+ - name : Build and run examples of pybind11 extensions
654+ working-directory : ${{ env.workdir }}\examples\pybind11
655+ env :
656+ CC : icx
657+ CXX : icx
658+ run : |
659+ @echo on
660+ call conda activate ${{ env.EXAMPLES_ENV_NAME }} || exit /b 1
661+ conda list
662+ for /d %%d in (*) do (
663+ pushd %%d || exit /b 1
664+ call conda activate --stack ${{ env.BUILD_ENV_NAME }} || exit /b 1
665+ python setup.py build_ext --inplace -G Ninja || exit /b 1
666+ call conda deactivate || exit /b 1
667+ if exist tests (
668+ python -m pytest -v tests || exit /b 1
669+ ) else (
670+ python example.py || exit /b 1
671+ )
672+ popd
673+ )
674+
675+ - name : Build and run examples of Cython extensions
676+ working-directory : ${{ env.workdir }}\examples\cython
677+ env :
678+ CC : icx
679+ CXX : icx
680+ run : |
681+ @echo on
682+ call conda activate ${{ env.EXAMPLES_ENV_NAME }} || exit /b 1
683+ conda list
684+ for /d %%d in (*) do (
685+ pushd %%d || exit /b 1
686+ call conda activate --stack ${{ env.BUILD_ENV_NAME }} || exit /b 1
687+ python setup.py build_ext --inplace -G Ninja || exit /b 1
688+ call conda deactivate || exit /b 1
689+ python -m pytest -v tests || exit /b 1
690+ popd
691+ )
692+
693+ - name : Build and run examples of C-extensions
694+ working-directory : ${{ env.workdir }}\examples\c
695+ run : |
696+ @echo on
697+ call conda activate ${{ env.EXAMPLES_ENV_NAME }} || exit /b 1
698+ conda list
699+ for /d %%d in (*) do (
700+ pushd %%d || exit /b 1
701+ python setup.py build_ext --inplace || exit /b 1
702+ python -m pytest -v tests || exit /b 1
703+ popd
704+ )
705+
706+ - name : Run Python examples
707+ working-directory : ${{ env.workdir }}\examples\python
708+ run : |
709+ @echo on
710+ call conda activate ${{ env.EXAMPLES_ENV_NAME }} || exit /b 1
711+ for /f "delims=" %%f in ('dir /b *.py ^| findstr /v "^_"') do (
712+ echo Executing %%f
713+ python %%f --run all || exit /b 1
714+ )
0 commit comments