SPRINT v. 1.0.7 released on CRAN (R package repository)

Author: Eilidh Troup
Posted: 30 Oct 2014 | 16:28


It's always good to end a project on a high so I was delighted to end my recent assignment to the SPRINT project by overcoming a few tricky technical obstacles and having the latest version of SPRINT accepted into the CRAN repository of add-on packages to the very popular R statistical computing software. This will make it much easier for users to discover and install SPRINT and gain from the fast processing of larger data sets that it can provide.

The new version of SPRINT (v 1.0.7) is now easy to install on Linux (Fedora or Debian) or Mac OS X with OpenMPI or MPICH. It has been great to work closely with Thorsten Forster, a biostatistician from the School of Biomedical Sciences, to provide the functionality required to allow him to analyse correlations between many more genes than he could before.

Getting onto CRAN was, however, not as straightforward has I had hoped. It’s been hard to get C and MPI code to compile along with R on all the recommended platforms and with different MPI implementations too. Even the mighty Google failed to present me with the immediate solutions to my difficulties.  I record some of the details at the end in the hope that they provide a trail of pebbles to anyone following in my footsteps through this particular dark wood a little more easily.

Now that one book temporarily closes, another one opens.  Except that this time I have to write it myself! Or at least a chapter of it. I’m working on a chapter on how to add your own MPI C code to R, using SPRINT. The SPRINT project is open source and welcomes contributions, so I’m looking forward to describing how to do this.

Now for the techy bit for MPI and R developers, apologies to everyone else:

If your MPI code compiles and runs under MPICH but not OpenMPI on Linux, you may need to export LD_PRELOAD=/usr/lib/libmpi.so. Alternatively you can add the following to your C code:
#ifdef OPEN_MPI
#if defined(__unix__)
       dlhandle = dlopen("libmpi.so", RTLD_GLOBAL | RTLD_LAZY);
       if ( NULL == dlhandle ) {
           ERR("Failed to open libmpi.so library. %s\n", dlerror());

Other tips for compiling MPI code inside R:

I simplified my configure.ac file when I realised that R figures out what most of the flags should be and then you can just ask for them like this: CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS` To see all the R configuration available to you run this on the command line: $ R CMD config

Configuring with the MPI compiler was much easier with the ACX_MPI macro. To compile with MPI, add the following to your configure.ac file. ACX_MPI([AC_MSG_RESULT([MPI found with success])], [AC_MSG_FAILURE("Unable to detect MPI compiler. Please use --with-wrapper-script option")])

And for adding the C99 flag, the AC_PROG_CC_C99 macro worked better across various compilers (including non-gnu ones). It didn’t add the C99 flag on Solaris. For this, exporting  MPICC='mpicc -xc99’ works.

Image: Nemo


Eilidh Troup

Blog Archive