Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] What will happen if a non-MPI executible loaded a MPI enabled shared library?
From: Lisandro Dalcin (dalcinl_at_[hidden])
Date: 2010-09-11 15:24:34

On 7 September 2010 17:08, Allen Zhao <a.zhao_at_[hidden]> wrote:
>  Hi, All,
> A newbie question:
> Suppose that I have a main executable (a non-MPI code, which just
> dynamically loaded a named share library), and I do compile the shared
> library with mpi-gcc. This way, when the main executable loads the shared
> library, what is going to happen?

Should work just fine. This is the way I use many MPI-based libs and
MPI itself from Python. However, make sure you dlopen() with
mode RTLD_GLOBAL, or things can co bad (this is the case with

> Can I parallel this application without calling MPI_Init() inside the main
> code, instead, I call MPI_Init() when the shared library is loaded by the
> main executable?

Of course.

> Will it then be able to run in parallel?

Unlikely. But you could use MPI_Comm_spawn() to spawn a new
application, then your main sequential code "chats" to the child
parallel app using MPI calls.

> If this scenario
> is possible, when should I call MPI_Finalize()?

When you know you will not use MPI any more. Perhaps you could
register a finalizer using atexit()...

Lisandro Dalcin
Predio CONICET-Santa Fe
Colectora RN 168 Km 472, Paraje El Pozo
Tel: +54-342-4511594 (ext 1011)
Tel/Fax: +54-342-4511169