Skip to content

dsl: Add PETSc functionality#2570

Open
ZoeLeibowitz wants to merge 115 commits into
mainfrom
petsc
Open

dsl: Add PETSc functionality#2570
ZoeLeibowitz wants to merge 115 commits into
mainfrom
petsc

Conversation

@ZoeLeibowitz
Copy link
Copy Markdown
Contributor

@ZoeLeibowitz ZoeLeibowitz commented Apr 3, 2025

Work in progress PETSc functionality

TODO:

  • Add parallel tests
  • Fix CI-gpu

@mloubout mloubout added API api (symbolics, types, ...) feature-request labels Apr 3, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 3, 2025

Codecov Report

❌ Patch coverage is 40.65249% with 1619 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.87%. Comparing base (c71560b) to head (2698ce8).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
devito/petsc/iet/callbacks.py 14.33% 466 Missing ⚠️
devito/petsc/types/metadata.py 37.36% 233 Missing ⚠️
devito/petsc/iet/passes.py 31.55% 124 Missing and 4 partials ⚠️
devito/petsc/iet/builder.py 18.05% 118 Missing ⚠️
devito/petsc/iet/type_builder.py 20.68% 92 Missing ⚠️
devito/petsc/solve.py 23.95% 73 Missing ⚠️
devito/petsc/logging.py 36.60% 71 Missing ⚠️
devito/petsc/types/array.py 53.62% 64 Missing ⚠️
devito/petsc/iet/solve.py 24.24% 50 Missing ⚠️
devito/petsc/iet/time_dependence.py 34.66% 49 Missing ⚠️
... and 27 more

❗ There is a different number of reports uploaded between BASE (c71560b) and HEAD (2698ce8). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (c71560b) HEAD (2698ce8)
pytest-gpu-nvc-nvidiaX 1 0
pytest-gpu-aomp-amdgpuX 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2570      +/-   ##
==========================================
- Coverage   83.37%   75.87%   -7.50%     
==========================================
  Files         248      275      +27     
  Lines       51881    56537    +4656     
  Branches     4479     4820     +341     
==========================================
- Hits        43257    42899     -358     
- Misses       7867    12803    +4936     
- Partials      757      835      +78     
Flag Coverage Δ
pytest-gpu-aomp-amdgpuX ?
pytest-gpu-gcc- 74.71% <40.65%> (-3.38%) ⬇️
pytest-gpu-icx- 74.63% <40.65%> (-3.37%) ⬇️
pytest-gpu-nvc-nvidiaX ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread .github/workflows/pytest-petsc.yml Fixed
ZoeLeibowitz and others added 15 commits July 16, 2025 23:05
dsl/compiler: Fix&tidy PETSc mixed solver functionality
…ate logging (#2718)

* compiler: Utilise petsctools and start extending solver parameters functionality

examples: Add example using argparse in conjunction with PetscInitialize

* compiler: Edit argument to PetscInitialize

* compiler: Use petsctools to process solver params and start callback to set petsc options

* compiler: Progress on petscoptions callbacks

* dsl/compiler: Re-factor solver params, add solver_parameters.py file

* misc: Add tests

* compiler: Start extending the PetscSummary

* dsl: Fix hashing for solveexpr

* misc: Add tests and clean up

* compiler: Add utility function inside petsc routines

* misc: Clean up

* tests: Add command line tests with random prefixes

* compiler: Create dummy op for petscgetargs

* misc: Update requirements

* misc: Create getargs Op inside function

* compiler/dsl: Add get_info functionality to petscsolve

* compiler/misc: Drop petscgetargs callback, add functions to logging/get_info, clean up and more tests

* workflows: Fix serial wf run
* misc/compiler: Rename/separate files, clean up, add lower_petsc_symbols and change PETScSolve to petscsolve
Comment thread devito/ir/iet/visitors.py Outdated
# (PetscScalar (*)[rhs_vec->size[1]]) ctx0;
# This is the case when a1 is a LocalCompositeObject (i.e a1.is_AbstractObject)

if o.offset:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the offset a symbol at this point?

Comment on lines +21 to +93
name: ${{ matrix.name }}
runs-on: "${{ matrix.os }}"

env:
DOCKER_BUILDKIT: "1"
DEVITO_ARCH: "${{ matrix.arch }}"
DEVITO_LANGUAGE: ${{ matrix.language }}

strategy:
# Prevent all build to stop if a single one fails
fail-fast: false

# To be extended
matrix:
include:
- name: pytest-petsc
os: ubuntu-latest
arch: "gcc"
language: "C"

steps:
- name: Checkout devito
uses: actions/checkout@v4

- name: Log in to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build docker image
run: |
docker build -f docker/Dockerfile.petsc --tag devito_petsc_image:test .

- name: Set run prefix
run: |
echo "RUN_CMD=docker run --rm -t -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} --name testrun devito_petsc_image:test" >> $GITHUB_ENV
id: set-run

- name: Set tests
run : |
echo "TESTS=tests/test_petsc.py" >> $GITHUB_ENV
id: set-tests

- 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 - serial
run: |
${{ env.RUN_CMD }} mpiexec -n 1 pytest -m "not parallel" --cov --cov-config=.coveragerc --cov-report=xml ${{ env.TESTS }}

- name: Test with pytest - parallel
run: |
${{ env.RUN_CMD }} mpiexec -n 1 pytest -m parallel --cov --cov-config=.coveragerc --cov-report=xml ${{ env.TESTS }}

- name: Test examples
run: |
${{ env.RUN_CMD }} mpiexec -n 1 python3 examples/petsc/seismic/01_staggered_acoustic.py
${{ env.RUN_CMD }} mpiexec -n 1 python3 examples/petsc/cfd/01_navierstokes.py
${{ env.RUN_CMD }} mpiexec -n 1 python3 examples/petsc/Poisson/01_poisson.py
${{ env.RUN_CMD }} mpiexec -n 1 python3 examples/petsc/Poisson/02_laplace.py
${{ env.RUN_CMD }} mpiexec -n 1 python3 examples/petsc/Poisson/03_poisson.py
${{ env.RUN_CMD }} mpiexec -n 1 python3 examples/petsc/Poisson/04_poisson.py
${{ env.RUN_CMD }} mpiexec -n 1 python3 examples/petsc/random/01_helmholtz.py
${{ env.RUN_CMD }} mpiexec -n 1 python3 examples/petsc/random/02_biharmonic.py

- name: Upload coverage to Codecov
if: "!contains(matrix.name, 'docker')"
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: ${{ matrix.name }}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 days ago

Add an explicit permissions block to the workflow root in .github/workflows/pytest-petsc.yml, immediately after the trigger section (on: block) and before jobs:.
Use least privilege for this workflow: contents: read. This is sufficient for actions/checkout and does not change existing CI functionality. No other code changes, imports, or definitions are needed.

Suggested changeset 1
.github/workflows/pytest-petsc.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/pytest-petsc.yml b/.github/workflows/pytest-petsc.yml
--- a/.github/workflows/pytest-petsc.yml
+++ b/.github/workflows/pytest-petsc.yml
@@ -14,6 +14,9 @@
       - main
       - petsc
 
+permissions:
+  contents: read
+
 jobs:
   pytest:
     name: ${{ matrix.name }}
EOF
@@ -14,6 +14,9 @@
- main
- petsc

permissions:
contents: read

jobs:
pytest:
name: ${{ matrix.name }}
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API api (symbolics, types, ...) feature-request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants