-
Notifications
You must be signed in to change notification settings - Fork 246
dsl/compiler: Fix&tidy PETSc mixed solver functionality #2626
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
Merged
Merged
Changes from all commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
92edf68
dsl/compiler: Edits to mixed solver functionality
ZoeLeibowitz f6b38ed
compiler: Working petscbundle
ZoeLeibowitz 7300c8f
compiler: Add PetscMixin to simplify priority destroys
ZoeLeibowitz 1ddc053
compiler: Working reuse_efunc for petscbundles
ZoeLeibowitz 6834611
dsl/compiler: Zero columns for essential bcs
ZoeLeibowitz 9642278
dsl: Compatible scaling of jacobian
ZoeLeibowitz ce9150f
dsl: Scale boundary rows of jacobian
ZoeLeibowitz f7e00bb
types: Edit PetscMixin and use it in other petsc classes
ZoeLeibowitz 6e20d4b
dsl: Add extraction file
ZoeLeibowitz 8a79fcd
dsl: Move symbolic extraction functions outside of the PETSc module
ZoeLeibowitz 3000bd8
types: Move EssentialBC to another file
ZoeLeibowitz a0457f0
dsl/compiler: Add equation.py to petsc module
ZoeLeibowitz 7132eb1
dsl: Add jacobian class for single fields
ZoeLeibowitz 6897ab8
dsl: Fix compatible scaling for single fields
ZoeLeibowitz 8386992
dsl: Improve Jacobian abstraction
ZoeLeibowitz fb20781
examples: Add pressure norm check in stokes example
ZoeLeibowitz 5c1b686
tests: Add more petsc tests for linear coupled
ZoeLeibowitz b0ca11f
misc: Merge petsc branch in but broken petscbundle
ZoeLeibowitz b6710be
types: Fix PetscBundle symbolic shape
ZoeLeibowitz 01d153a
tests: Fix petsc tests
ZoeLeibowitz d6bd4f4
misc: Address comments
ZoeLeibowitz 4fad6aa
misc: Merge leftover
ZoeLeibowitz 525fdf6
Merge branch 'petsc' into biharmonic
ZoeLeibowitz 27dd201
compiler: Edit switch_log_level
ZoeLeibowitz 30ed5ba
tests: Add mpi petsc test
ZoeLeibowitz 51d4d7e
misc: Address more comments and add docstrings
ZoeLeibowitz a4a5660
misc: Clean up more docstrings
ZoeLeibowitz 312c826
misc: Add BaseJacobian
ZoeLeibowitz 048f693
misc: Docstrings, stop list output for PETScSolve, tests
ZoeLeibowitz 905def2
misc: Flake8
ZoeLeibowitz 19fddbe
misc: Fix exprs in 01_navierstokes.py due to change in PETScSolve out…
ZoeLeibowitz 6972cbc
Merge branch 'biharmonic' into petsc_mpi
ZoeLeibowitz 8037cf9
misc: Clean up
ZoeLeibowitz 8c16f2e
misc: Utilise zero_vector function
ZoeLeibowitz dcbf929
Merge branch 'biharmonic' into petsc_mpi
ZoeLeibowitz f3d4d2d
misc: Move vecset to function inside iet/utils.py
ZoeLeibowitz 8d10b87
misc: Flake8
ZoeLeibowitz 53b58a9
misc: Clean up
ZoeLeibowitz 857eb9c
misc: Add more tests
ZoeLeibowitz 7a5b10f
mpi: Start parallel tests
ZoeLeibowitz 467c19b
add to petsc laplacian test
ZoeLeibowitz 343ba75
merge conflict
ZoeLeibowitz d2e3eb5
mpi tests
ZoeLeibowitz 6165373
edit test
ZoeLeibowitz 0b43ea6
tests: Add petsc parallel test
ZoeLeibowitz 62d0045
clean up
ZoeLeibowitz bd96379
misc: Simplify comm extraction in lower_petsc
ZoeLeibowitz ce5cf82
clean up
ZoeLeibowitz b7c4082
trigger petsc CI
ZoeLeibowitz e485c9c
misc: Add todo:
ZoeLeibowitz df4e638
address some of ed's comments
ZoeLeibowitz 72e8222
misc: Address comments
ZoeLeibowitz b72465f
Merge pull request #2635 from devitocodes/petsc_mpi
ZoeLeibowitz 16be19a
dsl/compiler: Add PETSc logging instrastructure and tests
ZoeLeibowitz f790ab9
Merge pull request #2655 from devitocodes/petsc_performance_summary
ZoeLeibowitz e3e26f0
compiler: Fix language summary
ZoeLeibowitz 9a182da
misc: Fix advisor profiling with new language arg
ZoeLeibowitz 774af10
misc: Clean up and docstrings
ZoeLeibowitz 910c987
misc: Clean up
ZoeLeibowitz ff4b2d7
misc: flake8
ZoeLeibowitz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| from devito.petsc.solve import * # noqa | ||
| from devito.petsc.types.equation import * # noqa |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| from functools import cached_property | ||
|
|
||
| from devito.symbolics import Byref, FieldFromPointer | ||
| from devito.ir.iet import DummyExpr | ||
| from devito.logger import PERF | ||
|
|
||
| from devito.petsc.iet.utils import petsc_call | ||
| from devito.petsc.logging import petsc_return_variable_dict, PetscInfo | ||
|
|
||
|
|
||
| class PetscLogger: | ||
| """ | ||
| Class for PETSc loggers that collect solver related statistics. | ||
| """ | ||
| def __init__(self, level, **kwargs): | ||
| self.sobjs = kwargs.get('solver_objs') | ||
| self.sreg = kwargs.get('sregistry') | ||
| self.section_mapper = kwargs.get('section_mapper', {}) | ||
| self.inject_solve = kwargs.get('inject_solve', None) | ||
|
|
||
| self.function_list = [] | ||
|
|
||
| if level <= PERF: | ||
| self.function_list.extend([ | ||
| 'kspgetiterationnumber', | ||
| 'snesgetiterationnumber' | ||
| ]) | ||
|
|
||
| # TODO: To be extended with if level <= DEBUG: ... | ||
|
|
||
| name = self.sreg.make_name(prefix='petscinfo') | ||
| pname = self.sreg.make_name(prefix='petscprofiler') | ||
|
|
||
| self.statstruct = PetscInfo( | ||
| name, pname, self.logobjs, self.sobjs, | ||
| self.section_mapper, self.inject_solve, | ||
| self.function_list | ||
| ) | ||
|
|
||
| @cached_property | ||
| def logobjs(self): | ||
| """ | ||
| Create PETSc objects specifically needed for logging solver statistics. | ||
| """ | ||
| return { | ||
| info.name: info.variable_type( | ||
| self.sreg.make_name(prefix=info.output_param) | ||
| ) | ||
| for func_name in self.function_list | ||
| for info in [petsc_return_variable_dict[func_name]] | ||
| } | ||
|
|
||
| @cached_property | ||
| def calls(self): | ||
| """ | ||
| Generate the PETSc calls that will be injected into the C code to | ||
| extract solver statistics. | ||
| """ | ||
| struct = self.statstruct | ||
| calls = [] | ||
| for param in self.function_list: | ||
| param = petsc_return_variable_dict[param] | ||
|
|
||
| inputs = [] | ||
| for i in param.input_params: | ||
| inputs.append(self.sobjs[i]) | ||
|
|
||
| logobj = self.logobjs[param.name] | ||
|
|
||
| calls.append( | ||
| petsc_call(param.name, inputs + [Byref(logobj)]) | ||
| ) | ||
| # TODO: Perform a PetscCIntCast here? | ||
| expr = DummyExpr(FieldFromPointer(logobj._C_symbol, struct), logobj._C_symbol) | ||
| calls.append(expr) | ||
|
|
||
| return tuple(calls) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why did you add Differentiable here? Is it possible to add a test to
test_ietcovering this specific case (or at least for me to understand)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.
@FabioLuporini The problem arises from my new class
PetscBundle(Bundle), whose components arePETScArrays. In theabstract_objectsfunction, the mapper must be updated for the components before thePetscBundleitself.PETScArrayinherits fromArrayBasicandDifferentiable. However, I can't useArrayBasicbecauseBundlealso inherits from it. So I choseDifferentiableas the distinguishing type (to avoid usingPETScArray)