Configure "configure" for openMP in R

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?

+5
2

, ,

## -- compiling for OpenMP 
PKG_CXXFLAGS=-fopenmp
##
## -- linking for OpenMP
PKG_LIBS= -fopenmp -lgomp 

, -lgomp OpenMP. , , Rtools Windows. Linux .

unrelease, , PKG_LIBS, Rcpp:

$(shell $(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()") \
                              $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

, , autoconf , , OpenMP configure.

: SpacedMan . libgomp-4.4:

1 OpenMP

OpenMP C/++ Fortran, `-fopenmp '. OpenMP [...] OpenMP.

, . , , , ...

+1

autoconf - , autoconf . , autoconf configure script - , , configure script. , configure script configure.ac( configure.in, ), autoconf . autoconf aclocal, autoheader, libtoolize .. (autoreconf), . autoreconf autoconf.

+1

All Articles