arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2501.15856cs.MScs.PFstat.CO
收藏

rcpptimer:支持OpenMP的Rcpp计时器

rcpptimer: Rcpp Tic-Toc Timer with OpenMP Support

Jonathan Berrisch

AI总结:

rcpptimer包为Rcpp生态系统提供用户友好的tic-toc计时类,支持重叠、嵌套计时器及OpenMP并行,以纳秒级分辨率高效测量C++代码执行时间,并无需编写C++代码即可将结果传回R。

摘要:

高效代码编写既是一项关键任务,也是一项具有挑战性的任务,尤其是在统计和机器学习应用中对计算密集型算法的需求日益增长的背景下。尽管当今可用的计算能力已十分强大,但优化算法实现的需求仍然至关重要。许多R用户依赖Rcpp在C++中编写高性能代码,但编写和基准测试C++代码本身也面临诸多困难。虽然R的基准测试工具不足以测量C++代码段的执行时间,但C++的原生性能分析工具往往学习曲线陡峭。rcpptimer包通过在Rcpp生态系统中提供一种简单高效的C++代码计时解决方案,弥补了这一差距。这一新颖的包引入了一个用户友好的tic-toc类,支持重叠和嵌套计时器以及OpenMP并行性,提供纳秒级的时间分辨率。包括汇总统计在内的结果可无缝传回R,无需用户编写任何C++代码。本文在R和C++性能分析工具的更广泛生态系统中对rcpptimer包进行了定位,解释了其开发背后的动机,并全面概述了其实现。作为本文的补充,我们提供了多个小插曲,详细说明了该包的用法。

英文摘要:

Efficient code writing is both a critical and challenging task, especially with the growing demand for computationally intensive algorithms in statistical and machine-learning applications. Despite the availability of significant computational power today, the need for optimized algorithm implementations remains crucial. Many R users rely on Rcpp to write performant code in C++, but writing and benchmarking C++ code presents its own difficulties. While R's benchmarking tools are insufficient for measuring the execution times of C++ code segments, C++'s native profiling tools often come with a steep learning curve. The rcpptimer package bridges this gap by offering a simple and efficient solution for timing C++ code within the Rcpp ecosystem. This novel package introduces a user-friendly tic-toc class that supports overlapping and nested timers and OpenMP parallelism, providing nanosecond-level time resolution. Results, including summary statistics, are seamlessly passed back to R without requiring users to write any C++ code. This paper contextualizes the rcpptimer package within the broader ecosystem of R and C++ profiling tools, explains the motivation behind its development, and offers a comprehensive overview of its implementation. Supplementary to this paper, we provide multiple vignettes that thoroughly explain this package's usage.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑