CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Using OpenMP similar to MPI? Bad idea? (https://www.cfd-online.com/Forums/main/232893-using-openmp-similar-mpi-bad-idea.html)

aerosayan January 5, 2021 03:12

Using OpenMP similar to MPI? Bad idea?
 
1 Attachment(s)
I want to see if it's possible to use OpenMP to manage the multithreading of my solver instead of using MPI. I will be solving for supersonic flow over a ramp. There will be multiple block structured regions as shown in the pic.

Since the blocks will be small in size, it would be faster to make each CPU work on a different block instead of every CPU working on a single block. I know MPI is commonly used for tasks like this. But I want to see if OpenMP can be used instead.

The data will be stored in a shared memory model in a single PC, so OpenMP can access the complete data.

I'm thinking of making a function like solve_flow_in_block(block[i], omp_get_thread_num()) and putting it inside a #pragma omp parallel block that will execute until convergence.

Is it a good idea to do this? Or is it gonna blow up in my face? :D

PS : I only know OpenMP, and I only have a small system with limited resources. So I don't need MPI right now.

sbaffini January 5, 2021 06:48

For an unstructured grid I would have no doubt, MPI is easier and more rewarding.

For a structured grid, instead, I guess OpenMP is probably easier, but only because MPI would need to be extremely "verbose" in this case and the parallel decomposition would be a very limiting factor unless a lot of effort is put on it.

Still, my experience is only with MPI on unstructured grids, so take this with a grain of salt.

aerosayan January 6, 2021 04:31

Quote:

Originally Posted by sbaffini (Post 792459)
For an unstructured grid I would have no doubt, MPI is easier and more rewarding.

For a structured grid, instead, I guess OpenMP is probably easier, but only because MPI would need to be extremely "verbose" in this case and the parallel decomposition would be a very limiting factor unless a lot of effort is put on it.

Still, my experience is only with MPI on unstructured grids, so take this with a grain of salt.


I don't know MPI, but apparently there's a faster option in MPI that alllows it to not use its distributed memory model, instead use shared memory model.


How difficult is it to learn MPI and get started?

Currently I don't know with guarantee if OpenMP can handle the task I mentioned. Other option is to use the basic C++ multithreading.

sbaffini January 6, 2021 05:42

If you have even a very basic understanding of how distributed parallel works, then learning MPI, which is just a bunch of commands, is basically trivial. The actual problem with MPI is structuring the code (memory allocation and algorithms) so that everything works smoothly and nothing scales with the total number of cells or processors.

But, in my opinion, with respect to the shared memory approach, its main advantage is that nothing happens under the hood, except for few cases (like the remote memory access feature you were mentioning). So that you can actually structure the code to be fairly transparent to the parallel implementation.

If you are staying shared, consider that learning OpenMP will be useful in other languages (including Fortran)

I see no point in using MPI only with remote memory access. You would not build a true MPI code and still have the difficulties of a shared approach.


All times are GMT -4. The time now is 03:42.