I understand that MPI_init can only be called more than once per executable instance. Can anyone clarify the limits of this language: ie:
- I know multiple python exec on mpiexec can be run.
- Is there anything like fork() or threads that can lead to something that qualifies? Is the criterion that they have to happen first and then invoke mpiexec?
Thanks!
If I understand you correctly, the easiest way would be to intercept the calls to
MPI_Initand execute it only once. For C, MPI provides the PMPI Profiling Interface that allows you to override any MPI symbol and provides an additional PMPI symbol. E.g. you define a functionMPI_Initand in that function, depending if it is called for the firs time, callPMPI_Init. The same (in reverse) forMPI_Finalize.I am not sure about the most elegant way to do that in Python. I assume you could just hack into the python bindings or
LD_PRELOADa simple C library doing the magic.All of that is just a workaround, that might have bad side effects. MPI Implementations advise you to not do much before an
MPI_Init. The real solution would be fixing the code to use MPI appropriately.