I have an R package that is easily accelerated using OpenMP. If your compiler supports it, then you get a win, but if not, pragmas are ignored and you get one core.
My problem is how to get the package build system to use the correct compiler options and libraries. I currently have:
PKG_CPPFLAGS=-fopenmp
PKG_LIBS=-fopenmp
hardcoded in src / Makevars on my machine and this creates it with OpenMP support. But it gives a warning about non-standard compiler flags when checking and probably will not work on a machine without openMP capabilities.
The solution is similar to using configure and autoconf. There is information 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 figure out how to start the setup to check openmp and libgomp.
None of the R packages I looked at in this talk about using openMP seem to be configured either.
Does anyone have a step-by-step guide for creating an R package with OpenMP?
[EDIT]
I may have hacked it now. I have a configure.ac script and Makevars.in with @FOO @ substitutions for compiler options. But now I'm not sure about the workflow. It:
- Run "autoconf configure.in> configure; chmod 755 configure" if I modify the configure.in file.
- Create a package.
- When installing the package, the system starts. / configure for me and creates Makevars from Makevars.in
, , "autoconf configure.in > configure" - script, - amirite?