2021年3月27日星期六

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

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. 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  CXXFLAGS+=-Wno-ignored-attributes  CXX11FLAGS+=-Wno-ignored-attributes  CXX14FLAGS+=-Wno-ignored-attributes  

The ignored-attributes flags are in there in an attempt to silence the numerous "issues" raised by sourceCpp when loading the RcppEigen template library. That's based on this post (https://github.com/vinecopulib/rvinecopulib/issues/135) and others, but it doesn't seem to work.

https://stackoverflow.com/questions/66838053/rcppeigen-functions-are-very-fast-with-sourcecpp-but-very-slow-when-compiled-as March 28, 2021 at 11:07AM

没有评论:

发表评论