-
Notifications
You must be signed in to change notification settings - Fork 238
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 ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2570 +/- ##
==========================================
- Coverage 91.30% 85.39% -5.91%
==========================================
Files 245 261 +16
Lines 48495 50604 +2109
Branches 4261 4326 +65
==========================================
- Hits 44276 43211 -1065
- Misses 3521 6667 +3146
- Partials 698 726 +28
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:
|
.github/workflows/pytest-petsc.yml
Outdated
name: ${{ matrix.name }}-${{ matrix.set }} | ||
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 | ||
|
||
matrix: | ||
name: [ | ||
pytest-docker-py39-gcc-noomp | ||
] | ||
include: | ||
- name: pytest-docker-py39-gcc-noomp | ||
python-version: '3.9' | ||
os: ubuntu-latest | ||
arch: "gcc" | ||
language: "C" | ||
sympy: "1.12" | ||
|
||
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.devito --build-arg base=zoeleibowitz/petsc_image:latest --tag zoeleibowitz/petsc_devito_image:latest . | ||
|
||
- name: Set run prefix | ||
run: | | ||
echo "RUN_CMD=docker run --rm -t -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} --name testrun zoeleibowitz/petsc_devito_image:latest" >> $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 | ||
run: | | ||
${{ env.RUN_CMD }} mpiexec -n 1 pytest --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/random/01_helmholtz.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
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.
Some comments for now. Will go through some more at a later date
|
||
matrix: | ||
name: [ | ||
pytest-docker-py39-gcc-noomp |
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.
Python 3.9 is EOL soon, so this version should get bumped. It would also be worth adding an Omp run
|
||
- name: Build docker image | ||
run: | | ||
docker build -f docker/Dockerfile.devito --build-arg base=zoeleibowitz/petsc_image:latest --tag zoeleibowitz/petsc_devito_image:latest . |
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.
This image should probably be on the main Devito Dockerhub now
|
||
- 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()]))" |
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.
Ultra nitpick: fstring
${{ 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 |
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.
How about naming this folder 'misc' rather than 'random'?
@@ -17,9 +17,11 @@ on: | |||
push: | |||
branches: | |||
- main | |||
- master |
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.
These additional "master"s need dropping throughout the CI workflows
|
||
|
||
def initialize(iet): | ||
# should be int because the correct type for argc is a C int |
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.
Nitpick: comment starts with lowercase
argv = ArgvSymbol(name='argv') | ||
Help = Macro('help') | ||
|
||
help_string = c.Line(r'static char help[] = "This is help text.\n";') |
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 this a placeholder?
self.iters = iters | ||
self.kwargs = kwargs | ||
self.coupled = isinstance(injectsolve.expr.rhs.fielddata, MultipleFieldData) | ||
self.args = { |
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.
Nitpick: whitespace above this line would improve readability
# the C code cleaner and more modular. This is also a step toward leveraging | ||
# Devito's `reuse_efuncs` functionality, allowing reuse of efuncs when | ||
# they are semantically identical. | ||
objs = frozendict({ |
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.
Could be worth naming this petsc_objs
to avoid potential namespace clashes?
self._main_matvec_callback = None | ||
self._main_formfunc_callback = None | ||
self._user_struct_callback = None | ||
# TODO: Test pickling. The mutability of these lists |
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.
Possibly initialise them to one, then generate tuples for each in a lazy manner?
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.
Possibly remove these, then make the properties into cached properties with the requisite machinery to fill them
…st_log_warning petsc fix pytest log warning
Work in progress PETSc functionality
TODO before merging: