Add Cython bindings for the PETSc API #30
Draft
+186
−1
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.
The ultimate aim is to move this file out of Firedrake and make it more widely available.
Why is this useful?
It can be useful to be able to access the C API of PETSc directly (instead of going through petsc4py) in cases where we need to call a function many many times (e.g. inside a loop that is the size of the mesh). I wrote a little demo that shows this:
vs
The former takes 4.0s and the latter takes 1.8s and 0.78s each. The differences are admittedly much smaller than expected but still significant enough to care about.
But petsc4py have Cython headers too, why aren't those sufficient?
Basically 2 reasons:
Matis called aPetscMatso all of the C API signatures look a bit odd. Here everything matches exactly, and a petsc4py Python Mat is calledMat_py.