ninohardt / echoice2

choice models with economic foundation
http://ninohardt.de/echoice2
Other
1 stars 0 forks source link

Note on OpenMP & Rcpp Plugin #2

Open coatless opened 1 year ago

coatless commented 1 year ago

Nino,

Hope all is well. Glancing at the updated package, I think everything should now be in order for your CRAN submission.

That is, you are using an #ifdef _OPENMP to protect against including OpenMP headers ( <omp.h> ) if they are absent from the crippled compiler inside a custom myomp.h

https://github.com/ninohardt/echoice2/blob/114108d009fddfe3b63791afaeee1394e3bac967/src/myomp.h#L1

However, the next line down, you are including:

// [[Rcpp::plugins(openmp)

This plugin only works with the standalone Rcpp functions (evalCpp(), cppFunction(), and sourceCpp()). Within a package context, it isn't setting any variables required. You can remove this line as a result.

The true compiler flags for OpenMP are being set in src/Makevars:

https://github.com/ninohardt/echoice2/blob/114108d009fddfe3b63791afaeee1394e3bac967/src/Makevars#L2-L3

In particular, note that SHLIB_OPENMP_CXXFLAGS appears twice over.

ninohardt commented 1 year ago

James,

thank you! I removed // [[Rcpp::plugins(openmp). It's unfortunate that MacOS users need to invest so much effort to install and recompile the package to benefit from OpenMP support, but at least it runs.

coatless commented 1 year ago

@ninohardt we're slowly moving toward adding the omp.h headers into the new "Mac for Rtools" approach.

https://github.com/coatless-mac/macrtools

Right now, your users should be able to get Xcode CLI, gfortran, and an assortment of R development binaries.