Skip to content

Conversation

@ZoeLeibowitz
Copy link
Contributor

@ZoeLeibowitz ZoeLeibowitz commented Aug 14, 2025

  • Extend the solver_parameters dictionary in PETScSolve.
  • Add two new callbacks to the generated code - one to set options and one to clear them from the global PETSc options database.
  • Ensure that command line args take precedence over both default options and options specified in the solver_parameters dict.
  • Add get_info argument to PETScSolve to collect specific statistics from the solver.
  • Add lots of new tests, including tests for command line parsing.

@ZoeLeibowitz ZoeLeibowitz added compiler API api (symbolics, types, ...) feature-request labels Aug 14, 2025
@ZoeLeibowitz ZoeLeibowitz changed the title dsl/compiler: Extend PETSc solver parameters and logging dsl/compiler: Extend solver_parameters handling in PETScSolve and update logging Aug 14, 2025
'ksp_type': 'gmres',
'pc_type': 'none',
'ksp_rtol': 1.e-5,
'ksp_atol': 1.e-50,
Copy link
Contributor

Choose a reason for hiding this comment

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

That's an interesting "numerical" number

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is the default one used in PETSc

@codecov
Copy link

codecov bot commented Aug 18, 2025

Codecov Report

❌ Patch coverage is 25.00000% with 417 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.46%. Comparing base (4139a3f) to head (8c2f56c).
⚠️ Report is 1 commits behind head on petsc.

Files with missing lines Patch % Lines
tests/test_petsc.py 20.00% 252 Missing ⚠️
devito/petsc/iet/routines.py 12.12% 58 Missing ⚠️
devito/petsc/logging.py 34.14% 27 Missing ⚠️
devito/petsc/iet/logging.py 9.52% 19 Missing ⚠️
devito/petsc/types/types.py 46.15% 14 Missing ⚠️
devito/petsc/iet/passes.py 25.00% 12 Missing ⚠️
devito/petsc/utils.py 50.00% 10 Missing ⚠️
devito/petsc/solver_parameters.py 43.75% 9 Missing ⚠️
devito/petsc/solve.py 46.15% 7 Missing ⚠️
devito/petsc/initialize.py 14.28% 6 Missing ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##            petsc    #2718      +/-   ##
==========================================
- Coverage   84.89%   84.46%   -0.44%     
==========================================
  Files         268      269       +1     
  Lines       52464    52832     +368     
  Branches     4457     4472      +15     
==========================================
+ Hits        44540    44622      +82     
- Misses       7155     7440     +285     
- Partials      769      770       +1     

☔ 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.

@ZoeLeibowitz ZoeLeibowitz marked this pull request as ready for review August 22, 2025 09:12
Example:
--------
>>> self.function_list
Copy link
Contributor

Choose a reason for hiding this comment

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

Should self.function_list be allowed to be mutable? Ditto with self.petsc_option_mapper

Copy link
Contributor

@JDBetteridge JDBetteridge left a comment

Choose a reason for hiding this comment

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

Not all comments need addressing before merge



petsc_variables = get_petsc_variables()
# TODO: Use petsctools get_petscvariables() instead?
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO

def get_petsc_type_mappings():
try:
petsc_precision = petsc_variables['PETSC_PRECISION']
except KeyError:
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be a hard error if the precision cannot be determined?

Copy link
Contributor Author

@ZoeLeibowitz ZoeLeibowitz Sep 15, 2025

Choose a reason for hiding this comment

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

This is called inside devito/passes/iet/languages/C.py so it;s not a hard error otherwise CI will break. However it's also called inside PETScSolve, so maybe this should be extended

Comment on lines 89 to -92
if petsc_precision == 'single':
mapper[ctypes.c_float] = petsc_scalar
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a lot of this shouldn't be indented, but I can't tell because github has messed up the formatting.

@ZoeLeibowitz ZoeLeibowitz merged commit 7c69c4d into petsc Sep 19, 2025
32 checks passed
@ZoeLeibowitz ZoeLeibowitz deleted the solver_params branch September 22, 2025 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants