# FreeFem++ petsc ubuntu

**URL:** <https://community.freefem.org/t/freefem-petsc-ubuntu/3289>\
**Category:** General Discussion\
**Created:** [June 5, 2024, 2:44pm UTC](https://community.freefem.org/t/freefem-petsc-ubuntu/3289 "2024-06-05T14:44:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![LXX](https://avatars.discourse-cdn.com/v4/letter/l/258eb7/32.png) [@LXX](https://community.freefem.org/u/LXX)\
**Post date:** [June 5, 2024, 2:44pm UTC](https://community.freefem.org/t/freefem-petsc-ubuntu/3289/1 "2024-06-05T14:44:41Z")

</div>

Hello everyone, I am a FreeFem++ learner. Recently, I encountered the issue of FreeFem++ code running very slowly on my CPU. Therefore, I wanted to try using PETSc to accelerate it (on a Linux system). I followed the tutorial on GitHub, but I failed.

 ![截屏2024-06-04 12.33.05](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/6/66dc720b359093ed293808303c8463cf844979de.png)

Then, I try install the binary package.  
Now I can output the correct results by using command `FreeFem++ -nw file.edp`, but I don’t know how to run `diffusion-2d-PETSc.edp` or `diffusion-2d.edp` like this in `hpddm` file. Please help me!!!

```auto
https://github.com/FreeFem/FreeFem-sources/tree/master/examples

```

---

<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:** [June 5, 2024, 2:56pm UTC](https://community.freefem.org/t/freefem-petsc-ubuntu/3289/2 "2024-06-05T14:56:01Z")

</div>

You _both_ compiled FreeFEM sources and installed the binary package? That’s not ideal. You’ll need to remove one of the installation before going further.

---

<div class="post-metadata">

**Author:** ![LXX](https://avatars.discourse-cdn.com/v4/letter/l/258eb7/32.png) [@LXX](https://community.freefem.org/u/LXX)\
**Post date:** [June 5, 2024, 2:59pm UTC](https://community.freefem.org/t/freefem-petsc-ubuntu/3289/3 "2024-06-05T14:59:52Z")

</div>

I failed in compiling FreeFEM sources, so I installed the binary package. Do I need to remove FreeFEM sources? I don’t know how to do it.

---

<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:** [June 5, 2024, 6:17pm UTC](https://community.freefem.org/t/freefem-petsc-ubuntu/3289/4 "2024-06-05T18:17:04Z")

</div>

You should just remove the folder of the sources.

---

<div class="post-metadata">

**Author:** ![LXX](https://avatars.discourse-cdn.com/v4/letter/l/258eb7/32.png) [@LXX](https://community.freefem.org/u/LXX)\
**Post date:** [June 7, 2024, 5:07am UTC](https://community.freefem.org/t/freefem-petsc-ubuntu/3289/5 "2024-06-07T05:07:30Z")

</div>

Yes, I have removed the corresponding folder. But the question I want to ask is:  
Now I can output the correct results by using command `FreeFem++ -nw file.edp`, but I don’t know how to run `diffusion-2d-PETSc.edp` or `diffusion-2d.edp` like this in `hpddm` folder. Please help me!!!

```auto
https://github.com/FreeFem/FreeFem-sources/tree/master/examples

```

---

<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:** [June 7, 2024, 6:17am UTC](https://community.freefem.org/t/freefem-petsc-ubuntu/3289/6 "2024-06-07T06:17:55Z")

</div>

You need to use `ff-mpirun`.

---

<div class="post-metadata">

**Author:** ![LXX](https://avatars.discourse-cdn.com/v4/letter/l/258eb7/32.png) [@LXX](https://community.freefem.org/u/LXX)\
**Post date:** [June 7, 2024, 8:32am UTC](https://community.freefem.org/t/freefem-petsc-ubuntu/3289/7 "2024-06-07T08:32:52Z")

</div>

Thank you very much, professor. I tried using command `ff-mpirun` for `diffusion-2d-PETSc.edp` and `diffusion-2d.edp`, but what should I set the number of mpi processes - np to?

---

<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:** [June 7, 2024, 10:35am UTC](https://community.freefem.org/t/freefem-petsc-ubuntu/3289/8 "2024-06-07T10:35:37Z")

</div>

Whatever you decide.

---

<div class="post-metadata">

**Author:** ![LXX](https://avatars.discourse-cdn.com/v4/letter/l/258eb7/32.png) [@LXX](https://community.freefem.org/u/LXX)\
**Post date:** [June 7, 2024, 3:18pm UTC](https://community.freefem.org/t/freefem-petsc-ubuntu/3289/9 "2024-06-07T15:18:01Z")

</div>

Yes, but it will output a reminder of memory leak every time. Does this have any impact?

```auto
######## We forget of deleting 0 Nb pointer, 0Bytes , mpirank 1, memory leak =110992
 CodeAlloc : nb ptr 7859, size :698024 mpirank: 1
times: compile 0.035767s, execution 0.111224s, mpirank:2
 ######## We forget of deleting 0 Nb pointer, 0Bytes , mpirank 2, memory leak =219216
 CodeAlloc : nb ptr 7859, size :698024 mpirank: 2

times: compile 4.819200e-02s, execution 1.103700e-02s, mpirank:0
 ######## We forget of deleting 0 Nb pointer, 0Bytes , mpirank 0, memory leak =304368
 CodeAlloc : nb ptr 7859, size :698024 mpirank: 0
Ok: Normal End
WARNING! There are options you set that were not used!
WARNING! could be spelling mistake, etc!
There is one unused database option. It is:
Option left: name:-nw value: examples/hpddm/diffusion-2d-PETSc.edp source: command line
times: compile 0.035693s, execution 0.111251s, mpirank:3
 ######## We forget of deleting 0 Nb pointer, 0Bytes , mpirank 3, memory leak =219808
 CodeAlloc : nb ptr 7859, size :698024 mpirank: 3

```

---

<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:** [June 7, 2024, 3:34pm UTC](https://community.freefem.org/t/freefem-petsc-ubuntu/3289/10 "2024-06-07T15:34:50Z")

</div>

I don’t know, you tell me.
