# ParallelStencil w/MPI

**URL:** <https://discourse.julialang.org/t/parallelstencil-w-mpi/79077>\
**Category:** Julia at Scale\
**Tags:** mpi\
**Created:** [April 6, 2022, 12:42am UTC](https://discourse.julialang.org/t/parallelstencil-w-mpi/79077 "2022-04-06T00:42:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wkharold](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wkharold/32/17231_2.png) [@wkharold](https://discourse.julialang.org/u/wkharold)\
**Post date:** [April 6, 2022, 12:42am UTC](https://discourse.julialang.org/t/parallelstencil-w-mpi/79077/1 "2022-04-06T00:42:30Z")

</div>

Is the CPU parallelism in the ParallelStencil.jl [Concise single/multi-XPU miniapps](https://github.com/omlins/ParallelStencil.jl#concise-singlemulti-xpu-miniapps) limited to threads, or since it’s built on/with ImplicitGlobalGrid can it do MPI as well? I don’t see anything that looks like MPI support but I’m not an expert. If the code currently only does threads how difficult would adding MPI be?

---

<div class="post-metadata">

**Author:** ![smillerc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/smillerc/32/35457_2.png) [@smillerc](https://discourse.julialang.org/u/smillerc)\
**Post date:** [April 6, 2022, 12:51am UTC](https://discourse.julialang.org/t/parallelstencil-w-mpi/79077/2 "2022-04-06T00:51:34Z")

</div>

ImplicitGlobalGrid uses MPI for domain-decomposition with halo exchange. The global domain is split up behind the scenes with the `init_global_grid()` call. If you dig around in the ImplicitGlobalGrid source code you’ll see where they call MPI.

---

<div class="post-metadata">

**Author:** ![samo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samo/32/35398_2.png) [@samo](https://discourse.julialang.org/u/samo)\
**Post date:** [April 6, 2022, 9:41am UTC](https://discourse.julialang.org/t/parallelstencil-w-mpi/79077/3 "2022-04-06T09:41:47Z")

</div>

If you use ParallelStencil in combination with ImplicitGlobalGrid, then you will be able launch your application on multiple processes (CPU/GPU) - ImplicitGlobalGrid relies on MPI for inter-process communication. In the github readme we have written an overview of ImplicitGlobalGrid, which should answer all your initial questions:

> **[GitHub - eth-cscs/ImplicitGlobalGrid.jl: Almost trivial distributed...](https://github.com/eth-cscs/ImplicitGlobalGrid.jl)**
>
> Almost trivial distributed parallelization of stencil-based GPU and CPU applications on a regular staggered grid - GitHub - eth-cscs/ImplicitGlobalGrid.jl: Almost trivial distributed parallelizatio...

Function documentation is callable from the REPL:

> **[GitHub - eth-cscs/ImplicitGlobalGrid.jl: Almost trivial distributed...](https://github.com/eth-cscs/ImplicitGlobalGrid.jl#module-documentation-callable-from-the-julia-repl--ijulia)**
>
> Almost trivial distributed parallelization of stencil-based GPU and CPU applications on a regular staggered grid - GitHub - eth-cscs/ImplicitGlobalGrid.jl: Almost trivial distributed parallelizatio...

Furthermore, my talk at JuliaCon 2020 gives an introduction to ParallelStencil and ImplicitGlobalGrid:

[![](https://global.discourse-cdn.com/julialang/original/3X/b/1/b1352b664af5f4a7ee1848913dc892e447a63187.jpeg "JuliaCon 2020 | Solving Nonlinear Multi-Physics on GPU Supercomputers with Julia | Samuel Omlin") ](https://www.youtube.com/watch?v=vPsfZUqI4_0)

Finally, our last year’s workshop on “Solving differential equations in parallel on GPUs | Workshop | 2021” also discusses the usage of ParallelStencil with ImplicitGlobalGrid (I think towards the end):

[![](https://global.discourse-cdn.com/julialang/original/3X/c/9/c911a3583436fb09b638f34cb68ee44d6209cb9b.jpeg "Solving differential equations in parallel on GPUs | Workshop | 2021") ](https://www.youtube.com/watch?v=DvlM0w6lYEY)

Do not hesitate to ask if something remains unclear…
