From e0cbe0e052383d5db750c414647159cc71bba4db Mon Sep 17 00:00:00 2001 From: mloubout Date: Tue, 23 Jul 2024 11:21:20 -0400 Subject: [PATCH 1/2] CI: switch M1 runner to openmp --- .github/workflows/pytest-core-nompi.yml | 23 ++++++++++++++++------- tests/test_buffering.py | 4 +++- tests/test_gradient.py | 4 ++-- tests/test_roundoff.py | 3 +++ 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pytest-core-nompi.yml b/.github/workflows/pytest-core-nompi.yml index c9967fa351..bb701c3f69 100644 --- a/.github/workflows/pytest-core-nompi.yml +++ b/.github/workflows/pytest-core-nompi.yml @@ -22,6 +22,7 @@ jobs: env: DEVITO_ARCH: "${{ matrix.arch }}" DEVITO_LANGUAGE: ${{ matrix.language }} + DEVITO_PLATFORM: ${{ matrix.platform }} OMP_NUM_THREADS: 2 strategy: @@ -48,6 +49,7 @@ jobs: arch: "gcc-11" language: "C" sympy: "1.11" + platform: "cpu64" - name: pytest-ubuntu-py38-gcc12-omp python-version: '3.8' @@ -55,6 +57,7 @@ jobs: arch: "gcc-12" language: "openmp" sympy: "1.10" + platform: "cpu64" - name: pytest-ubuntu-py38-gcc7-omp python-version: '3.8' @@ -62,6 +65,7 @@ jobs: arch: "gcc-7" language: "openmp" sympy: "1.9" + platform: "cpu64" - name: pytest-ubuntu-py310-gcc10-noomp python-version: '3.10' @@ -69,6 +73,7 @@ jobs: arch: "gcc-10" language: "C" sympy: "1.11" + platform: "cpu64" - name: pytest-ubuntu-py312-gcc13-omp python-version: '3.12' @@ -76,6 +81,7 @@ jobs: arch: "gcc-13" language: "openmp" sympy: "1.13" + platform: "cpu64" - name: pytest-ubuntu-py39-gcc9-omp python-version: '3.9' @@ -83,13 +89,15 @@ jobs: arch: "custom" language: "openmp" sympy: "1.9" + platform: "cpu64" - name: pytest-osx-py312-clang-omp python-version: '3.12' os: macos-latest arch: "clang" - language: "C" + language: "openmp" sympy: "1.9" + platform: "m1" - name: pytest-docker-py39-gcc-omp python-version: '3.9' @@ -97,6 +105,7 @@ jobs: arch: "gcc" language: "openmp" sympy: "1.12" + platform: "cpu64" - name: pytest-docker-py39-icx-omp python-version: '3.9' @@ -104,6 +113,7 @@ jobs: arch: "icx" language: "openmp" sympy: "1.12" + platform: "intel64" - set: base test-set: 'not adjoint' @@ -147,9 +157,8 @@ jobs: - name: Set tests (reduced number for OSX) run : | if [ "${{ runner.os }}" == 'macOS' ]; then - echo "TESTS=tests/test_operator.py" >> $GITHUB_ENV - else - echo "TESTS=tests/" >> $GITHUB_ENV + brew install llvm libomp + echo "/opt/homebrew/bin:/opt/homebrew/opt/llvm/bin" >> $GITHUB_PATH fi id: set-tests @@ -162,9 +171,9 @@ jobs: - name: Install dependencies if: "!contains(matrix.name, 'docker')" run: | - pip install ${{ env.PIPFLAGS }} --upgrade pip - pip install ${{ env.PIPFLAGS }} sympy==${{matrix.sympy}} - pip install ${{ env.PIPFLAGS }} -e .[tests] + python3 -m pip install ${{ env.PIPFLAGS }} --upgrade pip + python3 -m pip install ${{ env.PIPFLAGS }} sympy==${{matrix.sympy}} + python3 -m pip install ${{ env.PIPFLAGS }} -e .[tests,extras] - name: Check configuration run: | diff --git a/tests/test_buffering.py b/tests/test_buffering.py index d4c6b54949..a7472ae22c 100644 --- a/tests/test_buffering.py +++ b/tests/test_buffering.py @@ -3,7 +3,8 @@ from conftest import skipif from devito import (Constant, Grid, TimeFunction, Operator, Eq, SubDimension, - SubDomain, ConditionalDimension) + SubDomain, ConditionalDimension, configuration, switchconfig) +from devito.arch.archinfo import AppleArm from devito.ir import FindSymbols, retrieve_iteration_tree from devito.exceptions import InvalidOperator @@ -672,6 +673,7 @@ def test_everything(): @pytest.mark.parametrize('subdomain', ['domain', 'interior']) +@switchconfig(safe_math=True, condition=isinstance(configuration['platform'], AppleArm)) def test_stencil_issue_1915(subdomain): nt = 5 grid = Grid(shape=(6, 6)) diff --git a/tests/test_gradient.py b/tests/test_gradient.py index 8e82aef2c3..67a691ab1d 100644 --- a/tests/test_gradient.py +++ b/tests/test_gradient.py @@ -14,7 +14,7 @@ class TestGradient: - @skipif(['chkpnt', 'cpu64-icc']) + @skipif(['chkpnt', 'cpu64-icc', 'cpu64-arm']) @switchconfig(safe_math=True) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) @pytest.mark.parametrize('opt', [('advanced', {'openmp': True}), @@ -59,7 +59,7 @@ def test_gradient_checkpointing(self, dtype, opt, space_order, kernel, shape, sp assert np.allclose(gradient.data, gradient2.data, atol=0, rtol=0) - @skipif('cpu64-icc') + @skipif(['cpu64-icc', 'cpu64-arm']) @pytest.mark.parametrize('tn', [750.]) @pytest.mark.parametrize('spacing', [(10, 10)]) @pytest.mark.parametrize("dtype, tolerance", [(np.float32, 1e-4), diff --git a/tests/test_roundoff.py b/tests/test_roundoff.py index 8b90f871a0..e853019deb 100644 --- a/tests/test_roundoff.py +++ b/tests/test_roundoff.py @@ -1,6 +1,7 @@ import pytest import numpy as np +from conftest import skipif from devito import Grid, Constant, TimeFunction, Eq, Operator, switchconfig @@ -84,6 +85,7 @@ def test_lm_backward(self, dat, dtype): @pytest.mark.parametrize('dat', [0.5, 0.624, 1.0, 1.5, 2.0, 3.0, 3.6767, 4.0]) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) @switchconfig(log_level='DEBUG', safe_math=True) + @skipif('cpu64-arm') def test_lm_fb(self, dat, dtype): """ Test logistic map with forward and backward terms that should cancel. @@ -123,6 +125,7 @@ def test_lm_fb(self, dat, dtype): @pytest.mark.parametrize('dat', [0.5, 0.624, 1.0, 1.5, 2.0, 3.0, 3.6767, 4.0]) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) @switchconfig(log_level='DEBUG', safe_math=True) + @skipif('cpu64-arm') def test_lm_ds(self, dat, dtype): """ Test logistic map with 2nd derivative term that should cancel. From 9ca3bacd2b7239ccf10c00a950251aa8ce958fab Mon Sep 17 00:00:00 2001 From: mloubout Date: Wed, 24 Jul 2024 11:35:04 -0400 Subject: [PATCH 2/2] deps: bump minimal python version to 3.9 --- .github/workflows/examples.yml | 3 +-- .github/workflows/pytest-core-mpi.yml | 2 +- .github/workflows/pytest-core-nompi.yml | 31 +++++++++---------------- requirements-optional.txt | 1 - setup.py | 8 +------ 5 files changed, 14 insertions(+), 31 deletions(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 00a33c8b03..f9a86a5232 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -37,9 +37,8 @@ jobs: uses: actions/checkout@v4 - name: Setup conda - uses: conda-incubator/setup-miniconda@v2 + uses: conda-incubator/setup-miniconda@v3 with: - python-version: 3.8 activate-environment: devito environment-file: environment-dev.yml auto-activate-base: false diff --git a/.github/workflows/pytest-core-mpi.yml b/.github/workflows/pytest-core-mpi.yml index 1df105361c..a5d2354e33 100644 --- a/.github/workflows/pytest-core-mpi.yml +++ b/.github/workflows/pytest-core-mpi.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python-version: ['3.8','3.9'] + python-version: ['3.9', '3.11'] env: DEVITO_LANGUAGE: "openmp" diff --git a/.github/workflows/pytest-core-nompi.yml b/.github/workflows/pytest-core-nompi.yml index bb701c3f69..d30f1752e1 100644 --- a/.github/workflows/pytest-core-nompi.yml +++ b/.github/workflows/pytest-core-nompi.yml @@ -22,7 +22,6 @@ jobs: env: DEVITO_ARCH: "${{ matrix.arch }}" DEVITO_LANGUAGE: ${{ matrix.language }} - DEVITO_PLATFORM: ${{ matrix.platform }} OMP_NUM_THREADS: 2 strategy: @@ -32,8 +31,8 @@ jobs: matrix: name: [ pytest-ubuntu-py311-gcc11-noomp, - pytest-ubuntu-py38-gcc12-omp, - pytest-ubuntu-py38-gcc7-omp, + pytest-ubuntu-py312-gcc12-omp, + pytest-ubuntu-py39-gcc7-omp, pytest-ubuntu-py310-gcc10-noomp, pytest-ubuntu-py312-gcc13-omp, pytest-ubuntu-py39-gcc9-omp, @@ -49,23 +48,20 @@ jobs: arch: "gcc-11" language: "C" sympy: "1.11" - platform: "cpu64" - - name: pytest-ubuntu-py38-gcc12-omp - python-version: '3.8' - os: ubuntu-22.04 + - name: pytest-ubuntu-py312-gcc12-omp + python-version: '3.12' + os: ubuntu-24.04 arch: "gcc-12" language: "openmp" - sympy: "1.10" - platform: "cpu64" + sympy: "1.13" - - name: pytest-ubuntu-py38-gcc7-omp - python-version: '3.8' + - name: pytest-ubuntu-py39-gcc7-omp + python-version: '3.9' os: ubuntu-20.04 arch: "gcc-7" language: "openmp" sympy: "1.9" - platform: "cpu64" - name: pytest-ubuntu-py310-gcc10-noomp python-version: '3.10' @@ -73,7 +69,6 @@ jobs: arch: "gcc-10" language: "C" sympy: "1.11" - platform: "cpu64" - name: pytest-ubuntu-py312-gcc13-omp python-version: '3.12' @@ -81,23 +76,20 @@ jobs: arch: "gcc-13" language: "openmp" sympy: "1.13" - platform: "cpu64" - name: pytest-ubuntu-py39-gcc9-omp python-version: '3.9' os: ubuntu-20.04 arch: "custom" language: "openmp" - sympy: "1.9" - platform: "cpu64" + sympy: "1.10" - name: pytest-osx-py312-clang-omp python-version: '3.12' os: macos-latest arch: "clang" language: "openmp" - sympy: "1.9" - platform: "m1" + sympy: "1.13" - name: pytest-docker-py39-gcc-omp python-version: '3.9' @@ -105,7 +97,6 @@ jobs: arch: "gcc" language: "openmp" sympy: "1.12" - platform: "cpu64" - name: pytest-docker-py39-icx-omp python-version: '3.9' @@ -113,7 +104,6 @@ jobs: arch: "icx" language: "openmp" sympy: "1.12" - platform: "intel64" - set: base test-set: 'not adjoint' @@ -134,6 +124,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + allow-prereleases: true - name: Build docker image if: contains(matrix.name, 'docker') diff --git a/requirements-optional.txt b/requirements-optional.txt index c681b7bdc7..d9ca13e636 100644 --- a/requirements-optional.txt +++ b/requirements-optional.txt @@ -1,5 +1,4 @@ matplotlib -pandas pyrevolve==2.2.4 scipy distributed \ No newline at end of file diff --git a/setup.py b/setup.py index 852c2ee2a3..a9a33d98e4 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,6 @@ import versioneer import os -import sys import pkg_resources from setuptools import setup, find_packages @@ -19,10 +18,6 @@ def numpy_compat(required): new_reqs = [r for r in required if "numpy" not in r and "sympy" not in r] sympy_lb, sympy_ub = min_max(required, "sympy") numpy_lb, numpy_ub = min_max(required, "numpy") - if sys.version_info < (3, 9): - # Numpy 2.0 requires python > 3.8 - new_reqs.extend([f"sympy>={sympy_lb},<1.12.1", f"numpy>{numpy_lb},<2.0"]) - return new_reqs # Due to api changes in numpy 2.0, it requires sympy 1.12.1 at the minimum # Check if sympy is installed and enforce numpy version accordingly. @@ -108,7 +103,7 @@ def numpy_compat(required): }, url='http://www.devitoproject.org', platforms=["Linux", "Mac OS-X", "Unix"], - python_requires=">=3.8", + python_requires=">=3.9", classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', @@ -120,7 +115,6 @@ def numpy_compat(required): 'Operating System :: Unix', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11',