diff --git a/.github/workflows/asv.yml b/.github/workflows/asv.yml new file mode 100644 index 00000000000..ec75cb81ccf --- /dev/null +++ b/.github/workflows/asv.yml @@ -0,0 +1,96 @@ +# Runner information: +# CPU: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz +# GPU: NVIDIA GeForce RTX 2060 + +name: asv-benchmarks + +env: + OUTPUT_PATH: ${{ github.workspace }} + ENVHOME: "/home/devito/environments" + +on: + workflow_dispatch: + inputs: + tags: + description: 'Run ASV' + # Trigger the workflow on push to the master branch + push: + branches: + - master + +jobs: + + # Run the asv benchmarks on the self-hosted runner + benchmarks: + name: benchmarks + runs-on: [self-hosted, asv] + + env: + DEVITO_ARCH: "gcc-9" + DEVITO_LANGUAGE: "openmp" + DEVITO_BENCHMARKS: "1" + DEVITO_LOGGING: "PERF" + OMP_NUM_THREADS: "8" + CC: "gcc-9" + CXX: "g++-9" + + steps: + - name: Checkout devito + uses: actions/checkout@v3 + + - name: Set VIRTUAL_ENV + run: | + echo "VIRTUAL_ENV=$ENVHOME/asv" >> $GITHUB_ENV + echo "PATH=$VIRTUAL_ENV/bin:$PATH" >> $GITHUB_ENV + + - name: Set PATH + run: | + echo "PATH=$VIRTUAL_ENV/bin:$PATH" >> $GITHUB_ENV + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install --upgrade asv + + - name: Setup asv + run: | + asv machine --config benchmarks/regression/asv.conf.json --machine i7-6700K --os ubuntu-20.10 --arch x86-64 --cpu i7-6700K --num_cpu 8 --ram 16GB + + - name: Run benchmarks + run: | + asv run -v --show-stderr --config benchmarks/regression/asv.conf.json --cpu-affinity 0-7 --machine i7-6700K + + - name: Checkout asv-results branch + uses: actions/checkout@v3 + with: + ref: asv-results + clean: false + + - name: Commit benchmarks results + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + asv run --config benchmarks/regression/asv.conf.json --bench just-discover --machine i7-6700K + git add -f benchmarks/regression/.asv/results/ + git status + git commit -m "Commit ASV results" + + - name: Push benchmarks results to the asv-results branch + uses: ad-m/github-push-action@master + with: + branch: asv-results + force: true + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Create results (html) + run: | + asv publish --config benchmarks/regression/asv.conf.json + rm -f /tmp/ssh-auth.sock + + - name: Deploy results to devitocodes/devito-performance/gh-pages + uses: peaceiris/actions-gh-pages@v3 + with: + deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} + external_repository: devitocodes/devito-performance + publish_branch: gh-pages + publish_dir: ./benchmarks/regression/.asv/html diff --git a/.github/workflows/docker-bases.yml b/.github/workflows/docker-bases.yml new file mode 100644 index 00000000000..96846320fc5 --- /dev/null +++ b/.github/workflows/docker-bases.yml @@ -0,0 +1,214 @@ +name: Build base compilers docker images + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + push: + paths: + - '/docker/Dockerfile.nvidia' + - '/docker/Dockerfile.cpu' + - '/docker/Dockerfile.amd' + workflow_dispatch: + inputs: + tags: + description: 'Build compiler bases' + schedule: + # Run once a week + - cron: "0 13 * * 1" + +jobs: +####################################################### +############## Basic gcc CPU ########################## +####################################################### + deploy-cpu-bases: + name: "cpu-base" + runs-on: ubuntu-latest + env: + DOCKER_BUILDKIT: "1" + + steps: + - name: Checkout devito + uses: actions/checkout@v3 + + - name: Check event name + run: echo ${{ github.event_name }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: cleanup + run: docker system prune -a -f + + - name: GCC image + uses: docker/build-push-action@v3 + with: + context: . + file: './docker/Dockerfile.cpu' + push: true + target: 'gcc' + build-args: 'arch=gcc' + tags: 'devitocodes/bases:cpu-gcc' + +####################################################### +############## Intel OneApi CPU ####################### +####################################################### + deploy-oneapi-bases: + name: "oneapi-base" + runs-on: ubuntu-latest + env: + DOCKER_BUILDKIT: "1" + + steps: + - name: Checkout devito + uses: actions/checkout@v3 + + - name: Check event name + run: echo ${{ github.event_name }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: cleanup + run: docker system prune -a -f + + - name: ICX image + uses: docker/build-push-action@v3 + with: + context: . + file: './docker/Dockerfile.cpu' + push: true + target: 'icx' + build-args: 'arch=icx' + tags: 'devitocodes/bases:cpu-icx' + +####################################################### +################### Nvidia nvhpc ###################### +####################################################### + deploy-nvidia-bases: + name: "nvidia-bases" + runs-on: ["self-hosted", "nvidiagpu"] + env: + DOCKER_BUILDKIT: "1" + + steps: + - name: Checkout devito + uses: actions/checkout@v3 + + - name: Check event name + run: echo ${{ github.event_name }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: cleanup + run: docker system prune -a -f + + - name: NVC image + uses: docker/build-push-action@v3 + with: + context: . + file: './docker/Dockerfile.nvidia' + push: true + target: 'nvc' + build-args: 'arch=nvc' + tags: 'devitocodes/bases:nvidia-nvc' + + - name: NVCC image + uses: docker/build-push-action@v3 + with: + context: . + file: './docker/Dockerfile.nvidia' + push: true + target: 'nvcc' + build-args: 'arch=nvcc' + tags: 'devitocodes/bases:nvidia-nvcc' + + - name: NVC host image + uses: docker/build-push-action@v3 + with: + context: . + file: './docker/Dockerfile.nvidia' + push: true + target: 'nvc-host' + build-args: 'arch=nvc-host' + tags: 'devitocodes/bases:cpu-nvc' + +####################################################### +##################### AMD ############################# +####################################################### + deploy-amd-bases: + name: "amd-base" + runs-on: ["self-hosted", "amdgpu"] + env: + DOCKER_BUILDKIT: "1" + + steps: + - name: Checkout devito + uses: actions/checkout@v3 + + - name: Check event name + run: echo ${{ github.event_name }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: cleanup + run: docker system prune -a -f + + - name: AMD image + uses: docker/build-push-action@v3 + with: + context: . + file: './docker/Dockerfile.amd' + push: true + target: 'amdclang' + tags: devitocodes/bases:amd + + - name: AMD HIP image + uses: docker/build-push-action@v3 + with: + context: . + file: './docker/Dockerfile.amd' + push: true + target: 'hip' + build-args: | + arch=hip + tags: devitocodes/bases:amd-hip diff --git a/.github/workflows/docker-devito.yml b/.github/workflows/docker-devito.yml new file mode 100644 index 00000000000..597eed67405 --- /dev/null +++ b/.github/workflows/docker-devito.yml @@ -0,0 +1,109 @@ +name: Publish devito docker images from compiler bases + +on: + release: + types: [published] + push: + branches: + - master # Push events on master branch + +jobs: + deploy-devito: + runs-on: ${{ matrix.runner }} + env: + # Use buildkit https://docs.docker.com/develop/develop-images/build_enhancements/ for better build + DOCKER_BUILDKIT: "1" + + strategy: + fail-fast: false + matrix: + include: + - base: 'bases:nvidia-nvc' + tag: 'nvidia-nvc' + flag: '--gpus all' + test: 'tests/test_gpu_openacc.py tests/test_gpu_common.py' + runner: ["self-hosted", "nvidiagpu"] + + # Runtime gpu flags from https://hub.docker.com/r/rocm/tensorflow/ + - base: 'bases:amd' + tag: 'amd' + flag: '--network=host --device=/dev/kfd --device=/dev/dri --ipc=host --group-add video --group-add $(getent group render | cut -d: -f3) --cap-add=SYS_PTRACE --security-opt seccomp=unconfined' + test: 'tests/test_gpu_openmp.py' + runner: ["self-hosted", "amdgpu"] + + - base: 'bases:cpu-gcc' + tag: "gcc" + flag: '' + test: 'tests/test_operator.py' + runner: ubuntu-latest + + - base: 'bases:cpu-icx' + tag: "icx" + flag: '' + test: 'tests/test_operator.py' + runner: ubuntu-latest + + steps: + - name: Checkout devito + uses: actions/checkout@v3 + + - name: Check event name + run: echo ${{ github.event_name }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + flavor: | + latest=false + images: | + devitocodes/devito + # Creates all the tags to be pushed. + # `event`` is the trigger even (pr for pull request, tag for release) + # `value/pattern` is the actual tag + # `enable` is a "if" filter fir that tag + # `type` is the type of tag + tags: | + type=raw,value=${{ matrix.tag }}-dev + type=raw,value=${{ matrix.tag }}-latest,enable=${{ github.event_name == 'release' }} + type=raw,value=latest,enable=${{ matrix.base == 'bases:cpu-gcc' }} + type=semver,pattern={{raw}},prefix=${{ matrix.tag }}-,enable=${{ github.event_name == 'release' }} + # Legacy "gpu" tag + type=raw,value=gpu-dev,enable=${{ matrix.base == 'bases:nvidia-nvc' }} + type=semver,pattern={{raw}},prefix=gpu-,enable=${{ github.event_name == 'release' && matrix.base == 'bases:nvidia-nvc' }} + type=semver,pattern={{raw}},value=gpu-latest,enable=${{ github.event_name == 'release' && matrix.base == 'bases:nvidia-nvc' }} + # Legacy "cpu" tag + type=raw,value=cpu-dev,enable=${{ matrix.base == 'bases:cpu-gcc' }} + type=semver,pattern={{raw}},prefix=cpu-,enable=${{ github.event_name == 'release' && matrix.base == 'bases:cpu-gcc' }} + type=semver,pattern={{raw}},value=cpu-latest,enable=${{ github.event_name == 'release' && matrix.base == 'bases:cpu-gcc' }} + + - name: Check tags + run: echo "${{ steps.meta.outputs.tags }}" + + - name: Build and push image + uses: docker/build-push-action@v3 + with: + context: . + file: ./docker/Dockerfile.devito + push: true + tags: ${{ steps.meta.outputs.tags }} + build-args: base=devitocodes/${{ matrix.base }} + + - name: Remove dangling layers + run: docker system prune -f + + - name: Run tests + run: | + docker run ${{ matrix.flag }} --rm --name testrun 'devitocodes/devito:${{ matrix.tag }}-dev' pytest ${{ matrix.test }} diff --git a/.github/workflows/examples-mpi.yml b/.github/workflows/examples-mpi.yml new file mode 100644 index 00000000000..2c8fb09f858 --- /dev/null +++ b/.github/workflows/examples-mpi.yml @@ -0,0 +1,81 @@ +# Runner information: +# CPU: Intel(R) Xeon(R) CPU E5-2640 0 @ 2.50GHz (24 cores) + +name: Examples-mpi + +env: + OUTPUT_PATH: ${{ github.workspace }} + ENVHOME: "/home/devito/environments" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + # Trigger the workflow on push or pull request, + # but only for the master branch + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + name: Examples with mpi + runs-on: ubuntu-latest + strategy: + matrix: + mpi: ['openmpi', 'intelmpi'] + + include: + - mpi: openmpi + mpiarg: "-n 2 --oversubscribe" + + - mpi: intelmpi + mpiarg: "-n 4" + + env: + DEVITO_MPI: "1" + DEVITO_LANGUAGE: "openmp" + OMP_NUM_THREADS: "2" + DEVITO_ARCH: "gcc" + CC: "gcc" + CXX: "g++" + + steps: + - name: Checkout devito + uses: actions/checkout@v3 + + - name: Setup MPI + uses: mpi4py/setup-mpi@v1 + with: + mpi: ${{ matrix.mpi }} + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install -e .[extras,mpi,tests] + python3 scripts/clear_devito_cache.py + + - name: Test mpi notebooks + continue-on-error: true + run : | + ./scripts/create_ipyparallel_mpi_profile.sh + ipcluster start --profile=mpi --engines=mpi -n 4 --daemonize + # A few seconds to ensure workers are ready + sleep 20 + py.test --nbval examples/mpi + ipcluster stop --profile=mpi + + - name: Test seismic examples + run: | + mpirun ${{ matrix.mpiarg }} pytest examples/seismic/tti/tti_example.py + mpirun ${{ matrix.mpiarg }} pytest examples/seismic/elastic/elastic_example.py + mpirun ${{ matrix.mpiarg }} pytest examples/seismic/viscoacoustic/viscoacoustic_example.py + mpirun ${{ matrix.mpiarg }} pytest examples/seismic/viscoelastic/viscoelastic_example.py + + - name: Test fwi examples with mpi + run: | + mpirun ${{ matrix.mpiarg }} python examples/seismic/inversion/fwi.py diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml new file mode 100644 index 00000000000..b4eb3d55a1a --- /dev/null +++ b/.github/workflows/examples.yml @@ -0,0 +1,93 @@ +name: Examples + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + # Trigger the workflow on push or pull request, + # but only for the master branch + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + tutorials: + name: Examples with conda install + runs-on: ubuntu-latest + + defaults: + # Default for conda env + run: + shell: bash -l {0} + + env: + DEVITO_ARCH: gcc + DEVITO_LANGUAGE: "openmp" + + strategy: + # Prevent all build to stop if a single one fails + fail-fast: false + + steps: + - name: Checkout devito + uses: actions/checkout@v3 + + - name: Setup conda + uses: conda-incubator/setup-miniconda@v2 + with: + python-version: 3.8 + activate-environment: devito + environment-file: environment-dev.yml + auto-activate-base: false + + - name: Install dependencies + run: | + pip install -e .[tests,extras] + + - name: Tests in examples + run: | + py.test --cov --cov-config=.coveragerc --cov-report=xml examples/ + + - name: Seismic acoustic examples + run: | + python examples/seismic/acoustic/acoustic_example.py --full + python examples/seismic/acoustic/acoustic_example.py --full --checkpointing + python examples/seismic/acoustic/acoustic_example.py --constant --full + python examples/seismic/acoustic/acoustic_example.py --fs + python examples/seismic/inversion/fwi.py + python examples/seismic/self_adjoint/example_iso.py + python examples/seismic/viscoacoustic/viscoacoustic_example.py + python examples/seismic/viscoacoustic/viscoacoustic_example.py -k kv + python examples/seismic/viscoacoustic/viscoacoustic_example.py -k maxwell + + - name: Seismic tti examples + run: | + python examples/seismic/tti/tti_example.py -a basic + python examples/seismic/tti/tti_example.py -a basic --noazimuth + python examples/seismic/tti/tti_example.py -k staggered + python examples/seismic/tti/tti_example.py -nd 2 --full -so 12 + python examples/seismic/tti/tti_example.py -nd 2 --full -so 4 --checkpointing + + - name: Seismic elastic examples + run: | + python examples/seismic/elastic/elastic_example.py + python examples/seismic/viscoelastic/viscoelastic_example.py + + - name: Linear algebra example + run: | + python examples/misc/linalg.py mat-vec mat-mat mat-mat-sum transpose-mat-vec + python examples/misc/linalg.py mat-vec -o mat-mat -o mat-mat-sum -o transpose-mat-vec -o + + - name: CFD examples + run: | + python examples/cfd/example_diffusion.py + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + name: ${{ matrix.name }} diff --git a/.github/workflows/pytest-core-mpi.yml b/.github/workflows/pytest-core-mpi.yml new file mode 100644 index 00000000000..581fc94e9ca --- /dev/null +++ b/.github/workflows/pytest-core-mpi.yml @@ -0,0 +1,81 @@ +name: CI-mpi + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + # Trigger the workflow on push or pull request, + # but only for the master branch + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test-mpi-basic: + name: pytest-mpi + runs-on: ubuntu-20.04 + strategy: + matrix: + python-version: ['3.8','3.9'] + + env: + DEVITO_LANGUAGE: "openmp" + DEVITO_ARCH: "gcc-9" + OMP_NUM_THREADS: "1" + CC: "gcc-9" + CXX: "g++-9" + + steps: + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Checkout devito + uses: actions/checkout@v3 + + - name: Install dependencies + run: | + sudo apt-get update && sudo apt install mpich -y + pip3 install --upgrade pip + pip3 install -e .[extras,mpi,tests] + + - 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: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + name: pytest-mpi + + test-mpi-docker: + name: pytest-mpi + runs-on: ${{ matrix.os }} + strategy: + matrix: + name: [gcc, icx] + include: + - name: gcc + arch: gcc + os: ubuntu-latest + - name: icx + arch: icx + os: ubuntu-latest + + steps: + - name: Checkout devito + uses: actions/checkout@v3 + + - name: Build docker image + run: | + docker build . --file docker/Dockerfile.devito --tag devito_img --build-arg base=devitocodes/bases:cpu-${{ matrix.arch }} + + - name: Test with pytest + run: | + docker run --rm -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} -e OMP_NUM_THREADS=1 --name testrun devito_img pytest tests/test_mpi.py \ No newline at end of file diff --git a/.github/workflows/pytest-core-nompi.yml b/.github/workflows/pytest-core-nompi.yml new file mode 100644 index 00000000000..af0127b0532 --- /dev/null +++ b/.github/workflows/pytest-core-nompi.yml @@ -0,0 +1,176 @@ +name: CI-core + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + # Trigger the workflow on push or pull request, + # but only for the master branch + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + pytest: + name: ${{ matrix.name }}-${{ matrix.set }} + runs-on: "${{ matrix.os }}" + + env: + DEVITO_ARCH: "${{ matrix.arch }}" + DEVITO_LANGUAGE: ${{ matrix.language }} + OMP_NUM_THREADS: 2 + + strategy: + # Prevent all build to stop if a single one fails + fail-fast: false + + matrix: + name: [ + pytest-ubuntu-py311-gcc11-noomp, + pytest-ubuntu-py38-gcc12-omp, + pytest-ubuntu-py37-gcc7-omp, + pytest-ubuntu-py310-gcc10-noomp, + pytest-ubuntu-py38-gcc8-omp, + pytest-ubuntu-py39-gcc9-omp, + pytest-osx-py37-clang-omp, + pytest-docker-py39-gcc-omp, + pytest-docker-py39-icx-omp + ] + set: [base, adjoint] + include: + - name: pytest-ubuntu-py311-gcc11-noomp + python-version: '3.11' + os: ubuntu-22.04 + arch: "gcc-11" + language: "C" + sympy: "1.11" + + - name: pytest-ubuntu-py38-gcc12-omp + python-version: '3.8' + os: ubuntu-22.04 + arch: "gcc-12" + language: "openmp" + sympy: "1.10" + + - name: pytest-ubuntu-py37-gcc7-omp + python-version: '3.7' + os: ubuntu-20.04 + arch: "gcc-7" + language: "openmp" + sympy: "1.9" + + - name: pytest-ubuntu-py310-gcc10-noomp + python-version: '3.10' + os: ubuntu-20.04 + arch: "gcc-10" + language: "C" + sympy: "1.10" + + - name: pytest-ubuntu-py38-gcc8-omp + python-version: '3.8' + os: ubuntu-20.04 + arch: "gcc-8" + language: "openmp" + sympy: "1.11" + + - name: pytest-ubuntu-py39-gcc9-omp + python-version: '3.9' + os: ubuntu-20.04 + arch: "custom" + language: "openmp" + sympy: "1.9" + + - name: pytest-osx-py37-clang-omp + python-version: '3.7' + os: macos-latest + arch: "clang" + language: "C" + sympy: "1.9" + + - name: pytest-docker-py39-gcc-omp + python-version: '3.9' + os: ubuntu-latest + arch: "gcc" + language: "openmp" + sympy: "1.12" + + - name: pytest-docker-py39-icx-omp + python-version: '3.9' + os: ubuntu-latest + arch: "icx" + language: "openmp" + sympy: "1.12" + + - set: base + test-set: 'not adjoint' + + - set: adjoint + test-set: 'adjoint' + + exclude: + - name: pytest-osx-py37-clang-omp + set: adjoint + + steps: + - name: Checkout devito + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + if: "!contains(matrix.name, 'docker')" + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Build docker image + if: contains(matrix.name, 'docker') + run: | + docker build . --file docker/Dockerfile.devito --tag devito_img --build-arg base=devitocodes/bases:cpu-${{ matrix.arch }} + + - name: Set run prefix + run: | + if [[ "${{ matrix.name }}" =~ "docker" ]]; then + echo "RUN_CMD=docker run --rm -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} --name testrun devito_img" >> $GITHUB_ENV + else + echo "RUN_CMD=" >> $GITHUB_ENV + fi + id: set-run + + - name: Install ${{ matrix.arch }} compiler + if: "runner.os == 'linux' && !contains(matrix.name, 'docker') && matrix.arch !='custom' " + run : | + sudo apt-get install -y ${{ matrix.arch }} + + - 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 + fi + id: set-tests + + - name: Install dependencies + if: "!contains(matrix.name, 'docker')" + run: | + pip install --upgrade pip + pip install -e .[tests] + pip install sympy==${{matrix.sympy}} + + - name: Check configuration + run: | + ${{ env.RUN_CMD }} python3 -c "from devito import configuration; print(''.join(['%s: %s \n' % (k, v) for (k, v) in configuration.items()]))" + + - name: Test with pytest + run: | + ${{ env.RUN_CMD }} pytest -k "${{ matrix.test-set }}" -m "not parallel" --cov --cov-config=.coveragerc --cov-report=xml ${{ env.TESTS }} + + - name: Upload coverage to Codecov + if: "!contains(matrix.name, 'docker')" + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + name: ${{ matrix.name }} diff --git a/.github/workflows/pytest-gpu.yml b/.github/workflows/pytest-gpu.yml new file mode 100644 index 00000000000..71f00331068 --- /dev/null +++ b/.github/workflows/pytest-gpu.yml @@ -0,0 +1,96 @@ +# Runner information: +# OpenACC on NVidia runs on `nvidiagpu` +# OpenMP on NVidia runs on `nvidiagpu` +# OpenMP on AMD runs on `amdgpu` + +name: CI-gpu + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + OUTPUT_PATH: ${{ github.workspace }} + RESOURCE_GROUP: CI-gpu + +on: + # Trigger the workflow on push or pull request, + # but only for the master branch + push: + branches: + - master + pull_request: + branches: + - master + # Push-button activation + workflow_dispatch: + inputs: + tags: + description: 'Run GPU tests' + +jobs: + + build: + name: ${{ matrix.name }} + runs-on: ${{ matrix.tags }} + + env: + DEVITO_ARCH: ${{ matrix.arch }} + DEVITO_PLATFORM: ${{ matrix.platform }} + DEVITO_LANGUAGE: ${{ matrix.language }} + OMPI_CC: ${{ matrix.arch }} + + strategy: + # Prevent all builds from terminating if one fails + fail-fast: false + + matrix: + name: [ + pytest-gpu-acc-nvidia, + pytest-gpu-omp-amd + ] + test_examples: ["examples/seismic/tti/tti_example.py examples/seismic/acoustic/acoustic_example.py examples/seismic/viscoacoustic/viscoacoustic_example.py examples/seismic/viscoelastic/viscoelastic_example.py examples/seismic/elastic/elastic_example.py"] + + include: + - name: pytest-gpu-acc-nvidia + test_files: "tests/test_adjoint.py tests/test_gpu_common.py tests/test_gpu_openacc.py" + base: "devitocodes/bases:nvidia-nvc" + tags: ["self-hosted", "nvidiagpu"] + test_drive_cmd: "nvidia-smi" + flags: '--gpus all --rm --name testrun-nvc' + + - name: pytest-gpu-omp-amd + test_files: "tests/test_adjoint.py tests/test_gpu_common.py tests/test_gpu_openmp.py" + tags: ["self-hosted", "amdgpu"] + base: "devitocodes/bases:amd" + test_drive_cmd: "rocm-smi" + # Attach the AMD GPU devices `/dev` and add user to video and render (109 on wampa) group + # Options from https://rocmdocs.amd.com/en/latest/ROCm_Virtualization_Containers/ROCm-Virtualization-&-Containers.html + flags: "--network=host --device=/dev/kfd --device=/dev/dri --ipc=host --group-add video --group-add $(getent group render | cut -d: -f3) --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --rm --name testrun-amd" + + steps: + - name: Checkout devito + uses: actions/checkout@v3 + + - name: Build docker image + run: | + docker build . --rm --pull --file docker/Dockerfile.devito --tag ${{ matrix.name }} --build-arg base=${{ matrix.base }} + + - name: Remove dangling layers + run: docker system prune -f + + - name: Test with pytest + run: | + # Remove all existing containers for safety + docker ps -aq | xargs -r docker rm -f + # Run tests + docker run ${{ matrix.flags }} ${{ matrix.name }} ${{ matrix.test_drive_cmd }} + docker run ${{ matrix.flags }} -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} ${{ matrix.name }} pytest --cov --cov-config=.coveragerc --cov-report=xml ${{ matrix.test_files }} + + - name: Test examples + run: | + docker run ${{ matrix.flags }} ${{ matrix.name }} pytest ${{ matrix.test_examples }} + + - name: Test examples with MPI + run: | + docker run ${{ matrix.flags }} --env DEVITO_MPI=1 ${{ matrix.name }} mpiexec -n 2 pytest ${{ matrix.test_examples }} diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml new file mode 100644 index 00000000000..c215ffeecdf --- /dev/null +++ b/.github/workflows/pythonpublish.yml @@ -0,0 +1,26 @@ +name: Upload to PyPI + +on: + release: + types: [published] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/.github/workflows/tutorials.yml b/.github/workflows/tutorials.yml new file mode 100644 index 00000000000..fab303b18ab --- /dev/null +++ b/.github/workflows/tutorials.yml @@ -0,0 +1,130 @@ +name: Jupyter Notebooks + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + # Trigger the workflow on push or pull request, + # but only for the master branch + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + tutorials: + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + + env: + DEVITO_ARCH: "${{ matrix.compiler }}" + DEVITO_LANGUAGE: ${{ matrix.language }} + PYTHON_VERSION: "3.9" + + strategy: + # Prevent all build to stop if a single one fails + fail-fast: false + matrix: + name: [ + tutos-ubuntu-gcc-py39, + tutos-osx-clang-py39, + tutos-docker-gcc-py39 + ] + + include: + - name: tutos-ubuntu-gcc-py39 + os: ubuntu-latest + compiler: gcc + language: "openmp" + + - name: tutos-osx-clang-py39 + os: macos-latest + compiler: clang + language: "C" + + - name: tutos-docker-gcc-py39 + os: ubuntu-latest + compiler: gcc + language: "openmp" + + steps: + - name: Checkout devito + uses: actions/checkout@v3 + + - name: Set up Python 3.9 + if: "!contains(matrix.name, 'docker')" + uses: actions/setup-python@v4 + with: + python-version: 3.9 + + - uses: maxim-lobanov/setup-xcode@v1 + if: runner.os == 'macOS' + with: + xcode-version: latest-stable + + - name: Build docker image + if: "contains(matrix.name, 'docker')" + run: | + docker build . --file docker/Dockerfile.devito --tag devito_img + + - name: Set run prefix + run: | + if [ "${{ matrix.name }}" == 'tutos-docker-gcc-py39' ]; then + echo "RUN_CMD=docker run --rm --name testrun devito_img" >> $GITHUB_ENV + else + echo "RUN_CMD=" >> $GITHUB_ENV + fi + id: set-run + + - name: Install dependencies + if: matrix.name != 'tutos-docker-gcc-py39' + run: | + python -m pip install --upgrade pip + pip install -e .[tests,extras] + pip install blosc + + - name: Seismic notebooks + run: | + ${{ env.RUN_CMD }} py.test --nbval -k 'not dask' -k 'not synthetics' examples/seismic/tutorials/ + ${{ env.RUN_CMD }} py.test --nbval examples/seismic/acoustic/accuracy.ipynb + + - name: Failing notebooks + continue-on-error: true + run: | + ${{ env.RUN_CMD }} py.test --nbval examples/seismic/tutorials/14_creating_synthetics.ipynb + + - name: Dask notebooks + if: runner.os != 'macOS' + run: | + ${{ env.RUN_CMD }} py.test --nbval examples/seismic/tutorials/*dask*.ipynb + + - name: Self-adjoint notebooks + run: | + ${{ env.RUN_CMD }} py.test --nbval examples/seismic/self_adjoint/ + + - name: CFD notebooks + run: | + ${{ env.RUN_CMD }} py.test --nbval examples/cfd + + - name: User api notebooks + run: | + ${{ env.RUN_CMD }} py.test --nbval examples/userapi + + - name: Compiler notebooks + run: | + ${{ env.RUN_CMD }} py.test --nbval examples/compiler + + - name: Finance notebooks + run: | + ${{ env.RUN_CMD }} py.test --nbval examples/finance + + - name: Performance notebooks + run: | + ${{ env.RUN_CMD }} py.test --nbval examples/performance + + - name: ABC Notebooks + run: | + ${{ env.RUN_CMD }} py.test --nbval examples/seismic/abc_methods diff --git a/xdsl_llvm.docker b/xdsl_llvm.docker index 26a304c4cf0..9d57b4c46c2 100644 --- a/xdsl_llvm.docker +++ b/xdsl_llvm.docker @@ -18,7 +18,16 @@ RUN git init llvm-project \ && git checkout --progress --force FETCH_HEAD \ && mkdir build \ && cd build \ - && cmake -G Ninja ../llvm -DLLVM_ENABLE_PROJECTS="mlir;clang;openmp;lld" -DLLVM_BUILD_EXAMPLES=ON -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=OFF -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLLVM_ENABLE_LLD=ON -DLLVM_BINUTILS_INCDIR=/usr/include \ + && cmake -G Ninja ../llvm \ + -DLLVM_ENABLE_PROJECTS="mlir;clang;openmp;lld" \ + -DLLVM_BUILD_EXAMPLES=ON \ + -DLLVM_TARGETS_TO_BUILD="X86" \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_ASSERTIONS=OFF \ + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_CXX_COMPILER=clang++ \ + -DLLVM_ENABLE_LLD=ON \ + -DLLVM_BINUTILS_INCDIR=/usr/include \ && ninja install \ && cd ../../ \ && rm -rf llvm-project