# Memory allocation problem in MPI computation using PETSc

**URL:** <https://community.freefem.org/t/memory-allocation-problem-in-mpi-computation-using-petsc/2071>\
**Category:** General Discussion\
**Created:** [October 18, 2022, 11:27am UTC](https://community.freefem.org/t/memory-allocation-problem-in-mpi-computation-using-petsc/2071 "2022-10-18T11:27:55Z")\
**Posts on this page:** 4\
**Page:** 3

<div class="post-metadata">

**Author:** ![marcodeba](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@marcodeba](https://community.freefem.org/u/marcodeba)\
**Post date:** [October 23, 2022, 9:44am UTC](https://community.freefem.org/t/memory-allocation-problem-in-mpi-computation-using-petsc/2071/41 "2022-10-23T09:44:36Z")

</div>

Unfortunately I do not have any alternative rather than using large meshes for the solution of such a problem…

The good news is that using parmetis as a partitioner allows the execution to overcome the partitioning step and it arrives to the solution of the algebraic system. I’ll let you know if the problem is also actually solved!

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [October 23, 2022, 11:05am UTC](https://community.freefem.org/t/memory-allocation-problem-in-mpi-computation-using-petsc/2071/42 "2022-10-23T11:05:40Z")

</div>

> The good news is that using parmetis as a partitioner allows the execution to overcome the partitioning step

I should have known better, in your first post, the error `***Failed to allocate memory for adjncy. ` comes from METIS. You could simply switch back to your initial code (and still use `-Dpartitioner=parmetis`), that should also make the problem go away.

---

<div class="post-metadata">

**Author:** ![marcodeba](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@marcodeba](https://community.freefem.org/u/marcodeba)\
**Post date:** [October 25, 2022, 6:40am UTC](https://community.freefem.org/t/memory-allocation-problem-in-mpi-computation-using-petsc/2071/43 "2022-10-25T06:40:18Z")

</div>

Sorry @prj for the dealy of my answer, but I was waiting that my simulation begun on the cluster on which I’m working.

You are right, using parmetis also in the original script the metis error does not appear. By the way once the script reaches the “solve problem line → `sol[] = AA * bb^1`” a PETSc error appear, as reported below:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/7/79a8f8111c4fd058cf887bd3fe026084451ac873.png)

Do you think that changing the `pc_type` , maybe to hypre, may help to solve this issue? Is it straight forward to pass from -pc\_type lu to -pc\_type hypre? I’m seeing that in this line [FreeFem-sources/maxwell-3d-PETSc.edp at master · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/master/examples/hpddm/maxwell-3d-PETSc.edp#:~:text=set(A%2C%20sparams%20%3D%20%22%2Dpc_type%20hypre%20%2Dpc_hypre_type%20ams%20%2Dksp_monitor%20%2Dksp_view%20%2Dksp_max_it%2040%22%2C%20coordinates%20%3D%20coordPETSc%2C%20gradient%20%3D%20G)%3B) additional parameters are passed, for instance coordinates and gradient. What are they?

Is there someway a summary of all the possible choices -pc\_type and -pc\_factor\_mat\_solver\_type that can be used in freefem?

Thanks again for your support!

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [October 25, 2022, 8:35am UTC](https://community.freefem.org/t/memory-allocation-problem-in-mpi-computation-using-petsc/2071/44 "2022-10-25T08:35:53Z")

</div>

Maybe changing the PC will fix things, cannot say for sure. The additional parameters are for using AMS: [AMS — hypre 2.26.0 documentation](https://hypre.readthedocs.io/en/latest/solvers-ams.html). The list of PETSc preconditioners are available at [KSP: Linear System Solvers — PETSc 3.18.0 documentation](https://petsc.org/release/docs/manual/ksp/).

[Previous page](https://community.freefem.org/t/memory-allocation-problem-in-mpi-computation-using-petsc/2071.md?page=2)
