# PETSC.jl MPI wrapper

**URL:** <https://discourse.julialang.org/t/petsc-jl-mpi-wrapper/77900>\
**Category:** General Usage\
**Tags:** hpc, parallel, mpi\
**Created:** [March 15, 2022, 12:18am UTC](https://discourse.julialang.org/t/petsc-jl-mpi-wrapper/77900 "2022-03-15T00:18:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srikumar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/srikumar/32/34565_2.png) [@Srikumar](https://discourse.julialang.org/u/Srikumar)\
**Post date:** [March 15, 2022, 12:18am UTC](https://discourse.julialang.org/t/petsc-jl-mpi-wrapper/77900/1 "2022-03-15T00:18:21Z")

</div>

Hello,  
I would love to know if someone has used PETSC wrapper in Julia for MPI? I am planning to develop a parallel code using the PETSC wrapper and would like to know how extensive the PETSC functionality is in Julia. Can one expect to find all PETSC commands (just like in C,C++,Fortran)? Also how good is the documentation?

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [March 15, 2022, 8:11am UTC](https://discourse.julialang.org/t/petsc-jl-mpi-wrapper/77900/2 "2022-03-15T08:11:08Z")

</div>

Not a user of it but check out [https://github.com/JuliaParallel/PETSc.jl](https://github.com/JuliaParallel/PETSc.jl).

---

<div class="post-metadata">

**Author:** ![boriskaus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/boriskaus/32/34591_2.png) [@boriskaus](https://discourse.julialang.org/u/boriskaus)\
**Post date:** [March 16, 2022, 6:58am UTC](https://discourse.julialang.org/t/petsc-jl-mpi-wrapper/77900/3 "2022-03-16T06:58:40Z")

</div>

In PETSc.jl, @jkozdon started to automatically wrap the full PETSc package, which is available in this [branch](https://github.com/JuliaParallel/PETSc.jl/tree/jek/gen) and employs the precompiled PETSc\_jll binaries (which also works in parallel).  
To make this more julia-like, we started adding some functionality for DMDA and partly for DMSTAG but ran out of time a while ago. We are hoping to finish this work over the coming weeks, and push this branch back to main.  
Documentation is very limited, but as it mostly follows the actual PETSc routines, it shouldn’t be too difficult to use (have a look at the examples or the quite extensive tests).

---

<div class="post-metadata">

**Author:** ![viralbshah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/viralbshah/32/54_2.png) [@viralbshah](https://discourse.julialang.org/u/viralbshah)\
**Post date:** [October 30, 2024, 4:51pm UTC](https://discourse.julialang.org/t/petsc-jl-mpi-wrapper/77900/4 "2024-10-30T16:51:57Z")

</div>

Just an update after a long time. The PETSc.jl repo is now updated to work on the latest Julia release (1.11) - by @boriskaus and me.

A major next project would be to do what @boriskaus outlined above. Much of the work already exists in a PR on the repo, that will need to be revived.

---

<div class="post-metadata">

**Author:** ![priyanshuFSI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/priyanshufsi/32/221835_2.png) [@priyanshuFSI](https://discourse.julialang.org/u/priyanshuFSI)\
**Post date:** [May 23, 2025, 3:47pm UTC](https://discourse.julialang.org/t/petsc-jl-mpi-wrapper/77900/5 "2025-05-23T15:47:40Z")

</div>

Hi, did you develop it ?  
I was also curious about how extensive the PETSc wrapper is in Julia.

---

<div class="post-metadata">

**Author:** ![pitipatw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pitipatw/32/211438_2.png) [@pitipatw](https://discourse.julialang.org/u/pitipatw)\
**Post date:** [May 24, 2025, 12:47pm UTC](https://discourse.julialang.org/t/petsc-jl-mpi-wrapper/77900/6 "2025-05-24T12:47:03Z")

</div>

I am also looking into using PETSC as well.  
I glad to see some updates on PETSC.jl !

---

<div class="post-metadata">

**Author:** ![viralbshah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/viralbshah/32/54_2.png) [@viralbshah](https://discourse.julialang.org/u/viralbshah)\
**Post date:** [June 3, 2025, 4:43pm UTC](https://discourse.julialang.org/t/petsc-jl-mpi-wrapper/77900/7 "2025-06-03T16:43:05Z")

</div>

I think @boriskaus may be the right person to chime in about how extensive the wrappers are. My main contribution was to have it update to Julia 1.11, and hopefully that will also make it easy to run in 1.12 as well.

---

<div class="post-metadata">

**Author:** ![boriskaus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/boriskaus/32/34591_2.png) [@boriskaus](https://discourse.julialang.org/u/boriskaus)\
**Post date:** [June 6, 2025, 5:56am UTC](https://discourse.julialang.org/t/petsc-jl-mpi-wrapper/77900/8 "2025-06-06T05:56:48Z")

</div>

Indeed, there has been a long-standing attempt to try and wrap the whole PETSc library to Julia. As the original `dmstag` branch became too large, I revived this last year, and much of it is available in this branch:

> **[GitHub - JuliaParallel/PETSc.jl at bk/wrapping\_tests](https://github.com/JuliaParallel/PETSc.jl/tree/bk/wrapping_tests)**
>
> Julia wrappers for the PETSc library. Contribute to JuliaParallel/PETSc.jl development by creating an account on GitHub.

This includes automatically wrapping of nearly the full PETSc library using Clang, which results in a file `lib/petsc_library.jl` that is over 77k lines long. In principle, you can thus call nearly every PETSc function from julia already.  
The issue is that much of this is not very julia-like and therefore of limited practical use.

Therefore, I also wrote some helper functions to automatically create nicer formatted julia functions (`gem/wrap_functions`), while also adding [tests](https://github.com/JuliaParallel/PETSc.jl/blob/bk/wrapping_tests/test/runtests.jl) for it (which shows what is currently working).

My issue is a lack of time. I seem to have a few days every 6 months or so to spend on this, and at this rate it’ll take very long to finish.

If there are people that would like to see more functionality added to PETSc.jl (@pitipatw, @priyanshuFSI), you are very welcome to help with this effort.

Note that making nicer julia wrappers around the PETSc functions only has to be done once, after which we only need to push minor modifications to routines that change in future PETSc versions.

---

<div class="post-metadata">

**Author:** ![pitipatw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pitipatw/32/211438_2.png) [@pitipatw](https://discourse.julialang.org/u/pitipatw)\
**Post date:** [June 7, 2025, 3:23am UTC](https://discourse.julialang.org/t/petsc-jl-mpi-wrapper/77900/9 "2025-06-07T03:23:08Z")

</div>

Thank you @boriskaus for the clarification.

I do want to contribute, however, I’m a beginner Julia user + very new to PETSc.

If you could kindly guide how I could help, I’m willing to do so and spend time on it this summer.
