我想加载并调用一个使用MPI的库。我可以想象,每个级别都加载自己版本的库,然后库之间进行通信。我不想与库调用者进行任何通信或MPI处理。无论是加载使用mpi的库还是使用openmp的库,python代码都将保持不变。当我从C.动态加载和调用库时,我设法使它工作,但是对于python,它失败了:
mca: base: /usr/lib/openmpi/lib/openmpi/mca_paffinity_hwloc::component_find:无法打开可能缺少的符号,或者为open的不同版本编译?(忽略)
。。
看起来opal_init因为某种原因失败了;
。。
opal_shmem_base_select失败->返回值-1而不是OPAL_SUCCESS ompi_mpi_init: orte_init失败->返回“错误”(-1)而不是“成功”(0)
。。
我想知道我有什么用蟒蛇做的。比如用openmpi重新编译python?
我举一个例子如下:
testMPI.py
#!/usr/bin/env python
from ctypes import *
# Loading library
raw = cdll.LoadLibrary('./libtest.so.1.0')
print "hello world "
raw.test()test.f90
subroutine test() bind(c,name='test')
use MPI
implicit none
integer :: nprocs =-1 !< total number of process
integer :: rank=0 !< rank in comm world
integer :: ierr =-1 !<
call MPI_init(ierr)
call MPI_comm_size(MPI_comm_world, nprocs, ierr)
call MPI_comm_rank(MPI_comm_world, rank, ierr)
write(*,*)"hello world from ",rank," of ",nprocs
call MPI_finalize(ierr)
end subroutineMakefile
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*发布于 2015-02-12 16:04:30
我遇到了一个类似的问题,需要解决的问题是:当您运行用于编译openmpi的配置时,请使用以下标志:
/配置-禁用-dlopen
希望它对你有用!
https://stackoverflow.com/questions/26739644
复制相似问题