From 56cb01a315faa385eb72fd9e6b95ae301f0c58cc Mon Sep 17 00:00:00 2001 From: Vahid Tavanashad Date: Wed, 16 Apr 2025 22:16:29 -0700 Subject: [PATCH 1/2] extend github workflows with build with clang --- .github/dependabot.yml | 2 + .github/workflows/build-with-clang.yml | 77 ++++++++++++++++++++++++++ .github/workflows/conda-package-cf.yml | 30 ++++++++++ .github/workflows/conda-package.yml | 30 ++++++++++ 4 files changed, 139 insertions(+) create mode 100644 .github/workflows/build-with-clang.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5ace460..7863596 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,3 +4,5 @@ updates: directory: "/" schedule: interval: "weekly" + day: "saturday" + rebase-strategy: "disabled" diff --git a/.github/workflows/build-with-clang.yml b/.github/workflows/build-with-clang.yml new file mode 100644 index 0000000..9fe3e31 --- /dev/null +++ b/.github/workflows/build-with-clang.yml @@ -0,0 +1,77 @@ +name: Build project with IntelLLVM clang compiler + +on: + pull_request: + push: + branches: [master] + +permissions: read-all + +jobs: + build-with-clang: + runs-on: ubuntu-latest + + strategy: + matrix: + python: ["3.9", "3.10", "3.11", "3.12"] + numpy_version: ["numpy'<2'", "numpy'>=2'"] + env: + ONEAPI_ROOT: /opt/intel/oneapi + + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.12.1 + with: + access_token: ${{ github.token }} + + - name: Add Intel repository + run: | + wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main" + sudo apt-get update + + - name: Install Intel OneAPI + run: | + sudo apt-get install intel-oneapi-compiler-dpcpp-cpp + sudo apt-get install intel-oneapi-tbb + sudo apt-get install intel-oneapi-mkl-devel + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + architecture: x64 + + - name: Checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install mkl_fft dependencies + shell: bash -l {0} + run: | + pip install cython setuptools">=77" + pip install ${{ matrix.numpy_version }} + + - name: List oneAPI folder content + shell: bash -l {0} + run: ls /opt/intel/oneapi/compiler + + - name: Build mkl_fft + shell: bash -l {0} + run: | + source /opt/intel/oneapi/setvars.sh + echo $CMPLR_ROOT + export CC=$CMPLR_ROOT/bin/icx + export CXX=$CMPLR_ROOT/bin/icpx + export CFLAGS="${CFLAGS} -fno-fast-math -O2" + pip install -e . --no-build-isolation --no-deps --verbose + + - name: Run mkl_fft tests + shell: bash -l {0} + run: | + source /opt/intel/oneapi/setvars.sh + pip install pytest scipy mkl-service + pytest -s -v --pyargs mkl_fft diff --git a/.github/workflows/conda-package-cf.yml b/.github/workflows/conda-package-cf.yml index f95bc95..08084e0 100644 --- a/.github/workflows/conda-package-cf.yml +++ b/.github/workflows/conda-package-cf.yml @@ -22,6 +22,11 @@ jobs: matrix: python: ['3.9', '3.10', '3.11', '3.12'] steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.12.1 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -29,6 +34,7 @@ jobs: - name: Set pkgs_dirs run: | echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc + - name: Cache conda packages uses: actions/cache@v4 env: @@ -43,8 +49,10 @@ jobs: - name: Add conda to system path run: echo $CONDA/bin >> $GITHUB_PATH + - name: Install conda-build run: conda install conda-build + - name: Build conda package with NumPy 2.0 run: | CHANNELS="-c conda-forge --override-channels" @@ -56,6 +64,7 @@ jobs: $VERSIONS \ $CHANNELS \ conda-recipe-cf + - name: Upload artifact uses: actions/upload-artifact@v4 with: @@ -81,10 +90,13 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python_ver }} + - name: Add conda to system path run: echo $CONDA/bin >> $GITHUB_PATH + - name: Install conda-build run: conda install conda-build + - name: Create conda channel run: | mkdir -p $GITHUB_WORKSPACE/channel/linux-64 @@ -97,11 +109,14 @@ jobs: run: | CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}" conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME python=${{ matrix.python_ver }} ${{ matrix.numpy }} $CHANNELS --only-deps --dry-run > lockfile + - name: Display lockfile run: cat lockfile + - name: Set pkgs_dirs run: | echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc + - name: Cache conda packages uses: actions/cache@v4 env: @@ -120,6 +135,7 @@ jobs: conda create -n ${{ env.TEST_ENV_NAME }} python=${{ matrix.python_ver }} ${{ matrix.numpy }} $PACKAGE_NAME pytest scipy $CHANNELS # Test installed packages conda list -n ${{ env.TEST_ENV_NAME }} + - name: Run tests run: | source $CONDA/etc/profile.d/conda.sh @@ -133,9 +149,15 @@ jobs: matrix: python: ['3.9', '3.10', '3.11', '3.12'] steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.12.1 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v4 with: fetch-depth: 0 + - uses: conda-incubator/setup-miniconda@v3 with: miniforge-version: latest @@ -181,6 +203,7 @@ jobs: defaults: run: shell: cmd /C CALL {0} + strategy: matrix: python_ver: ['3.9', '3.10', '3.11', '3.12'] @@ -227,9 +250,11 @@ jobs: shell: cmd /C CALL {0} run: | conda search ${{ env.PACKAGE_NAME }} -c ${{ env.workdir }}/channel --override-channels --info --json > ${{ env.workdir }}\ver.json + - name: Output content of produced ver.json shell: pwsh run: Get-Content -Path ${{ env.workdir }}\ver.json + - name: Collect dependencies shell: cmd /C CALL {0} run: | @@ -242,9 +267,11 @@ jobs: SET PACKAGE_VERSION=%%F ) conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python_ver }} ${{ matrix.numpy }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile + - name: Display lockfile content shell: pwsh run: Get-Content -Path .\lockfile + - name: Cache conda packages uses: actions/cache@v4 env: @@ -256,6 +283,7 @@ jobs: restore-keys: | ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python_ver }}- ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- + - name: Install mkl_fft shell: cmd /C CALL {0} run: | @@ -269,12 +297,14 @@ jobs: ) SET "TEST_DEPENDENCIES=pytest pytest-cov" conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %TEST_DEPENDENCIES% python=${{ matrix.python }} ${{ matrix.numpy }} scipy -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} + - name: Report content of test environment shell: cmd /C CALL {0} run: | echo "Value of CONDA enviroment variable was: " %CONDA% echo "Value of CONDA_PREFIX enviroment variable was: " %CONDA_PREFIX% conda info && conda list -n ${{ env.TEST_ENV_NAME }} + - name: Run tests shell: cmd /C CALL {0} run: >- diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index 3ddbb8c..9cbd85c 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -22,6 +22,11 @@ jobs: matrix: python: ['3.9', '3.10', '3.11', '3.12'] steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.12.1 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -29,6 +34,7 @@ jobs: - name: Set pkgs_dirs run: | echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc + - name: Cache conda packages uses: actions/cache@v4 env: @@ -43,8 +49,10 @@ jobs: - name: Add conda to system path run: echo $CONDA/bin >> $GITHUB_PATH + - name: Install conda-build run: conda install conda-build + - name: Build conda package run: | CHANNELS="-c conda-forge -c https://software.repos.intel.com/python/conda --override-channels" @@ -56,6 +64,7 @@ jobs: $VERSIONS \ $CHANNELS \ conda-recipe + - name: Upload artifact uses: actions/upload-artifact@v4 with: @@ -80,10 +89,13 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} + - name: Add conda to system path run: echo $CONDA/bin >> $GITHUB_PATH + - name: Install conda-build run: conda install conda-build + - name: Create conda channel run: | mkdir -p $GITHUB_WORKSPACE/channel/linux-64 @@ -96,11 +108,14 @@ jobs: run: | CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}" conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME python=${{ matrix.python }} $CHANNELS --only-deps --dry-run > lockfile + - name: Display lockfile run: cat lockfile + - name: Set pkgs_dirs run: | echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc + - name: Cache conda packages uses: actions/cache@v4 env: @@ -119,6 +134,7 @@ jobs: conda create -n ${{ env.TEST_ENV_NAME }} python=${{ matrix.python }} $PACKAGE_NAME pytest scipy $CHANNELS # Test installed packages conda list -n ${{ env.TEST_ENV_NAME }} + - name: Run tests run: | source $CONDA/etc/profile.d/conda.sh @@ -132,9 +148,15 @@ jobs: matrix: python: ['3.9', '3.10', '3.11', '3.12'] steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.12.1 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v4.2.0 with: fetch-depth: 0 + - uses: conda-incubator/setup-miniconda@v3 with: miniforge-version: latest @@ -182,6 +204,7 @@ jobs: defaults: run: shell: cmd /C CALL {0} + strategy: matrix: python: ['3.9', '3.10', '3.11', '3.12'] @@ -197,6 +220,7 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} + - uses: conda-incubator/setup-miniconda@v3 with: miniforge-version: latest @@ -226,9 +250,11 @@ jobs: shell: cmd /C CALL {0} run: | conda search ${{ env.PACKAGE_NAME }} -c ${{ env.workdir }}/channel --override-channels --info --json > ${{ env.workdir }}\ver.json + - name: Output content of produced ver.json shell: pwsh run: Get-Content -Path ${{ env.workdir }}\ver.json + - name: Collect dependencies shell: cmd /C CALL {0} run: | @@ -241,9 +267,11 @@ jobs: SET PACKAGE_VERSION=%%F ) conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile + - name: Display lockfile content shell: pwsh run: Get-Content -Path .\lockfile + - name: Cache conda packages uses: actions/cache@v4 env: @@ -255,6 +283,7 @@ jobs: restore-keys: | ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- + - name: Install mkl_fft shell: cmd /C CALL {0} run: | @@ -268,6 +297,7 @@ jobs: ) SET "TEST_DEPENDENCIES=pytest pytest-cov" conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %TEST_DEPENDENCIES% python=${{ matrix.python }} scipy -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} + - name: Report content of test environment shell: cmd /C CALL {0} run: | From 6eb9cc0fcc542714af8718f9ef3b078a80103a40 Mon Sep 17 00:00:00 2001 From: Vahid Tavanashad Date: Thu, 17 Apr 2025 07:09:36 -0700 Subject: [PATCH 2/2] address comments --- .github/workflows/build-with-clang.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-with-clang.yml b/.github/workflows/build-with-clang.yml index 9fe3e31..4d45550 100644 --- a/.github/workflows/build-with-clang.yml +++ b/.github/workflows/build-with-clang.yml @@ -15,9 +15,14 @@ jobs: matrix: python: ["3.9", "3.10", "3.11", "3.12"] numpy_version: ["numpy'<2'", "numpy'>=2'"] + env: ONEAPI_ROOT: /opt/intel/oneapi + defaults: + run: + shell: bash -el {0} + steps: - name: Cancel Previous Runs uses: styfle/cancel-workflow-action@0.12.1 @@ -50,28 +55,23 @@ jobs: fetch-depth: 0 - name: Install mkl_fft dependencies - shell: bash -l {0} run: | pip install cython setuptools">=77" pip install ${{ matrix.numpy_version }} - name: List oneAPI folder content - shell: bash -l {0} - run: ls /opt/intel/oneapi/compiler + run: ls ${{ env.ONEAPI_ROOT }}/compiler - name: Build mkl_fft - shell: bash -l {0} run: | - source /opt/intel/oneapi/setvars.sh + source ${{ env.ONEAPI_ROOT }}/setvars.sh echo $CMPLR_ROOT export CC=$CMPLR_ROOT/bin/icx - export CXX=$CMPLR_ROOT/bin/icpx export CFLAGS="${CFLAGS} -fno-fast-math -O2" pip install -e . --no-build-isolation --no-deps --verbose - name: Run mkl_fft tests - shell: bash -l {0} run: | - source /opt/intel/oneapi/setvars.sh - pip install pytest scipy mkl-service + source ${{ env.ONEAPI_ROOT }}/setvars.sh + pip install scipy mkl-service pytest pytest -s -v --pyargs mkl_fft