mardi 4 avril 2017

C++ Compilation flags for an R package in Windows/Mac

I developed an R package which calls C++ code through Rcpp and RcppEigen. My Makevars.win looks like this (the enumeration is meant to refer to my questions)

  1. CXX_STD = CXX11

  2. PKG_CPPFLAGS = -fopenmp -O3 -Wall -ftree-vectorize -march=native -mavx -mfma

  3. PKG_CXXFLAGS += $(SHLIB_OPENMP_CXXFLAGS)

  4. PKG_LIBS = -fopenmp

  5. PKG_LIBS += $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB_OPENMP_CXXFLAGS)

  6. PKG_CPPFLAGS += -I../inst/include/

as I want to use OpenMP and link the R package against Intel MKL library. I am also adding in my source files the plugins // [[Rcpp::plugins(cpp11)]] and // [[Rcpp::plugins(openmp)]].

When I compile the package everything works fine but I am still getting the default compilation flags -O2 and -std=c++0x. So my questions are:

A. isn't 1. supposed to force -std=c++11 (by the way, using the same Makevars yields the right C++ version, so there must be something specific to Windows)?

B. does 3 repeats fopenmp in 2?

C. how to check whether 5. has been taken into account? I am asking this as the same package built on Mac is much faster than on Windows while their configurations are the same. I have done some benchmark of the same code on Windows using Microsoft R Open and Mac, and Windows was faster in that case.

Thank you very much for your very precious help.

Aucun commentaire:

Enregistrer un commentaire