Friday 15 March 2013

Python calling a (fortran) library that uses MPI -



Python calling a (fortran) library that uses MPI -

i'd load , phone call library uses mpi. imagine each rank loads own version of library , libraries communicate each other. don't want communication or mpi handling library caller. python code remain same no matter if load library uses mpi or library utilize openmp instance. manage create work when dynamically load , phone call library c. python fails :

mca: base: component_find: unable open /usr/lib/openmpi/lib/openmpi/mca_paffinity_hwloc: perhaps missing symbol, or compiled different version of open mpi? (ignored)

[..]

it looks opal_init failed reason;

[..]

opal_shmem_base_select failed --> returned value -1 instead of opal_success ompi_mpi_init: orte_init failed --> returned "error" (-1) instead of "success" (0)

[..]

i wonder have for python. recompiling python openmpi?

i give illustration below:

testmpi.py

#!/usr/bin/env python ctypes import * # loading library raw = cdll.loadlibrary('./libtest.so.1.0') print "hello world " raw.test()

test.f90

subroutine test() bind(c,name='test') utilize mpi implicit none integer :: nprocs =-1 !< total number of process integer :: rank=0 !< rank in comm world integer :: ierr =-1 !< phone call mpi_init(ierr) phone call mpi_comm_size(mpi_comm_world, nprocs, ierr) phone call mpi_comm_rank(mpi_comm_world, rank, ierr) write(*,*)"hello world ",rank," of ",nprocs phone call mpi_finalize(ierr) end subroutine

makefile

fc=mpif90.openmpi fflags=-free -fpic -g -wall all: obj test test: mpirun.openmpi -n 4 ./testmpi.py obj: $(fc) $(fflags) -c test.f90 $(fc) $(fflags) -shared -wl,-soname,libtest.so.1 -o libtest.so.1.0 test.o clean: rm *.o libtest*

i had similar issue, there work around : when run configure compiling openmpi, utilize next flag:

./configure --disable-dlopen

hope works you!

python mpi

No comments:

Post a Comment