使用高级编译工具和方法增强R
Enhancing R with Advanced Compilation Tools and Methods
摘要:
我描述了一种将R代码中的常见习惯用法直接编译为本机机器码的方法,并通过几个示例进行了说明。这不仅可以产生显着的性能增益,而且它允许我们使用新的方法来计算R。重要的是,编译不需要对R本身进行任何更改,而是完全通过R包完成。这允许其他人尝试不同的编译策略,甚至在R中定义新的特定于域的语言。我们使用低级虚拟机(LLVM)编译器工具包来创建本机代码并对代码执行复杂的优化。通过在R中采用这种广泛使用的软件,我们利用其为CPU和GPU等不同平台生成代码的能力,并将继续从其持续的开发中受益。这种方法可能允许我们开发高级R代码,这些代码也很快,可以编译为不同的数据表示和源,甚至可以在R之外运行。该方法旨在为R语言的有限子集提供编译器,并使R程序员能够编写其他编译器。这是另一种方法,可以帮助我们编写关于我们想要计算的内容的高级描述,而不是如何计算。
英文摘要:
I describe an approach to compiling common idioms in R code directly to native machine code and illustrate it with several examples. Not only can this yield significant performance gains, but it allows us to use new approaches to computing in R. Importantly, the compilation requires no changes to R itself, but is done entirely via R packages. This allows others to experiment with different compilation strategies and even to define new domain-specific languages within R. We use the Low-Level Virtual Machine (LLVM) compiler toolkit to create the native code and perform sophisticated optimizations on the code. By adopting this widely used software within R, we leverage its ability to generate code for different platforms such as CPUs and GPUs, and will continue to benefit from its ongoing development. This approach potentially allows us to develop high-level R code that is also fast, that can be compiled to work with different data representations and sources, and that could even be run outside of R. The approach aims to both provide a compiler for a limited subset of the R language and also to enable R programmers to write other compilers. This is another approach to help us write high-level descriptions of what we want to compute, not how.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。