Setting up "configure" for openMP in R
I have an R package which is easily sped up by using OpenMP. If your compiler supports it then you get the win, if it doesn't then the pragmas are ignored and you get one core.

My problem is how to get the package build system to use the right compiler options and libraries. Currently I have:

    PKG_CPPFLAGS=-fopenmp
    PKG_LIBS=-fopenmp

hardcoded into src/Makevars on my machine, and this builds it with OpenMP support. But it produces a warning about non-standard compiler flags on check, and will probably fail hard on a machine with no openMP capabilities.

The solution seems to be to use configure and autoconf. There's some information around here:

http://cran.r-project.org/doc/manuals/R-exts.html#Using-Makevars

including a complex example to compile in odbc functionality. But I can't see how to begin tweaking that to check for openmp and libgomp. 

None of the R packages I've looked at that talk about using openMP seem to have this set up either.

So does anyone have a walkthrough for setting up an R package with OpenMP?

Setting up "configure" for openMP in R
===

I have an R package which is easily sped up by using OpenMP. If your compiler supports it then you get the win, if it doesn't then the pragmas are ignored and you get one core.

My problem is how to get the package build system to use the right compiler options and libraries. Currently I have:

    PKG_CPPFLAGS=-fopenmp
    PKG_LIBS=-fopenmp

hardcoded into src/Makevars on my machine, and this builds it with OpenMP support. But it produces a warning about non-standard compiler flags on check, and will probably fail hard on a machine with no openMP capabilities.

The solution seems to be to use configure and autoconf. There's some information around here:

http://cran.r-project.org/doc/manuals/R-exts.html#Using-Makevars

including a complex example to compile in odbc functionality. But I can't see how to begin tweaking that to check for openmp and libgomp. 

None of the R packages I've looked at that talk about using openMP seem to have this set up either.

So does anyone have a walkthrough for setting up an R package with OpenMP?
