简体   繁体   中英

How to write a CRAN-publishable package linked against Intel MKL?

I am writing an R package that ideally needs the vdCdfNormInv function from the Intel MKL .

How do I configure the NAMESPACE file and the makevar file?

There is a scalar version of this function from Rmath.h . However, if possible, the MKL version should have better performance.

Use C++ preprocessor macros. Here's am example:

double result;
#ifdef INTEL_MKL_VERSION 
result = vdCdfNormInv(...);
#else
result = vdCdfNormInv_generic(...);
#endif

Alternatively, you can just throw an error ( std::runtime_error or Rcpp::stop ) if INTEL_MKL_VERSION is not defined.

But I think if you submit a package to CRAN, you should take the effort to make it available to people without MKL, even if it is slower.

See also reference: Using Predefined Preprocessor Symbols for Intel® MKL Version-Dependent Compilation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM