Skip to content

Add PETSc logging infrastructure #2655

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 1 commit into from
Jul 14, 2025
Merged

Conversation

ZoeLeibowitz
Copy link
Contributor

Add PETSc logging infrastructure. The data available to users via the PetscSummary will be extended in future PRs.

@ZoeLeibowitz ZoeLeibowitz added compiler API api (symbolics, types, ...) feature-request labels Jul 2, 2025
@ZoeLeibowitz ZoeLeibowitz marked this pull request as draft July 2, 2025 13:31
@ZoeLeibowitz ZoeLeibowitz marked this pull request as ready for review July 2, 2025 13:52
@@ -391,6 +391,9 @@ def _print_SizeOf(self, expr):
def _print_MathFunction(self, expr):
return f"{self._ns}{self._print_DefFunction(expr)}"

def _print_String(self, expr):
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm surprised this is needed?

and if it is, can you rather do it like at lines 400, 401 etc ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the String.__str__ instead, in a similar way to how Class and MacroArgument are handled

@@ -1101,6 +1109,12 @@ def lower_perfentry(v):

return summary

def _emit_language_info(self):
if self._language == 'petsc':
return petsc_summary(self.parameters)
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 you want the runtime arguments here (namely args, that the caller should have passed), not the static ones (self.parameters)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need access to the static self.parameters to construct the PetscSummary. I'm retrieving PetscInfo objects, which are similar to the Timer object in that callers don't explicitly pass them

return perf_summary

# Combine the performance and language specific summaries
return CombinedSummary(perf=perf_summary, lang=lang_summary)
Copy link
Contributor

Choose a reason for hiding this comment

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

why, instead of CombinedSummary, not just appending the information to perf_summary itself (it is a mutable data structure anyway)

I mean somewhere around here: https://github.com/devitocodes/devito/blob/main/devito/operator/profiling.py#L480

Copy link
Contributor

Choose a reason for hiding this comment

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

also note that the profiler object is (optionally) available inside the IET compiler passes, so perhaps you could anticipate something in there to eventually make the handling of the PETSc profiling part more homogeneous wrt what happens in devito for "normal" (as in, non-PETSc) Operators.

Anyway, feel free to ignore this, not a priority

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've removed CombinedSummary and instead dynamically added PetscSummary as a property to PerformanceSummary. If users specify language='petsc', they can access the language specific summary via perf_summary.petsc. What do you think? It also makes it easy to extend support for other summary types in the future?

Copy link
Contributor

Choose a reason for hiding this comment

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

I though we previously discussed not just including these in the Performance summary, since they aren't performance statistics.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think PerformanceSummary could just be renamed as Summary?

Copy link
Contributor

@EdCaunt EdCaunt left a comment

Choose a reason for hiding this comment

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

Looks great! A handful of tiny comments, but nothing important

Copy link
Contributor

@mloubout mloubout left a comment

Choose a reason for hiding this comment

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

looks good

@ZoeLeibowitz ZoeLeibowitz force-pushed the petsc_performance_summary branch from 401c4e6 to 16be19a Compare July 14, 2025 15:26
@ZoeLeibowitz ZoeLeibowitz merged commit f790ab9 into biharmonic Jul 14, 2025
1 check passed
@ZoeLeibowitz ZoeLeibowitz deleted the petsc_performance_summary branch July 14, 2025 19:27
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.

5 participants