是否存在 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 20:01:36  来源:igfitidea点击:

Does an R compiler to C/C++ exist?

c++cdeploymentcompiler-constructionr

提问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.

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 compilerpackage 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.

编辑/更新(2011 年 12 月):蒂尔尼教授刚刚发布了一篇关于字节码编译器的100 多页论文

回答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

您可以在以下位置下载免费版本

www.ptechnologies.org

www.ptechnologies.org

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 用户。