RcppEigen functions are very fast with sourceCpp but very slow when compiled as a package

424 Views Asked by At

I've written an RcppEigen package with extensive OpenMP usage, all of which is in a single .cpp file.

When I compile the code using Rcpp::sourceCpp() everything is extremely fast -- amazing.

When I compile using devtools::document() and run the same function it's terribly slow -- not amazing.

I suspect this is something to do with my Makevars file and/or compiler optimization. I've seen a few questions on this topic (Overriding system defaults for C++ compilation flags from R, R: C++ Optimization flag when using the inline package).

This is my makevars file:

CXXFLAGS=-O3 -fopenmp
CXX_STD = CXX11
0

There are 0 best solutions below