Skip to content

ci: Add UID to the dockertag #158

ci: Add UID to the dockertag

ci: Add UID to the dockertag #158

name: CI-mpi
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test-mpi-basic:
name: pytest-mpi
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.10', '3.11']
env:
DEVITO_LANGUAGE: "openmp"
DEVITO_ARCH: "gcc"
OMP_NUM_THREADS: "1"
RDMAV_FORK_SAFE: 1
steps:
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Checkout devito
uses: actions/checkout@v6
- name: Install dependencies
run: |
sudo apt-get update && sudo apt install mpich -y
pip3 install --upgrade pip
pip3 install -e ".[extras,mpi,tests]" --no-binary=mpi4py
- name: Test with pytest
run: |
python3 scripts/clear_devito_cache.py
python3 -m pytest --cov --cov-config=.coveragerc --cov-report=xml -m parallel tests/
- name: Test examples with MPI
run: |
python3 scripts/clear_devito_cache.py
DEVITO_MPI=1 mpirun -n 2 python3 -m pytest examples/seismic/acoustic
DEVITO_MPI=1 mpirun -n 2 python3 -m pytest examples/seismic/tti
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: pytest-mpi
test-mpi-docker:
name: pytest-mpi
runs-on: ${{ matrix.os }}
outputs:
unique : ${{ steps.uniquetag.outputs.unique }}
strategy:
matrix:
name: [gcc, gcc-arm, icx]
include:
- name: gcc
arch: gcc
os: ubuntu-latest
mpiflag: ""
- name: gcc-arm
arch: gcc
os: ubuntu-24.04-arm
mpiflag: ""
- name: icx
arch: icx
os: ubuntu-latest
# Need safe math for icx due to inaccuracy with mpi+sinc interpolation
mpiflag: "-e DEVITO_SAFE_MATH=1"
steps:
- name: Checkout devito
uses: actions/checkout@v6
- name: Generate unique CI tag
id: uniquetag
run: |
UNIQUE=$(echo "${GITHUB_RUN_ID}_${GITHUB_RUN_ATTEMPT}" | cksum | cut -f 1 -d " ")
echo "Unique ID: ${UNIQUE}"
echo "unique=${UNIQUE}" >> "$GITHUB_OUTPUT"
- name: Build docker image
env:
UNIQUE: ${{ steps.uniquetag.outputs.unique }}
run: |
docker build \
--file docker/Dockerfile.devito \
--tag "devito_img${UNIQUE}" \
--build-arg base=devitocodes/bases:cpu-${{ matrix.arch }} \
.
- name: Test with pytest
env:
UNIQUE: ${{ steps.uniquetag.outputs.unique }}
run: |
docker run \
--init -t --rm \
--env CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} \
--env OMP_NUM_THREADS=1 \
--name testrun \
"devito_img${UNIQUE}" \
pytest tests/test_mpi.py
- name: Test examples with MPI
env:
UNIQUE: ${{ steps.uniquetag.outputs.unique }}
run: |
docker run \
--init -t --rm \
${{ matrix.mpiflag }} \
--env DEVITO_MPI=1 \
--env OMP_NUM_THREADS=1 \
--name examplerun \
"devito_img${UNIQUE}" \
mpiexec -n 2 pytest examples/seismic/acoustic
#
docker run \
--init -t --rm \
--env DEVITO_MPI=1 \
--env OMP_NUM_THREADS=1 \
--name examplerun \
"devito_img${UNIQUE}" \
mpiexec -n 2 pytest examples/seismic/tti
- name: Cleanup
env:
UNIQUE: ${{ steps.uniquetag.outputs.unique }}
run: |
docker image rm -f "devito_img${UNIQUE}"