安装BLAS/ATLAS/MKL/OPENBLAS是否会加快用C/C ++编写的R包的速度? [英] Does installing BLAS/ATLAS/MKL/OPENBLAS will speed up R package that is written in C/C++?

查看:175
本文介绍了安装BLAS/ATLAS/MKL/OPENBLAS是否会加快用C/C ++编写的R包的速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现使用BLAS/ATLAS/MKL/OPENBLAS之一可以提高R的速度.但是,它是否仍会改善用C或C ++编写的R包? 例如,R包Glmnet在FORTRAN中实现,R包rpart在C ++中实现.是否仅安装BLAS/... etc会缩短执行时间?还是我们必须基于BLAS/... etc重新构建(构建新的C代码)包?

I found that using one of BLAS/ATLAS/MKL/OPENBLAS will give improvement on speed in R. However, will it still improve the R Package that is written in C or C++? for example, R package Glmnet is implemented in FORTRAN and R package rpart is implemented in C++. Will it just installing BLAS/...etc will improve the execution time? or do we have to rebuild (building new C code) the package based on BLAS/...etc?

推荐答案

经常要声明,必须重新编译R"才能使用不同的BLAS或LAPACK库,包括在此处的注释中.那是错误的.

It is frequently stated, including in a comment here, that "you have to recompile R" to use different BLAS or LAPACK library. That is wrong.

只要它是针对BLAS和LAPACK共享库版本构建的,就不必重新编译R .

You do not have to recompile R provided it is build against the shared library versions of BLAS and LAPACK.

我在CRAN上有一个包和小插图,它使用此事实在仅通过安装不同的BLAS和LAPACK版本(在Debian/Ubuntu中使用一个命令)并运行基准测试就可以对它们进行计时.这非常简单,可以在这样的程序包中自动化.

I have a package and vignette on CRAN which uses this fact to provide a benchmarking framework in which different BLAS and LAPACK version are timed against each just by installing different ones (one commmand in Debian/Ubuntu) and running benchmarks -- this is so straightforward that it can be automated in a package such as this.

该软件包中的结果将提供有关可能的速度差异的想法.它们的确切发布方式取决于您的计算机,您的数据(大小),您的问题等.但是,例如,如果您的问题使用的LAPACK函数可以从运行多线程中受益,那么安装OpenBLAS可能会有所帮助.对于使用LAPACK 的任何R软件包来说都是如此,因为它们将使用通过are访问的相同LAPACK安装,并且可以更改它们.

The results in that package will provide an idea of the possible speed differences. Exactly how they pan out depends on your computer, your data (size), your problem etc. But if, say, your problem uses LAPACK functions which can run benefit from running multithreaded then installing OpenBLAS may help. That is true for any R package using LAPACK as they will use the same LAPACK installation accessed through are, and these can be changed.

这篇关于安装BLAS/ATLAS/MKL/OPENBLAS是否会加快用C/C ++编写的R包的速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆