Discussion:
[Beowulf] Refactoring an MPI code to call from another MPI code
Navid Shervani-Tabar
2018-05-06 05:10:46 UTC
Permalink
Dear All,

I have a question which is more on the software side, and I was advised
that I might find people with related expertise here.

I have two programs Main and Solver, each of which uses MPI for parallel
processing. I am keeping Main as the main code and am modifying Solver as a
subroutine which is being called by Main.

The problem arises when both codes initiate the MPI (since both were
originally standalone programs) and then each have their own parallel
structure, which leads the code to crash as MPI_init can only be called
once in the now combined program.

I thought this must have been a common problem and there should be
discussions on how to approach this; However, to my surprise, I couldn't
find anything with this setting on common websites like stackoverflow and
the archives of this mailing list.


Thanks,

Navid

PS1: When connecting the two codes, I decided to call Solver by Main rather
than running the Solver as an executable by Main to have a more optimized
and robust setting and also avoid the overhead.

PS2: Code Main is written in c++ and code Solver is written in Fortran.
Charlie Peck
2018-05-06 11:30:25 UTC
Permalink
It’s hard to tell for certain without looking at the code, but I believe you want to use two different MPI communicators, one for each of the programs, see http://mpitutorial.com/tutorials/introduction-to-groups-and-communicators/

charlie
Post by Navid Shervani-Tabar
Dear All,
I have a question which is more on the software side, and I was advised that I might find people with related expertise here.
I have two programs Main and Solver, each of which uses MPI for parallel processing. I am keeping Main as the main code and am modifying Solver as a subroutine which is being called by Main.
The problem arises when both codes initiate the MPI (since both were originally standalone programs) and then each have their own parallel structure, which leads the code to crash as MPI_init can only be called once in the now combined program.
I thought this must have been a common problem and there should be discussions on how to approach this; However, to my surprise, I couldn't find anything with this setting on common websites like stackoverflow and the archives of this mailing list.
Thanks,
Navid
PS1: When connecting the two codes, I decided to call Solver by Main rather than running the Solver as an executable by Main to have a more optimized and robust setting and also avoid the overhead.
PS2: Code Main is written in c++ and code Solver is written in Fortran.
_______________________________________________
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf
_______________________________________________
Beowulf mailing list, ***@beowulf.org sponsored by Penguin Computing
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listi
Loading...