我正在通过重写绑定来弄清楚 haskell-mpi 是如何工作的。我正在尝试重新使用通过安装 PETSc 设置的 MPICH 安装(工作正常)。问题:make main
在 GHCi 中给了我一个正确的模块,但是当我请求计算 commWorld 时,链接器抱怨它找不到 MPI_COMM_WORLD 符号(但它在 makefile 的范围内)。
我究竟做错了什么?提前致谢
错误:
ByteCodeLink: can't find label
During interactive linking, GHCi couldn't find the following symbol:
MPI_COMM_WORLD
主要.chs:
type MPIComm = {# type MPI_Comm #}
newtype Comm = MkComm { fromComm :: MPIComm } deriving (Eq, Show)
foreign import ccall "&MPI_COMM_WORLD" commWorld_ :: Ptr MPIComm
foreign import ccall "&MPI_COMM_SELF" commSelf_ :: Ptr MPIComm
commWorld, commSelf :: Comm
commWorld = MkComm <$> unsafePerformIO $ peek commWorld_
commSelf = MkComm <$> unsafePerformIO $ peek commSelf_
生成文件:
PETSC_DIR_ARCH = ${PETSC_DIR}/arch-darwin-c-debug
PETSC_DIR_ARCH_INCLUDE = ${PETSC_DIR_ARCH}/include
main :
c2hs Main.chs -C -I${PETSC_DIR_ARCH}/include -C -I${PETSC_DIR}/include
ghci Main.hs -L${PETSC_DIR_ARCH}/lib -lpetsc -lmpich
mpi文件
typedef int MPI_Comm;
#define MPI_COMM_WORLD ((MPI_Comm)0x44000000)
#define MPI_COMM_SELF ((MPI_Comm)0x44000001)