-
Notifications
You must be signed in to change notification settings - Fork 247
dsl: Add PETSc functionality #2570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Temp fix until VecReplaceArray works properly in conjunction with PetscMemoryAllocator
* Compiler: Add basic initguess callback - to be improved
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2570 +/- ##
==========================================
- Coverage 83.01% 76.00% -7.02%
==========================================
Files 248 273 +25
Lines 51074 54428 +3354
Branches 4491 4603 +112
==========================================
- Hits 42401 41367 -1034
- Misses 7902 12225 +4323
- Partials 771 836 +65
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
compiler: Add Devito+PETSc MPI test
Add PETSc logging infrastructure
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
| # (PetscScalar (*)[rhs_vec->size[1]]) ctx0; | ||
| # This is the case when a1 is a LocalCompositeObject (i.e a1.is_AbstractObject) | ||
|
|
||
| if o.offset: |
There was a problem hiding this comment.
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?
| 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
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 13 hours ago
In general, the fix is to add an explicit permissions: block that restricts the GITHUB_TOKEN to the minimal scopes needed. For this workflow, the job only needs to read the repository contents (for actions/checkout) and does not push changes, manage issues, or alter other resources. Therefore, we can safely set contents: read and not grant any write permissions.
The cleanest fix without changing functionality is to add a top-level permissions: block (at the root of the workflow) so it applies to all jobs, including pytest. Concretely, in .github/workflows/pytest-petsc.yml, insert:
permissions:
contents: readbetween the concurrency block and the on: block near the top of the file. No other code changes or imports are required. This will ensure that the GITHUB_TOKEN used by actions/checkout, codecov/codecov-action, and any other steps is limited to read-only repository contents, which is sufficient for the existing behavior.
-
Copy modified lines R7-R9
| @@ -4,6 +4,9 @@ | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| # Trigger the workflow on push or pull request, | ||
| # but only for the master branch |
Work in progress PETSc functionality
TODO: