# Parallel computation

**URL:** <https://festim.discourse.group/t/parallel-computation/33>\
**Category:** User Support\
**Created:** [April 1, 2024, 8:12pm UTC](https://festim.discourse.group/t/parallel-computation/33 "2024-04-01T20:12:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![VVKulagin](https://yyz2.discourse-cdn.com/free1/user_avatar/festim.discourse.group/vvkulagin/32/51_2.png) [@VVKulagin](https://festim.discourse.group/u/VVKulagin)\
**Post date:** [April 1, 2024, 8:12pm UTC](https://festim.discourse.group/t/parallel-computation/33/1 "2024-04-01T20:12:58Z")

</div>

Hi, all!

How to properly run a FESTIM simulation in parallel?

---

<div class="post-metadata">

**Author:** ![remidm](https://yyz2.discourse-cdn.com/free1/user_avatar/festim.discourse.group/remidm/32/4_2.png) [@remidm](https://festim.discourse.group/u/remidm)\
**Post date:** [April 1, 2024, 8:13pm UTC](https://festim.discourse.group/t/parallel-computation/33/2 "2024-04-01T20:13:28Z")

</div>

@jhdark you may want to provide assistance on this since you’re used to run heavy calculations on clusters

---

<div class="post-metadata">

**Author:** ![jhdark](https://yyz2.discourse-cdn.com/free1/user_avatar/festim.discourse.group/jhdark/32/13_2.png) [@jhdark](https://festim.discourse.group/u/jhdark)\
**Post date:** [April 2, 2024, 8:34pm UTC](https://festim.discourse.group/t/parallel-computation/33/3 "2024-04-02T20:34:58Z")

</div>

Hey @VVKulagin

You can run festim simulations in parallel using the command

`mpirun -np x python3 my_script.py`

Where x corresponds to the number of logical processors you want to use. I would advise not using all the logical processors available to your PC though as you will need them for other functionality. Is this what you are after?

---

<div class="post-metadata">

**Author:** ![VVKulagin](https://yyz2.discourse-cdn.com/free1/user_avatar/festim.discourse.group/vvkulagin/32/51_2.png) [@VVKulagin](https://festim.discourse.group/u/VVKulagin)\
**Post date:** [April 2, 2024, 8:55pm UTC](https://festim.discourse.group/t/parallel-computation/33/4 "2024-04-02T20:55:53Z")

</div>

> Is this what you are after?

Yeap, thank you for that.

I tried using `mpirun -np x` (x=2…16) with [this](https://github.com/RemDelaporteMathurin/3d_monoblocks) 3D problem (~100k cells), but haven’t noticed any enhancements in the computation performance. I also ran in parallel a 1D problem with a decent amount of mesh elements, but the result is the same.

Could you, please, suggest an example of a FESTIM (or fenics) script which’ll benefit from parallelisation?

---

<div class="post-metadata">

**Author:** ![jhdark](https://yyz2.discourse-cdn.com/free1/user_avatar/festim.discourse.group/jhdark/32/13_2.png) [@jhdark](https://festim.discourse.group/u/jhdark)\
**Post date:** [April 3, 2024, 7:27am UTC](https://festim.discourse.group/t/parallel-computation/33/5 "2024-04-03T07:27:55Z")

</div>

In short, I think parallel simulations only provide benefit in cases where the solving of the PDE is the dominant factor in the solving time, so in cases where massive meshes are used (~500k cells+), one can see more of a benefit. If this is not the case then it may increase simulation time in passing communications between the nodes. Also, not every feature in legacy fenics benefits from parallelisation or has full capability. Furthermore, festim hasn’t been explicitly designed to scale well, so in many cases, there may be a sweet spot in terms of the number of processors to use (which may sometimes be 1).

This being said, I will do some investigations to see specific cases in which it benefits and I will get back to you
