diff --git a/.github/actions/install/psydac-req/action.yml b/.github/actions/install/psydac-req/action.yml new file mode 100644 index 000000000..535556663 --- /dev/null +++ b/.github/actions/install/psydac-req/action.yml @@ -0,0 +1,138 @@ +name: Install prerequisites + +runs: + using: composite + steps: + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: | + pyproject.toml + requirements.txt + + - name: Install non-Python dependencies on Ubuntu + if: matrix.os == 'ubuntu-latest' + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: gfortran openmpi-bin libopenmpi-dev libhdf5-openmpi-dev g++ liblapack3 cmake cmake-curses-gui zlib1g-dev libnetcdf-dev libnetcdff-dev + version: 1.0 + execute_install_scripts: true + + # When loading cached apt packages, the default MPI compiler isn't set. + # Workaround is to 'reinstall' openmpi-bin, which doesn't actually perform + # installation (since openmpi-bin already exists), but instead reruns + # `update-alternatives` which fixes the symlinks to mpicc/mpif90. + - name: Reconfigure non-Python dependencies on Ubuntu + if: matrix.os == 'ubuntu-latest' + shell: bash + run: | + sudo apt-get update + sudo apt-get install --reinstall openmpi-bin libhdf5-openmpi-dev liblapack-dev libblas-dev + + - name: Install non-Python dependencies on macOS + if: matrix.os == 'macos-14' + shell: bash + run: | + brew install make + brew install open-mpi + brew install hdf5-mpi + brew install libomp + brew update + brew install python3 + brew install gcc + brew install openblas + brew install lapack + brew install git + brew install pandoc + brew install cmake + brew install netcdf-fortran + brew install pkgconf + GFORTRAN_HOME=$(which gfortran || true) + echo "GFORTRAN_HOME : $GFORTRAN_HOME" + if [[ ! -f "$GFORTRAN_HOME" ]]; then + gfort=$(find ${PATH//:/\/ } -name 'gfortran-*' -exec basename {} \; | sort | tail -n 1 || true) + echo "Found $gfort" + gfort_path=$(which ${gfort}) + folder=$(dirname ${gfort_path}) + ln -s ${gfort_path} ${folder}/gfortran + fi + echo "MPI_OPTS=--oversubscribe" >> $GITHUB_ENV + echo "/opt/homebrew/opt/make/libexec/gnubin" >> $GITHUB_PATH + + - name: Print information on MPI and HDF5 libraries + shell: bash + run: | + ompi_info + h5pcc -showconfig -echo || true + + - name: Upgrade pip + shell: bash + run: | + python -m pip install --upgrade pip + + - name: Determine directory of parallel HDF5 library + shell: bash + run: | + if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then + HDF5_DIR=$(dpkg -L libhdf5-openmpi-dev | grep libhdf5.so | xargs dirname) + elif [[ "${{ matrix.os }}" == "macos-14" ]]; then + HDF5_DIR=$(brew list hdf5-mpi | grep "libhdf5.dylib" | xargs dirname | xargs dirname) + fi + echo $HDF5_DIR + echo "HDF5_DIR=$HDF5_DIR" >> $GITHUB_ENV + + - name: Cache PETSc + uses: actions/cache@v4 + id: cache-petsc + env: + cache-name: cache-PETSc + with: + path: "./petsc" + key: petsc-${{ matrix.os }}-${{ matrix.python-version }} + + - if: steps.cache-petsc.outputs.cache-hit != 'true' + name: Download a specific release of PETSc + shell: bash + run: | + git clone --depth 1 --branch v3.23.3 https://gitlab.com/petsc/petsc.git + + - if: steps.cache-petsc.outputs.cache-hit != 'true' + name: Install PETSc with complex support + working-directory: ./petsc + shell: bash + run: | + export PETSC_DIR=$(pwd) + export PETSC_ARCH=petsc-cmplx + ./configure --with-scalar-type=complex --with-fortran-bindings=0 --have-numpy=1 --download-fblaslapack=1 + make all + echo "PETSC_DIR=$PETSC_DIR" > petsc.env + echo "PETSC_ARCH=$PETSC_ARCH" >> petsc.env + + # This step is not really necessary and could be combined with PETSc install + # step; however it's good to verify if the cached PETSc installation really works! + - name: Test PETSc installation + working-directory: ./petsc + shell: bash + run: | + source petsc.env + make check + echo "PETSC_DIR=$PETSC_DIR" >> $GITHUB_ENV + echo "PETSC_ARCH=$PETSC_ARCH" >> $GITHUB_ENV + + - name: Install petsc4py + working-directory: ./petsc + shell: bash + run: | + python -m pip install wheel Cython numpy + python -m pip install src/binding/petsc4py + + # - name: Check parallel h5py installation + # run: | + # python -c " + # from mpi4py import MPI + # import h5py + # # This particular instantiation of h5py.File will fail if parallel h5py isn't installed + # f = h5py.File('parallel_test.hdf5', 'w', driver='mpio', comm=MPI.COMM_WORLD) + # print(f)" \ No newline at end of file diff --git a/.github/workflows/compile-with-pyccel-devel.yml b/.github/workflows/compile-with-pyccel-devel.yml new file mode 100644 index 000000000..e3f0f2d6c --- /dev/null +++ b/.github/workflows/compile-with-pyccel-devel.yml @@ -0,0 +1,67 @@ +name: Compile psydac w. pyccel devel + +on: + pull_request: + branches: [devel-tiny] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + compile-with-pyccel-devel: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest ] + # TODO: Make sure that struphy works with python > 3.11, keep the lower bound to 3.10 + python-version: [ '3.10', '3.12', '3.13' ] + compile_language: ['c', 'fortran'] + isMerge: + - ${{ github.event_name == 'push' && github.ref == 'refs/heads/devel' }} + # exclude: + # - { isMerge: false, python-version: '3.10' } + # - { isMerge: false, python-version: '3.11' } + # include: + # - os: macos-14 + # python-version: '3.10' + # - os: macos-14 + # python-version: '3.13' + + name: Compile psydac w. pyccel devel on ${{ matrix.os }} / Python ${{ matrix.python-version }} / ${{ matrix.compile_language }} + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Install prerequisites + uses: ./.github/actions/install/psydac-req + + - name: Install project + run: | + python -m pip install ".[test]" --no-cache-dir + python -m pip freeze + + - name: Set up environment variables + run: | + echo "PSYDAC_DIR=$GITHUB_WORKSPACE" >> $GITHUB_ENV + echo "PYCCEL_DIR=$GITHUB_WORKSPACE/pyccel" >> $GITHUB_ENV + + - name: Clone pyccel from Github (devel branch) + run: | + git clone --recurse-submodules https://github.com/pyccel/pyccel.git $PYCCEL_DIR + + - name: Install pyccel + working-directory: ${{ env.PYCCEL_DIR }} + run: | + echo "Pyccel location for this branch" + pip show pyccel + pip uninstall pyccel -y + python -m pip install ".[test]" --no-cache-dir + echo "Pyccel location after reinstalling" + pip show pyccel + + - name: Compile psydac kernels + run: | + psydac-accelerate --language ${{ matrix.compile_language }} diff --git a/.github/workflows/documentation.yml.disabled b/.github/workflows/documentation.yml.disabled deleted file mode 100644 index 41896bbb9..000000000 --- a/.github/workflows/documentation.yml.disabled +++ /dev/null @@ -1,65 +0,0 @@ -name: Documentation - -on: - push: - branches: [ devel ] - paths: - - 'docs/**' - - 'psydac/**.py' - - pull_request: - branches: [ devel ] - paths: - - 'docs/**' - - 'psydac/**.py' - - workflow_dispatch: - -permissions: - contents: read - pages: write - id-token: write - -jobs: - build_docs: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN}} - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.9 - - name: Install non-Python dependencies on Ubuntu - run: | - sudo apt update - sudo apt install graphviz - - name: Install Python dependencies - run: | - python -m pip install -r docs/requirements.txt - - name: Make the sphinx doc - run: | - rm -rf docs/source/modules/STUBDIR - make -C docs clean - make -C docs html - python docs/update_links.py - - name: Setup Pages - uses: actions/configure-pages@v5 - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - path: 'docs/build/html' - - deploy_docs: - if: github.event_name == 'push' && github.ref == 'refs/heads/devel' - needs: build_docs - runs-on: ubuntu-latest - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 diff --git a/.github/workflows/test-psydac.yml b/.github/workflows/test-psydac.yml new file mode 100644 index 000000000..a47ef2ea6 --- /dev/null +++ b/.github/workflows/test-psydac.yml @@ -0,0 +1,99 @@ +name: Test psydac + +on: + pull_request: + branches: [devel-tiny] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test_psydac: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest ] + # TODO: Make sure that struphy works with python > 3.11, keep the lower bound to 3.10 + python-version: [ '3.10', '3.12', '3.13' ] + compile_language: ['c', 'fortran'] + isMerge: + - ${{ github.event_name == 'push' && github.ref == 'refs/heads/devel' }} + # exclude: + # - { isMerge: false, python-version: '3.10' } + # - { isMerge: false, python-version: '3.11' } + # include: + # - os: macos-14 + # python-version: '3.10' + # - os: macos-14 + # python-version: '3.13' + + name: Test Psydac on ${{ matrix.os }} / Python ${{ matrix.python-version }} / ${{ matrix.compile_language }} + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Install prerequisites + uses: ./.github/actions/install/psydac-req + + - name: Install project without mpi + run: | + python -m pip install ".[test]" --no-cache-dir + python -m pip freeze + + - name: Compile psydac kernels + run: | + psydac-accelerate --language ${{ matrix.compile_language }} + + # - name: Test Pyccel optimization flags + # run: | + # pytest --pyargs psydac -m pyccel --capture=no + + - name: Initialize test directory + run: | + mkdir pytest + cp mpi_tester.py pytest + + - name: Run coverage tests on macOS + if: matrix.os == 'macos-14' + working-directory: ./pytest + run: >- + python -m pytest -n auto + --cov psydac + --cov-config $GITHUB_WORKSPACE/pyproject.toml + --cov-report xml + --pyargs psydac -m "not parallel and not petsc" + + - name: Run single-process tests with Pytest on Ubuntu + if: matrix.os == 'ubuntu-latest' + working-directory: ./pytest + run: | + python -m pytest -n auto --pyargs psydac -m "not parallel and not petsc" + + - name: Run single-process PETSc tests with Pytest + working-directory: ./pytest + run: | + python -m pytest -n auto --pyargs psydac -m "not parallel and petsc" + + - name: Install project with mpi + run: | + python -m pip install ".[mpi]" + python -m pip freeze + + - name: Run MPI tests with Pytest + working-directory: ./pytest + run: | + python mpi_tester.py --mpirun="mpiexec -n 4 ${MPI_OPTS}" --pyargs psydac -m "parallel and not petsc" + + - name: Run MPI PETSc tests with Pytest + working-directory: ./pytest + run: | + python mpi_tester.py --mpirun="mpiexec -n 4 ${MPI_OPTS}" --pyargs psydac -m "parallel and petsc" + + - name: Remove test directory + if: always() + run: | + rm -rf pytest + diff --git a/.github/workflows/test-struphy.yml b/.github/workflows/test-struphy.yml new file mode 100644 index 000000000..807fd0220 --- /dev/null +++ b/.github/workflows/test-struphy.yml @@ -0,0 +1,105 @@ +name: Test struphy + +on: + pull_request: + branches: [devel-tiny] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test_struphy: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest ] + # TODO: Make sure that struphy works with python > 3.11, keep the lower bound to 3.10 + python-version: [ '3.10', '3.12', '3.13' ] + compile_language: ['c', 'fortran'] + isMerge: + - ${{ github.event_name == 'push' && github.ref == 'refs/heads/devel' }} + # exclude: + # - { isMerge: false, python-version: '3.10' } + # - { isMerge: false, python-version: '3.11' } + # include: + # - os: macos-14 + # python-version: '3.10' + # - os: macos-14 + # python-version: '3.13' + + name: Test Struphy on ${{ matrix.os }} / Python ${{ matrix.python-version }} / ${{ matrix.compile_language }} + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Install prerequisites + uses: ./.github/actions/install/psydac-req + + - name: Install project without mpi + run: | + python -m pip install ".[test]" --no-cache-dir + python -m pip freeze + + - name: Set up environment variables + run: | + echo "PSYDAC_DIR=$GITHUB_WORKSPACE" >> $GITHUB_ENV + echo "STRUPHY_DIR=$GITHUB_WORKSPACE/struphy" >> $GITHUB_ENV + + - name: Clone struphy from Github + run: | + git clone https://github.com/struphy-hub/struphy.git $STRUPHY_DIR + + - name: Install struphy without mpi #TODO: Set branch to devel + working-directory: ${{ env.STRUPHY_DIR }} + run: | + echo "Psydac location for this branch" + pip show psydac + pip uninstall psydac -y + python -m pip install ".[phys]" --no-cache-dir + echo "Psydac location after installing struphy" + pip show psydac + + - name: Re-install Psydac from the current branch + run: | + echo "Uninstall psydac" + psydac-accelerate --cleanup --yes + pip show psydac + pip uninstall psydac -y + python -m pip install ${{ env.PSYDAC_DIR }} --force-reinstall --no-cache-dir + echo "Psydac location after installing psydac from the current branch (should be the same as in the previous step)" + pip show psydac + + - name: Compile struphy + working-directory: ${{ env.STRUPHY_DIR }} + run: | + pip show psydac + struphy -h + struphy compile -y --language ${{ matrix.compile_language }} + + - name: Run struphy unit tests + working-directory: ${{ env.STRUPHY_DIR }} + run: | + struphy test unit + + - name: Run struphy model tests + working-directory: ${{ env.STRUPHY_DIR }} + run: | + struphy test models + + - name: Install mpi4py + working-directory: ${{ env.STRUPHY_DIR }} + run: | + pip install -U mpi4py + + - name: Run struphy unit tests with mpi + working-directory: ${{ env.STRUPHY_DIR }} + run: | + struphy test unit --mpi 2 + + - name: Remove test directory + if: always() + run: | + rm -rf pytest diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml deleted file mode 100644 index 2c425379c..000000000 --- a/.github/workflows/testing.yml +++ /dev/null @@ -1,542 +0,0 @@ -# This workflow will install Python dependencies and run tests with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -on: - push: - branches: [ devel-tiny, devel, main ] - pull_request: - branches: [ devel-tiny, devel, main ] - -jobs: - compile-with-pyccel-devel: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ ubuntu-latest ] - # TODO: Make sure that struphy works with python > 3.11, keep the lower bound to 3.10 - python-version: [ '3.10', '3.12', '3.13' ] - compile_language: ['c', 'fortran'] - isMerge: - - ${{ github.event_name == 'push' && github.ref == 'refs/heads/devel' }} - # exclude: - # - { isMerge: false, python-version: '3.10' } - # - { isMerge: false, python-version: '3.11' } - # include: - # - os: macos-14 - # python-version: '3.10' - # - os: macos-14 - # python-version: '3.13' - - name: Compile psydac w. pyccel devel on ${{ matrix.os }} / Python ${{ matrix.python-version }} / ${{ matrix.compile_language }} - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: | - pyproject.toml - requirements.txt - - - name: Install non-Python dependencies on Ubuntu - if: matrix.os == 'ubuntu-latest' - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: gfortran openmpi-bin libopenmpi-dev libhdf5-openmpi-dev - version: 1.0 - execute_install_scripts: true - - # When loading cached apt packages, the default MPI compiler isn't set. - # Workaround is to 'reinstall' openmpi-bin, which doesn't actually perform - # installation (since openmpi-bin already exists), but instead reruns - # `update-alternatives` which fixes the symlinks to mpicc/mpif90. - - name: Reconfigure non-Python dependencies on Ubuntu - if: matrix.os == 'ubuntu-latest' - run: | - sudo apt-get update - sudo apt-get install --reinstall openmpi-bin libhdf5-openmpi-dev liblapack-dev libblas-dev - - - name: Install non-Python dependencies on macOS - if: matrix.os == 'macos-14' - run: | - brew install make - brew install open-mpi - brew install hdf5-mpi - brew install libomp - brew update - brew install python3 - brew install gcc - brew install openblas - brew install lapack - brew install git - brew install pandoc - GFORTRAN_HOME=$(which gfortran || true) - echo "GFORTRAN_HOME : $GFORTRAN_HOME" - if [[ ! -f "$GFORTRAN_HOME" ]]; then - gfort=$(find ${PATH//:/\/ } -name 'gfortran-*' -exec basename {} \; | sort | tail -n 1 || true) - echo "Found $gfort" - gfort_path=$(which ${gfort}) - folder=$(dirname ${gfort_path}) - ln -s ${gfort_path} ${folder}/gfortran - fi - echo "MPI_OPTS=--oversubscribe" >> $GITHUB_ENV - echo "/opt/homebrew/opt/make/libexec/gnubin" >> $GITHUB_PATH - - - name: Print information on MPI and HDF5 libraries - run: | - ompi_info - h5pcc -showconfig -echo || true - - - name: Upgrade pip - run: | - python -m pip install --upgrade pip - - - name: Determine directory of parallel HDF5 library - run: | - if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then - HDF5_DIR=$(dpkg -L libhdf5-openmpi-dev | grep libhdf5.so | xargs dirname) - elif [[ "${{ matrix.os }}" == "macos-14" ]]; then - HDF5_DIR=$(brew list hdf5-mpi | grep "libhdf5.dylib" | xargs dirname | xargs dirname) - fi - echo $HDF5_DIR - echo "HDF5_DIR=$HDF5_DIR" >> $GITHUB_ENV - - - name: Cache PETSc - uses: actions/cache@v4 - id: cache-petsc - env: - cache-name: cache-PETSc - with: - path: "./petsc" - key: petsc-${{ matrix.os }}-${{ matrix.python-version }} - - - if: steps.cache-petsc.outputs.cache-hit != 'true' - name: Download a specific release of PETSc - run: | - git clone --depth 1 --branch v3.23.3 https://gitlab.com/petsc/petsc.git - - - if: steps.cache-petsc.outputs.cache-hit != 'true' - name: Install PETSc with complex support - working-directory: ./petsc - run: | - export PETSC_DIR=$(pwd) - export PETSC_ARCH=petsc-cmplx - ./configure --with-scalar-type=complex --with-fortran-bindings=0 --have-numpy=1 --download-fblaslapack=1 - make all - echo "PETSC_DIR=$PETSC_DIR" > petsc.env - echo "PETSC_ARCH=$PETSC_ARCH" >> petsc.env - - # This step is not really necessary and could be combined with PETSc install - # step; however it's good to verify if the cached PETSc installation really works! - - name: Test PETSc installation - working-directory: ./petsc - run: | - source petsc.env - make check - echo "PETSC_DIR=$PETSC_DIR" >> $GITHUB_ENV - echo "PETSC_ARCH=$PETSC_ARCH" >> $GITHUB_ENV - - - name: Install petsc4py - working-directory: ./petsc - run: | - python -m pip install wheel Cython numpy - python -m pip install src/binding/petsc4py - - # - name: Check parallel h5py installation - # run: | - # python -c " - # from mpi4py import MPI - # import h5py - # # This particular instantiation of h5py.File will fail if parallel h5py isn't installed - # f = h5py.File('parallel_test.hdf5', 'w', driver='mpio', comm=MPI.COMM_WORLD) - # print(f)" - - - name: Install project - run: | - python -m pip install ".[test]" --no-cache-dir - python -m pip freeze - - - name: Set up environment variables - run: | - echo "PSYDAC_DIR=$GITHUB_WORKSPACE" >> $GITHUB_ENV - echo "PYCCEL_DIR=$GITHUB_WORKSPACE/pyccel" >> $GITHUB_ENV - - - name: Clone pyccel from Github (devel branch) - run: | - git clone --recurse-submodules https://github.com/pyccel/pyccel.git $PYCCEL_DIR - - - name: Install pyccel - working-directory: ${{ env.PYCCEL_DIR }} - run: | - echo "Pyccel location for this branch" - pip show pyccel - pip uninstall pyccel -y - python -m pip install ".[test]" --no-cache-dir - echo "Pyccel location after reinstalling" - pip show pyccel - - - name: Compile psydac kernels - run: | - psydac-accelerate --language ${{ matrix.compile_language }} - - test_psydac: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ ubuntu-latest ] - # TODO: Make sure that struphy works with python > 3.11, keep the lower bound to 3.10 - python-version: [ '3.10', '3.12', '3.13' ] - compile_language: ['c', 'fortran'] - isMerge: - - ${{ github.event_name == 'push' && github.ref == 'refs/heads/devel' }} - # exclude: - # - { isMerge: false, python-version: '3.10' } - # - { isMerge: false, python-version: '3.11' } - # include: - # - os: macos-14 - # python-version: '3.10' - # - os: macos-14 - # python-version: '3.13' - - name: Test Psydac on ${{ matrix.os }} / Python ${{ matrix.python-version }} / ${{ matrix.compile_language }} - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: | - pyproject.toml - requirements.txt - - - name: Install non-Python dependencies on Ubuntu - if: matrix.os == 'ubuntu-latest' - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: gfortran openmpi-bin libopenmpi-dev libhdf5-openmpi-dev - version: 1.0 - execute_install_scripts: true - - # When loading cached apt packages, the default MPI compiler isn't set. - # Workaround is to 'reinstall' openmpi-bin, which doesn't actually perform - # installation (since openmpi-bin already exists), but instead reruns - # `update-alternatives` which fixes the symlinks to mpicc/mpif90. - - name: Reconfigure non-Python dependencies on Ubuntu - if: matrix.os == 'ubuntu-latest' - run: | - sudo apt-get update - sudo apt-get install --reinstall openmpi-bin libhdf5-openmpi-dev liblapack-dev libblas-dev - - - name: Install non-Python dependencies on macOS - if: matrix.os == 'macos-14' - run: | - brew install open-mpi - brew install hdf5-mpi - brew install libomp - brew update - brew install python3 - brew install gcc - brew install openblas - brew install lapack - brew install git - brew install pandoc - GFORTRAN_HOME=$(which gfortran || true) - echo "GFORTRAN_HOME : $GFORTRAN_HOME" - if [[ ! -f "$GFORTRAN_HOME" ]]; then - gfort=$(find ${PATH//:/\/ } -name 'gfortran-*' -exec basename {} \; | sort | tail -n 1 || true) - echo "Found $gfort" - gfort_path=$(which ${gfort}) - folder=$(dirname ${gfort_path}) - ln -s ${gfort_path} ${folder}/gfortran - fi - echo "MPI_OPTS=--oversubscribe" >> $GITHUB_ENV - - - name: Print information on MPI and HDF5 libraries - run: | - ompi_info - h5pcc -showconfig -echo || true - - - name: Upgrade pip - run: | - python -m pip install --upgrade pip - - - name: Determine directory of parallel HDF5 library - run: | - if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then - HDF5_DIR=$(dpkg -L libhdf5-openmpi-dev | grep libhdf5.so | xargs dirname) - elif [[ "${{ matrix.os }}" == "macos-14" ]]; then - HDF5_DIR=$(brew list hdf5-mpi | grep "libhdf5.dylib" | xargs dirname | xargs dirname) - fi - echo $HDF5_DIR - echo "HDF5_DIR=$HDF5_DIR" >> $GITHUB_ENV - - - name: Cache PETSc - uses: actions/cache@v4 - id: cache-petsc - env: - cache-name: cache-PETSc - with: - path: "./petsc" - key: petsc-${{ matrix.os }}-${{ matrix.python-version }} - - - if: steps.cache-petsc.outputs.cache-hit != 'true' - name: Download a specific release of PETSc - run: | - git clone --depth 1 --branch v3.23.3 https://gitlab.com/petsc/petsc.git - - - if: steps.cache-petsc.outputs.cache-hit != 'true' - name: Install PETSc with complex support - working-directory: ./petsc - run: | - export PETSC_DIR=$(pwd) - export PETSC_ARCH=petsc-cmplx - ./configure --with-scalar-type=complex --with-fortran-bindings=0 --have-numpy=1 --download-fblaslapack=1 - make all - echo "PETSC_DIR=$PETSC_DIR" > petsc.env - echo "PETSC_ARCH=$PETSC_ARCH" >> petsc.env - - # This step is not really necessary and could be combined with PETSc install - # step; however it's good to verify if the cached PETSc installation really works! - - name: Test PETSc installation - working-directory: ./petsc - run: | - source petsc.env - make check - echo "PETSC_DIR=$PETSC_DIR" >> $GITHUB_ENV - echo "PETSC_ARCH=$PETSC_ARCH" >> $GITHUB_ENV - - - name: Install petsc4py - working-directory: ./petsc - run: | - python -m pip install wheel Cython numpy - python -m pip install src/binding/petsc4py - - # - name: Check parallel h5py installation - # run: | - # python -c " - # from mpi4py import MPI - # import h5py - # # This particular instantiation of h5py.File will fail if parallel h5py isn't installed - # f = h5py.File('parallel_test.hdf5', 'w', driver='mpio', comm=MPI.COMM_WORLD) - # print(f)" - - - name: Install project without mpi - run: | - python -m pip install ".[test]" --no-cache-dir - python -m pip freeze - - - name: Compile psydac kernels - run: | - psydac-accelerate --language ${{ matrix.compile_language }} - - # - name: Test Pyccel optimization flags - # run: | - # pytest --pyargs psydac -m pyccel --capture=no - - - name: Initialize test directory - run: | - mkdir pytest - cp mpi_tester.py pytest - - - name: Run coverage tests on macOS - if: matrix.os == 'macos-14' - working-directory: ./pytest - run: >- - python -m pytest -n auto - --cov psydac - --cov-config $GITHUB_WORKSPACE/pyproject.toml - --cov-report xml - --pyargs psydac -m "not parallel and not petsc" - - - name: Run single-process tests with Pytest on Ubuntu - if: matrix.os == 'ubuntu-latest' - working-directory: ./pytest - run: | - python -m pytest -n auto --pyargs psydac -m "not parallel and not petsc" - - - name: Run single-process PETSc tests with Pytest - working-directory: ./pytest - run: | - python -m pytest -n auto --pyargs psydac -m "not parallel and petsc" - - - name: Install project with mpi - run: | - python -m pip install ".[mpi]" - python -m pip freeze - - - name: Run MPI tests with Pytest - working-directory: ./pytest - run: | - python mpi_tester.py --mpirun="mpiexec -n 4 ${MPI_OPTS}" --pyargs psydac -m "parallel and not petsc" - - - name: Run MPI PETSc tests with Pytest - working-directory: ./pytest - run: | - python mpi_tester.py --mpirun="mpiexec -n 4 ${MPI_OPTS}" --pyargs psydac -m "parallel and petsc" - - - name: Remove test directory - if: always() - run: | - rm -rf pytest - - test_struphy: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ ubuntu-latest ] - # TODO: Make sure that struphy works with python > 3.11, keep the lower bound to 3.10 - python-version: [ '3.10', '3.12', '3.13' ] - compile_language: ['c', 'fortran'] - isMerge: - - ${{ github.event_name == 'push' && github.ref == 'refs/heads/devel' }} - # exclude: - # - { isMerge: false, python-version: '3.10' } - # - { isMerge: false, python-version: '3.11' } - # include: - # - os: macos-14 - # python-version: '3.10' - # - os: macos-14 - # python-version: '3.13' - - name: Test Struphy on ${{ matrix.os }} / Python ${{ matrix.python-version }} / ${{ matrix.compile_language }} - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: | - pyproject.toml - requirements.txt - - - name: Install non-Python dependencies on Ubuntu - if: matrix.os == 'ubuntu-latest' - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: gfortran openmpi-bin libopenmpi-dev libhdf5-openmpi-dev g++ liblapack3 cmake cmake-curses-gui zlib1g-dev libnetcdf-dev libnetcdff-dev - version: 1.0 - execute_install_scripts: true - - # When loading cached apt packages, the default MPI compiler isn't set. - # Workaround is to 'reinstall' openmpi-bin, which doesn't actually perform - # installation (since openmpi-bin already exists), but instead reruns - # `update-alternatives` which fixes the symlinks to mpicc/mpif90. - - name: Reconfigure non-Python dependencies on Ubuntu - if: matrix.os == 'ubuntu-latest' - run: | - sudo apt-get update - sudo apt-get install --reinstall openmpi-bin libhdf5-openmpi-dev liblapack-dev libblas-dev liblapack3 - - - name: Install non-Python dependencies on macOS - if: matrix.os == 'macos-14' - run: | - brew install open-mpi - brew install hdf5-mpi - brew install libomp - brew update - brew install python3 - brew install gcc - brew install openblas - brew install lapack - brew install git - brew install pandoc - brew install cmake - brew install netcdf-fortran - brew install pkgconf - GFORTRAN_HOME=$(which gfortran || true) - echo "GFORTRAN_HOME : $GFORTRAN_HOME" - if [[ ! -f "$GFORTRAN_HOME" ]]; then - gfort=$(find ${PATH//:/\/ } -name 'gfortran-*' -exec basename {} \; | sort | tail -n 1 || true) - echo "Found $gfort" - gfort_path=$(which ${gfort}) - folder=$(dirname ${gfort_path}) - ln -s ${gfort_path} ${folder}/gfortran - fi - echo "MPI_OPTS=--oversubscribe" >> $GITHUB_ENV - - - name: Print information on MPI and HDF5 libraries - run: | - ompi_info - h5pcc -showconfig -echo || true - - - name: Upgrade pip - run: | - python -m pip install --upgrade pip - - - name: Install project without mpi - run: | - python -m pip install ".[test]" --no-cache-dir - python -m pip freeze - - - name: Set up environment variables - run: | - echo "PSYDAC_DIR=$GITHUB_WORKSPACE" >> $GITHUB_ENV - echo "STRUPHY_DIR=$GITHUB_WORKSPACE/struphy" >> $GITHUB_ENV - - - name: Clone struphy from GitLab - run: | - git clone https://gitlab.mpcdf.mpg.de/struphy/struphy.git $STRUPHY_DIR - - - name: Install struphy without mpi #TODO: Set branch to devel - working-directory: ${{ env.STRUPHY_DIR }} - run: | - echo "Psydac location for this branch" - pip show psydac - pip uninstall psydac -y - python -m pip install ".[phys]" --no-cache-dir - echo "Psydac location after installing struphy" - pip show psydac - - - name: Re-install Psydac from the current branch - run: | - echo "Uninstall psydac" - psydac-accelerate --cleanup --yes - pip show psydac - pip uninstall psydac -y - python -m pip install ${{ env.PSYDAC_DIR }} --force-reinstall --no-cache-dir - echo "Psydac location after installing psydac from the current branch (should be the same as in the previous step)" - pip show psydac - - - name: Compile struphy - working-directory: ${{ env.STRUPHY_DIR }} - run: | - pip show psydac - struphy -h - struphy compile -y --language ${{ matrix.compile_language }} - - - name: Run struphy unit tests - working-directory: ${{ env.STRUPHY_DIR }} - run: | - struphy test unit - - - name: Run struphy model tests - working-directory: ${{ env.STRUPHY_DIR }} - run: | - struphy test models --fast - - - name: Install mpi4py - working-directory: ${{ env.STRUPHY_DIR }} - run: | - pip install -U mpi4py - - - name: Run struphy unit tests with mpi - working-directory: ${{ env.STRUPHY_DIR }} - run: | - struphy test unit --mpi 2 - - - name: Remove test directory - if: always() - run: | - rm -rf pytest