C++ with a math library like GSL, LAPACK, or CBLAS performance vs C++ with Rinside with an R function?

StackOverflow https://stackoverflow.com/questions/13089243

  •  14-07-2021
  •  | 
  •  

Question

Has anyone ever done a straight up apple to apple comparison between:

  1. A C++ application calling an algorithm done in a R functions using RInside
  2. A C++ application calling the equivelant algorithm but using a one of the math libraries like GSL, LAPACK, or CBLAS?

I am trying to get benchmarks which would be faster. I am also interested in what kind of parallalzation/multithreading designs that might make the calculate faster within C++?

Was it helpful?

Solution

Aside from startup costs for initializing R which you only get in case 1) by your study design, the results should be identical as R itself uses the exactly same BLAS AND LAPACK libraries if built correctly.

I have a to-be updated package / vignette which proposes a benchmarking framework for exactly these questions as the issue is so easy to misunderstand -- see the CRAN page for gcbd as well as the corresponding pdf vignette.

If you build R differently (eg statically, or with its own BLAS / LAPACK sources), then you are getting different results but you are also not making an apples-to-apples comparison.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top