Open MPI logo

Open MPI User's Mailing List Archives

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

Subject: [OMPI users] Solution for dynamic loading with python
From: Evans, Thomas M. (evanstm_at_[hidden])
Date: 2009-07-14 14:41:11


Again, thanks to some other posts, I think I've found a reasonable, if not elegant, solution to the dlopen() issue with python and openmpi. Here is what I'm doing. First I make a python binding to the following function in module mpi_dl.py:

void mpi_dlopen()
{
    void *handle;
    handle = dlopen("libmpi.so", RTLD_LAZY|RTLD_GLOBAL);
    dlclose(handle);
}

I compile this into a python file called openmpi.py that has the binding and the python call, ie.:

import _mpi_dlopen
# ... stuff for binding mpi_dlopen function

mpi_dlopen()

Then, in my python scripts (where I will load my other bindings, I do the following):

import openmpi

import my_other_modules
# .... go forth and conquer

Actually, I include these lines at the very beginning of my my_other_modules so that users don't have to put this ugly code in their python scripts. In other words, I'm doing what I was doing using python's dl package, but this is cross-platform (I hope).

Tom

On 7/14/09 12:07 PM, "Jeff Squyres" <jsquyres_at_[hidden]> wrote:

(off list)

Tom --

I'm usually the guy who answers dynamic linker questions in the OMPI
community.

Be aware that I'm on vacation this week and am only replying to you
under great personal risk to my person (if my wife catches me on work
mail, I'm hosed!! ;-) ).

Hopefully, you can wait for a rely until next week, when I return and
dig out from the 6M+ emails that will surely have accrued while I was
gone...

On Jul 14, 2009, at 10:48 AM, Evans, Thomas M. wrote:

> Well, my previous solution has a major flaw, the python dl module is
> not
> available on AMD64. So, I'm not really sure what to do except drop
> support
> for openmpi. Any ideas would be greatly appreciated. Thanks.
>
> Tom
> --
> Tom Evans
> Radiation Transport and Shielding
> Nuclear Science and Technology Division
> ------------------------------------------------
> (865) 576-3535 Oak Ridge National Laboratory
> (865) 574-9619 fax PO Box 2008 MS6172
> evanstm_at_[hidden] Oak Ridge, TN 37831-6170
> www.ornl.gov/sci/radiation_transport_criticality
> ------------------------------------------------
>
>
> _______________________________________________
> users mailing list
> users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/users
>

--
Jeff Squyres
Cisco Systems
--
Tom Evans
Radiation Transport and Shielding
Nuclear Science and Technology Division
------------------------------------------------
(865) 576-3535     Oak Ridge National Laboratory
(865) 574-9619 fax PO Box 2008 MS6172
evanstm_at_[hidden]   Oak Ridge, TN 37831-6170
www.ornl.gov/sci/radiation_transport_criticality
------------------------------------------------
------ End of Forwarded Message