是否存在 C/C++ 的 R 编译器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1452235/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does an R compiler to C/C++ exist?
提问by Shane
I'm wondering about the best way to deploy R. Matlab has the "matlab compiler" (MCR). There has been discussion about something similar in the past for R that would compile R into C or C++. Does anyone have any experience with the R to C Compiler (RCC) that was developed by John Garvin at Rice?
我想知道部署 R 的最佳方式。Matlab 有“matlab 编译器”(MCR)。过去曾讨论过将 R 编译成 C 或 C++ 的类似 R 的东西。有没有人对由 John Garvin 在 Rice 开发的R 到 C 编译器(RCC)有任何经验?
I've looked into it, and it seems to be the only project that worked on compiling R code into executable code. And as far as I can tell, it isn't still being used.
我研究过它,它似乎是唯一一个将 R 代码编译为可执行代码的项目。据我所知,它还没有被使用。
[Edit 1:]: To be clear, I know that there are C and C++ (and Java, Python, etc.) interfaces to R (rJava, rcpp, Rpy, etc.). I'm wondering about specific ways to compile and deploy R code without installing R in advance.
[编辑 1:]:要清楚,我知道有 C 和 C++(以及 Java、Python 等)到 R(rJava、rcpp、Rpy 等)的接口。我想知道在不提前安装 R 的情况下编译和部署 R 代码的具体方法。
[Edit 2:]: John Mellor-Crummey tells me that they're still working on RCC and hope to make it available in 4 months or so (at the earliest). I'll update this further if I find anything else out.
[Edit 2:]:John Mellor-Crummey 告诉我,他们仍在研究 RCC,并希望在 4 个月左右(最早)内使其可用。如果我发现任何其他内容,我会进一步更新。
采纳答案by Luke Tierney
A byte code compiler will be part of the R 2.13 release. By default it is not used in this release but it is available; I expect the 2.14 release will by default byte compile all base and recommended packages. The compiler::compile help page and the R Installation and Administration Manualgive some more details.
字节码编译器将成为 R 2.13 版本的一部分。默认情况下,此版本中不使用它,但它可用;我希望 2.14 版本将默认字节编译所有基本和推荐的包。compiler::compile 帮助页面和R 安装和管理手册提供了更多详细信息。
回答by Dirk Eddelbuettel
I had forgotten about the Rice project, it has been a while. I think the operational term here is stated at the top of the project page: Last Updated 3/8/06.
我已经忘记了赖斯项目,已经有一段时间了。我认为这里的操作术语在项目页面的顶部说明: Last Updated 3/8/06。
And we all know R changes a lot. So I have only the standard few pointers for you:
我们都知道 R 变化很大。所以我只有几个标准的建议给你:
- Luke Tierney, who not only knows a lot about R internals but equally about byte compilers, has been working on such a project. Nothing ready yet, and it would still work in conjunction with the standard R engine.
- Stephen Milborrow has the Raextension to R that works with his just-in-time compiler package jit
- my Introduction to High-Performance Computing with R tutorials (most recent tutorial slides from UseR! 2009)covers the profiling, compiling extentions, parallel computing with R, ... part, including Rcppand and a bit about RInside.
- Luke Tierney不仅对 R 内部结构了解很多,而且对字节编译器同样了解,他一直致力于这样一个项目。还没有准备好,它仍然可以与标准 R 引擎一起工作。
- Stephen Milborrow 拥有R的Ra扩展,可与他的即时编译器包jit 配合使用
- 我的 R 高性能计算介绍教程(来自 UseR!2009 的最新教程幻灯片)涵盖了性能分析、编译扩展、使用 R 进行并行计算,...部分,包括 Rcpp和一些关于 RInside 的内容。
In short: there is no way have what you desire specific ways to compile and deploy R code without installing R in advance. Sorry.
简而言之:如果不提前安装 R,就没有你想要的特定方式来编译和部署 R 代码。对不起。
Edit/Update (April 2011):Luke's new compiler
package will be part of R 2.13.0 (to be released April 2011) but not 'activated' by default which is expected for R 2.14.0 expected for October 2011.
编辑/更新(2011 年 4 月):Luke 的新compiler
软件包将成为 R 2.13.0(将于 2011 年 4 月发布)的一部分,但默认情况下不会“激活”,预计将于 2011 年 10 月发布的 R 2.14.0。
Edit/Update (December 2011):Prof Tierney just release a massive 100+ page paperon the byte-code compiler.
回答by Spacedman
Why do people get the fear when deploying R? I'm fairly sure I've seen this question before.
为什么人们在部署 R 时会感到恐惧?我很确定我以前见过这个问题。
Installing R is a piece of cake (you don't actually say which OS you care about). For Windows its one .exe. file, run it, say "yes" a few times and its done. I suspect the installer exe probably has flags for unattended installation too.
安装 R 是小菜一碟(你实际上并没有说你关心哪个操作系统)。对于 Windows,它是一个 .exe。文件,运行它,说“是”几次就完成了。我怀疑安装程序 exe 可能也有无人值守安装的标志。
回答by AST
You may check out the P compiler which implements a subset of R. Especially, lists, matrices, vectors etc. are implemented as well as lsfit, chol, svd, ...
您可以查看实现 R 子集的 P 编译器。特别是,实现了列表、矩阵、向量等以及 lsfit、chol、svd 等。
You can download a free version at
您可以在以下位置下载免费版本
It speeds up computations substantially.
它大大加快了计算速度。
Best,
最好的事物,
AS
作为
回答by Tristan
I haven't used Garvin's package and don't know what is possible along those lines. However:
我没有使用过 Garvin 的包,不知道这些方面有什么可能。然而:
Typically people just write computationally intensive functions directly in C/C++/Fortran, after profilingto find the bottlenecks. See the RCpp interfaceor Calling C functions from R using .C and .Callfor examples. The Scythe Statistical Libraryis also very nice for R users since the syntax/function names are similar.
通常,人们只是在分析以找到瓶颈之后直接在 C/C++/Fortran 中编写计算密集型函数。有关示例,请参阅RCpp 接口或使用 .C 和 .Call 从 R 调用 C 函数。由于语法/函数名称相似,Scythe 统计库也非常适合 R 用户。