Installing mpich2 for use with CL-MPI June 5th, 2009
Patrick Stein

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

% ./configure --prefix=/usr/local

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:

ubuntu% ./configure --prefix=/usr/local --enable-dynamiclibs --enable-sharedlibs=gcc
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:

libmpiskeleton.dylib: mpiskeleton.o
        mpicc -dynamiclib -o libmpiskeleton.dylib -dylib mpiskeleton.o

and changed the bottom of cl-mpi/cl-mpi-configure.lisp to this:

(eval-when (:compile-toplevel :load-toplevel :execute)
  (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 ()
    (cffi:use-foreign-library "/usr/local/asdf-install/site/cl-mpi/mpich2-stub/\"
    (cffi:use-foreign-library "/usr/local/asdf-install/site/cl-mpi/mpich2-stub/\

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.