2

Eigen supports OpenMP for some matrix operations

It asks the user to set the -fopenmp flag on the compiler. When using RcppEigen and sourceCpp(), I see options like -DNDEBUG and -O2 optimization flags being passed, but I don't see -fopenmp. Is there a function that exposes this flag when compiling RcppEigen code?

JCWong
  • 1,163
  • 1
  • 10
  • 29
  • 3
    There are plugins you can activate (or, in package, compiler flags you can set in `src/Makevars`). See the Rcpp Gallery questions on OpenMP. – Dirk Eddelbuettel Mar 29 '17 at 18:39
  • 1
    Got it, looks like the answer is ```#include ``` followed by ```// [[Rcpp::plugins(openmp)]]```. This is a great solution; if I turn my cpp code into a package a user doesn't have to think about passing openmp flags. I was worried end users would have to do something special to also get the flag passed in their system – JCWong Mar 29 '17 at 20:24
  • Correct. But you really want it in a package where you'd use `src/Makevars`. – Dirk Eddelbuettel Mar 29 '17 at 20:27
  • 2
    And if you want to require openmp for a package you should see: http://stackoverflow.com/questions/42280628/requiring-openmp-availability-for-use-in-an-rcpp-package/42281495#42281495 – coatless Mar 29 '17 at 20:33
  • Or simply never mention the package to any macOS user :) – Dirk Eddelbuettel Mar 29 '17 at 20:39

0 Answers0