Skip to content

Conversation

@ZoeLeibowitz
Copy link
Contributor

@ZoeLeibowitz ZoeLeibowitz commented Sep 2, 2025

The bulk of this PR is a cleanup: petsc/iet/routines.py had become too large, so it has been split into four files:

1. callback_builder.py
2. setup.py
3. solver.py
4. time_dependence.py

New code:

  • lower_petsc_symbols called inside passes/iet/languages/C.py: This was introduced because, in some cases, new symbols (e.g. x_size, y_size) are injected by the place_definitions and place_casts passes. In PETSc callback functions, such symbols can only be accessed through a struct (via DMGetApplicationContext). This struct is generated inside the lower_petsc pass.
    lower_petsc_symbols ensures that this struct is rebuilt (and any affected IET is updated) to include the new symbols.

  • Two new iet passes inside petsc/iet/passes.py which are called inside lower_petsc_symbols.

@ZoeLeibowitz ZoeLeibowitz changed the title compiler: Reorganise PETSc files and add a PetscCDataManager compiler: Reorganise PETSc files and add lower_petsc_symbols Sep 3, 2025
@JDBetteridge
Copy link
Contributor

Why is this being merged into the solver parameters branch, rather than the PETSc one? Or are you going to rebase once the solver params branch is merged?

from devito.passes.iet.langbase import LangBB
from devito.symbolics import c_complex, c_double_complex
from devito.tools import dtype_to_cstr

Copy link
Contributor

Choose a reason for hiding this comment

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

Does devito.petsc get its own line? I thought the "notional" "Devito style" grouped Devito imports.

(I will reiterate my desire to automate this nonsense!)

Copy link
Contributor

Choose a reason for hiding this comment

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

Pick a different filename (setup.py should only be used for installation)

from devito.petsc.iet.utils import petsc_call


class NonTimeDependent:
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a great name

return []


class TimeDependent(NonTimeDependent):
Copy link
Contributor

Choose a reason for hiding this comment

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

See above comment! A NonTimeDependent is a type of Something. The convention should be:

  • Replace NonTimeDependent with Something
  • This class should be a TimeSomething

Copy link
Contributor

Choose a reason for hiding this comment

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

Please find a proper home for all of these functions (and then one day hopefully someone can delete this file)

Comment on lines +216 to +217
class MainUserStruct(PETScStruct):
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this exist?

Copy link
Contributor

Choose a reason for hiding this comment

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

Find a proper home for these functions while you are refactoring and delete this file.

@ZoeLeibowitz ZoeLeibowitz mentioned this pull request Sep 19, 2025
@ZoeLeibowitz ZoeLeibowitz deleted the petsc_reorganise_files branch September 22, 2025 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants