Cheers
Ole
Hi Ole - I got it to work, but only by editing your pypar.py,
at the bottom to look like this:
# Work around bug in OpenMPI (December 2009):
# SJP NOTE: added code to have it look for MPICH first, then OpenMPI MPI
try:
mpi = CDLL('libmpich.so')
except:
mpi = CDLL('libmpi.so.0', RTLD_GLOBAL)
# End work around
As I see it, the problem is that this line
mpi = CDLL('libmpi.so.0', RTLD_GLOBAL)
will never work if you are wanting MPICH MPI, since
its lib file is libmpich.so.
Again, what I am wanting to do is write a Python script
that wraps both MPI (via Pypar) and our code LAMMPS, which
itself builds with MPI and makes MPI calls. So it is required
that both Pypar and LAMMPS use the same MPI, else the script
crashes immediately. LAMMPS allows you to build with any MPI
that is on your box (since you specify the name and path
of the mpi.h and MPI lib file in your LAMMPS Makefile).
The way I see it, Pypar also needs to give you some control
over which MPI on the system that it builds against. The odd thing
is that it seems to do this OK when you do setup.py build
and install, because it invokes mpicc. So as long as it finds
the correct mpicc, then everything should be consistent. In my
case, the mpicc is for MPICH, so I get this output
from "python setup.py build", as the last line
gcc -pthread -shared build/temp.linux-x86_64-2.7/mpiext.o -L/usr/local/lib -lmpich -lopa -lmpl -lrt -lpthread -o build/lib.linux-x86_64-2.7/pypar/mpiext.so
Note that it knows to use -lmpich and other libs that MPICH requires.
So all is good.
But when you "import pypar" into Python, it ends up running this line:
mpi = CDLL('libmpi.so.0', RTLD_GLOBAL)
which loads the OpenMPI libmpi.o, which is fatal. If I didn't
have OpenMPI on my box, it just gives the CDLL fail-to-load
error.
Since my code addition is a hack for my box, I suggest one of the following:
a) since the build knows it needs -lmpich and not -lmpi, keep that
info around for the CDLL call, if possible
b) add a setup.py option that lets the user specify the correct name
of the MPI *.so that is needed
c) you might also think about a setup.py option to give a path
to mpicc, since you can have multiple of those on your box as
well, if you have 2 or more MPIs installed
> PS - Pypar uses MPI_COMM_WORLD by default. But it would not be a huge deal
> to enable other communicators.
There are 2 issues I think.
a) First, Pypar would need to provide a wrap on MPI_Comm_split(), so
the Python script can create new communicators on subsets of procs.
Maybe it already has this?
b) Second, I need to be able to pass that new communicator (or
MPI_COMM_WORLD) to our LAMMPS lib, as an argument that ctypes
recognizes as being compatible with MPI_Comm.
Note that MPI_Comm is a datatype defined by MPI and is different
for different MPIs. In MPICH it is just an int. But in OpenMPI
it is an opaque data structure. I don't know how Pypar
represents the MPI communicator.
Can you show me a couple lines of Pypar code that would
pass an MPI communicator (e.g. MPI_COMM_WORLD) to a simple C
function that ctypes wraps? E.g. so that the C code can make
an MPI call with it?
Thanks for developing Pypar. I like that it has a simple API and is
supported.
Steve
> Date: Mon, 13 Aug 2012 17:35:47 +0700
> From: Ole Nielsen <ole.molle...@gmail.com>
> CC: Stephen Roberts <stephen...@anu.edu.au>,
> <pypar-...@googlegroups.com>
> Content-Type: multipart/alternative; boundary="0015173fec10bdfd8e04c723410d"
>
> [1:text/plain Hide]
> [2:text/html Show]