Some time back, I began writing some OpenMPI wrappers for Lisp. I got everything that I needed working, but I hardly scratched the surface of what MPI-2 makes available.
Recently, Alex Fukunaga started up a blog about Lisp. One of the things he has done is make CFFI bindings for mpich2. Here is an introductory post about those bindings with a link to his CL-MPI site.
Today, I have been working on getting his bindings up and running under Ubuntu Linux and Mac OS X.
So far, it has been a nightmare trying to get mpich2 compiled on either platform. It compiles famously if you just run
However, that doesn’t build shared libraries. Without shared libraries, the CFFI stub library happily links against the static library and happily imports zero of the symbols. After sifting through configure –help, I decided that I should add –enable-dynamiclibs. Doing so yells at me that I must also specify –enable-sharedlibs=type. So, I sifted through the help again and decided to try:
macosx% ./configure --prefix=/usr/local --enable-dynamiclibs --enable-sharedlibs=gcc-osx
Both compiles then bomb out saying MPIU_CALL_MPIDI_CH3 is undeclared. Yay.
Searching the web on the relevant errors, I discover that I do not need to enable dynamiclibs to get shared libraries. Wheee. Now, mpich2 is built on both architectures.
I added this target into cl-mpi/mpich2-stub/Makefile:
mpicc -dynamiclib -o libmpiskeleton.dylib -dylib mpiskeleton.o
and changed the bottom of cl-mpi/cl-mpi-configure.lisp to this:
(pushnew :mpich2 *features*) ; Use MPICH2
(defvar *mpi-header-file* "/usr/local/include/mpi.h")
;; For MPICH2, Need to load a special stub shared object, and not the MPICH s\
hared library directly
(defun load-mpi-foreign-libraries ()
#-darwin
(cffi:use-foreign-library "/usr/local/asdf-install/site/cl-mpi/mpich2-stub/\
libmpiskeleton.so.1.0.1")
#+darwin
(cffi:use-foreign-library "/usr/local/asdf-install/site/cl-mpi/mpich2-stub/\
libmpiskeleton.dylib")
))
After sorting out some svn merge problems in mpi-test.lisp, it appears as though it all works wonderfully on MacOSX. Most of it seems to work under Ubuntu for me, but I have to look into some error messages more closely.
Hello,
Great work, but I still need some help. I compile and install mpich2, libskeleton and mpi-grovel and I come as far as
Form:
(LOAD-MPI-FOREIGN-LIBRARIES)
Compile-time error:
(during compile-time-too processing)
The function LOAD-MPI-FOREIGN-LIBRARIES is undefined.
But my bag is running out of tricks. Any ideas?
No… I don’t know. It looks to me like the defun for LOAD-MPI-FOREIGN-LIBRARIES is inside an EVAL-WHEN that includes :compile-toplevel. Which Lisp are you using? on which platform?
Yes, defun is inside EVAL-WHEN :compile-toplevel. Shouldn’t it be?
I’m on SBCL 1.0.35 on Mac 10.6.2 trying to get the newest version of cl-mpi (0.2.3) to work with mpich2 (1.2.1).
I found a workaround for the problem of undefined »LOAD-MPI-FOREIGN-LIBRARIES«. In »mpi.lisp« replace »(load-mpi-foreign-libraries)« by »(cffi:use-foreign-library “/WHEREVER/mpich2-stub/libmpiskeleton.so.1.0.1”)«.
This way, and with a fews other obvious changes to filenames (e.g. where to look for MPI headers), I succeeded building CL-MPI and running examples. However, the test suite fails with memory corruption errors.
How about working together on this? There seems to be no mailing list for CL-MPI, so I created one at lisp@list.plastictree.net (it is intended for more general discussion as well).
I’m interested in implementation of efficient and parallel algorithms in general, and Common Lisp and Scheme in particular.