Conversation
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
add get_petsc_arrays/restore_petsc_arrays along with multiple dispatch for GPU Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
vchuravy
reviewed
Apr 28, 2026
vchuravy
reviewed
Apr 28, 2026
Co-authored-by: Valentin Churavy <v.churavy@gmail.com>
vchuravy
reviewed
Apr 28, 2026
vchuravy
reviewed
Apr 28, 2026
vchuravy
reviewed
Apr 28, 2026
Co-authored-by: Copilot <copilot@github.com>
vchuravy
reviewed
Apr 28, 2026
vchuravy
reviewed
Apr 28, 2026
vchuravy
reviewed
Apr 28, 2026
Member
vchuravy
left a comment
There was a problem hiding this comment.
There should also be tests for withlocalarray(Array, ...) and co
vchuravy
reviewed
Apr 28, 2026
…ry/finally cleanup
- determine_memtype now collects raw PetscMemType enum values and uses
Val{MT} dispatch (_array_type) instead of backend singleton types,
as requested by Valentin's review.
- Add _as_petsc_vec helper that converts any AbstractPetscVec to PetscVec
(non-owning, wraps .ptr), fixing MethodError when VecPtr is passed to
auto-generated *AndMemType ccall wrappers typed ::PetscVec.
Applied in vec.jl and PETScCUDAExt.jl at every *AndMemType call site.
- withlocalarray! uses try/finally (no Base.finalize) to avoid double-
execution of VecRestore* when Julia 1.12 concurrent GC races with
explicit finalize calls.
do-block compatibility.
vchuravy
reviewed
Apr 28, 2026
vchuravy
reviewed
Apr 28, 2026
vchuravy
reviewed
Apr 28, 2026
vchuravy
reviewed
Apr 28, 2026
vchuravy
reviewed
Apr 28, 2026
vchuravy
reviewed
Apr 28, 2026
vchuravy
reviewed
Apr 28, 2026
vchuravy
reviewed
Apr 28, 2026
vchuravy
reviewed
Apr 28, 2026
vchuravy
reviewed
Apr 28, 2026
vchuravy
reviewed
Apr 28, 2026
Co-authored-by: Valentin Churavy <v.churavy@gmail.com>
Co-authored-by: Valentin Churavy <v.churavy@gmail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PETSc has GPU support since a few years, which allows putting matrices and vectors to the GPU using command-line options (provided that PETSc is configured with CUDA support). Yet, to get the best performance, also the residual kernels will have to be rewritten for GPU, which requires writing native CUDA code (for NVIDIA systems), or use Kokkos ("dependency hell" as someone told me).
Julia, on the other hand, is well-known for its excellent GPU support, for example, through packages such as KernelAbstractions, which allows compiling the same vcode for NVIDIA, AMD, or Mac hardware in a straightforward manner.
Here, the PETSc
ex19example (typically used to test PETSc installations) was translated from C to Julia and combined withKernelAbstractionssuch that residual routines also run on the GPU. It uses coloring and finite differences to approximate the Jacobian and works with multigrid preconditioners.The documentation has been updated to show scalability tests on GPU vs. CPU (on 1 or 32 cores).
As a quick summary, it works and already shows great potential but can perhaps be further improved:
KSPSolve:
SNESSolve:
Disclaimer: Claude Sonnet 4.6 was used in preparing this; Valentin helped steer it back in place...