On Feb 24, 2009, at 11:32 AM, <michael.mei...@dlr.de> <michael.mei...@dlr.de > wrote:

The minimpi(.py) Python module loads the minimpiext(.c) module and calls
its minimpiext.init() method (defined in minimpiext.c) which in turn
calls MPI_Init(). "minimpiext.c" is linked against libmpi. Libmpi is
loaded as soon as Python evaluates "import minimpi".

Ah, ok. I wonder if you're not building properly. -lmpi is not usually suffucient to build an Open MPI application; we hide a bunch of flags inside mpicc you can see via mpicc --showme.

How does one add more ldflags to your setup.py script?

To try it out yourself, please feel free to use the attached code.
* Make sure to adapt the pathes to your OpenMPI implementation in
setup.py
* Run "setup.py install"
* Start Python
* type "import minimpi" and the application should crash.

I had to change your code slightly for my version of python (probably

ancient -- whatever ships in RHEL4):

#if 0
        Py_RETURN_TRUE;
#else
        return PyBool_FromInt(1);
#endif

I then was able to "./setup.py install" properly.  It looks like you
also need to setenv PYTHON_MPI_INIT to some non-empty value as well;
otherwise minimpi.py raises an error at import time.

You source fix looks good, I will pass it to the minimpi maintainer.

Actually, as I got further, I see PyBool_FromInt() does not exist -- but PyBool_FromLong() does. Use that instead.

BUT: The PYTHON_MPI_INIT environment variable is used to control our
patched Python interpreter and should not be needed. The exception is
generated just after the loading of the minimpiext(.c) module already
failed.

Ah, I see -- it was ignoring the exception in what you initially sent, which is why I ran into this issue.

If you replace the following line in minimpi.py:

   except ImportError: # couldn't load the .so

with the following lines:

   except ImportError, e: # couldn't load the .so
       print e


Ok, now I'm getting the error:

>>> import minimpi
python: symbol lookup error: /home/jsquyres/bogus/lib/openmpi/ mca_paffinity_linux.so: undefined symbol: mca_base_param_reg_int

I'd like to experiment with adding some other ldflags / libs into the build process. How do I do that?

--
Jeff Squyres
Cisco Systems

Reply via email to