姜海韬 羊帆 陈媛媛 付继发 张辉国
摘 要:文章对R语言已有的并行计算框架进行系统分类、比较,分析了适用于基于R+MPI与基于R+Hadoop的应用场景。在此基础上,结合两者优势提出了一种基于R+MPI的优化计算环境,该环境可以使用户仅修改少量代码就可以将原有的串行程序并行执行。最后,通过一个多元线性回归模型的代码实例展示编程的便捷性,通过与现有工具包的速度比较验证了其有效性。
关键词:代码并行化;分布式算法;MPI;Hadoop;多元线性回归
中图分类号:TP312 文献标志码:A 文章编号:2095-2945(2018)23-0037-04
Abstract: In this paper, the existing parallel computing frameworks in R language are classified and compared, and the application scenarios based on R+MPI and R+Hadoop are analyzed. On this basis, and in view of the advantages of both, an optimized computing environment based on R+MPI is proposed, which enables users to execute the original serial program in parallel only by modifying a small amount of code. Finally, the convenience of programming is demonstrated by a code example of a multivariate linear regression model, and its effectiveness is verified by comparing with the speed of the existing toolkits.
Keywords: code parallelization; distributed algorithm; MPI; Hadoop; multivariate linear regression
引言
由于人们数据收集能力的提高以及“数据即资产”意识的发展,数据集的规模与维度已今非昔比。以使用二维矩阵或者表格储存的数据为例,其属性数(列数)与样本数(行数)都达到了前所未有的数量级,这使得并行编程与分布式存储与计算必然地成为了处理大数据问题的主流解决方案。
R语言是一款基于GNU协议的开源软件,致力于统计计算、数据可视化以及数据分析。该语言拥有庞大的用户社区,在数据挖掘和机器学习盛行的今天发展速度极快。对于研究较多的数学模型,CRAN或GitHub上多有现成的R语言实现。但与此同时,R语言也有自身的不足之处:R语言以单线程运行,不能发挥目前多核处理器的全部计算能力;对于单台计算机内存无法存储的数据集,R语言无法直接处理。这些问题的解决方案之一是将R语言与其他辅助软件结合使用。
Message Passing Interface(MPI)是一个基于Socket的跨语言通讯协议,用于编写高性能的并行程序。……