Eli S
Eli S

Reputation: 1463

Calling MPI_Init more than once

I understand that MPI_init can only be called more than once per executable instance. Can anyone clarify the limits of this language: ie:

  1. I know multiple python exec on mpiexec can be run.
  2. 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!

Upvotes: 0

Views: 2390

Answers (1)

Zulan
Zulan

Reputation: 22670

If I understand you correctly, the easiest way would be to intercept the calls to MPI_Init and 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 function MPI_Init and in that function, depending if it is called for the firs time, call PMPI_Init. The same (in reverse) for MPI_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_PRELOAD a 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.

Upvotes: 1

Related Questions