Reconciling Abstraction with High Performance: A MetaOCaml approach

O. Kiselyov
{"title":"Reconciling Abstraction with High Performance: A MetaOCaml approach","authors":"O. Kiselyov","doi":"10.1561/2500000038","DOIUrl":null,"url":null,"abstract":"A common application of generative programming is building highperformance computational kernels highly tuned to the problem at hand. A typical linear algebra kernel is specialized to the numerical domain (rational, float, double, etc.), loop unrolling factors, array layout and a priori knowledge (e.g., the matrix being positive definite). It is tedious and error prone to specialize by hand, writing numerous variations of the same algorithm. The widely used generators such as ATLAS and SPIRAL reliably produce highly tuned specialized code but are difficult to extend. In ATLAS, which generates code using printf, even balancing parentheses is a challenge. According to the ATLAS creator, debugging is nightmare. A typed staged programming language such as MetaOCaml lets us state a general, obviously correct algorithm and add layers of specializations in a modular way. By ensuring that the generated code always compiles and letting us quickly test it, MetaOCaml makes writing generators less daunting and more productive. The readers will see it for themselves in this hands-on tutorial. Assuming no prior knowledge of MetaOCaml and only a basic familiarity with functional programming, we will eventually implement a simple domain-specific language (DSL) for linear algebra, with layers of optimizations for sparsity and memory layout of matrices and vectors, and their algebraic properties. We will generate optimal BLAS kernels. We shall get the taste of the “Abstraction without guilt”. O. Kiselyov. Reconciling Abstraction with High Performance: A MetaOCaml approach. Foundations and Trends © in Programming Languages, vol. 5, no. 1, pp. 1–101, 2018. DOI: 10.1561/2500000038. Full text available at: http://dx.doi.org/10.1561/2500000038","PeriodicalId":376429,"journal":{"name":"Found. Trends Program. Lang.","volume":"76 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2018-06-04","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"25","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Found. Trends Program. Lang.","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1561/2500000038","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 25

Abstract

A common application of generative programming is building highperformance computational kernels highly tuned to the problem at hand. A typical linear algebra kernel is specialized to the numerical domain (rational, float, double, etc.), loop unrolling factors, array layout and a priori knowledge (e.g., the matrix being positive definite). It is tedious and error prone to specialize by hand, writing numerous variations of the same algorithm. The widely used generators such as ATLAS and SPIRAL reliably produce highly tuned specialized code but are difficult to extend. In ATLAS, which generates code using printf, even balancing parentheses is a challenge. According to the ATLAS creator, debugging is nightmare. A typed staged programming language such as MetaOCaml lets us state a general, obviously correct algorithm and add layers of specializations in a modular way. By ensuring that the generated code always compiles and letting us quickly test it, MetaOCaml makes writing generators less daunting and more productive. The readers will see it for themselves in this hands-on tutorial. Assuming no prior knowledge of MetaOCaml and only a basic familiarity with functional programming, we will eventually implement a simple domain-specific language (DSL) for linear algebra, with layers of optimizations for sparsity and memory layout of matrices and vectors, and their algebraic properties. We will generate optimal BLAS kernels. We shall get the taste of the “Abstraction without guilt”. O. Kiselyov. Reconciling Abstraction with High Performance: A MetaOCaml approach. Foundations and Trends © in Programming Languages, vol. 5, no. 1, pp. 1–101, 2018. DOI: 10.1561/2500000038. Full text available at: http://dx.doi.org/10.1561/2500000038
查看原文
分享 分享
微信好友 朋友圈 QQ好友 复制链接
本刊更多论文
协调抽象与高性能:一种元ocaml方法
生成式编程的一个常见应用是构建针对当前问题高度调优的高性能计算内核。典型的线性代数核专门用于数值域(有理数,浮点数,双精度等),循环展开因子,数组布局和先验知识(例如,矩阵是正定的)。手工专门化编写相同算法的大量变体是乏味且容易出错的。广泛使用的生成器(如ATLAS和SPIRAL)可靠地生成高度调优的专用代码,但难以扩展。在使用printf生成代码的ATLAS中,即使是平衡括号也是一个挑战。根据ATLAS创建者的说法,调试是一场噩梦。类型化的分阶段编程语言(如MetaOCaml)允许我们声明一个通用的、明显正确的算法,并以模块化的方式添加专门化层。通过确保生成的代码总是可以编译,并允许我们快速测试它,MetaOCaml使编写生成器变得不那么令人生畏,而且更有效率。读者将在这个实践教程中看到它。假设没有MetaOCaml的先验知识,只对函数式编程有基本的了解,我们最终将实现一个简单的线性代数领域特定语言(DSL),其中包含对矩阵和向量的稀疏性和内存布局及其代数属性的优化层。我们将生成最优的BLAS核。我们将体会到“无罪抽象”的滋味。o·凯瑟列夫。协调抽象与高性能:一种元ocaml方法。基础与趋势©in Programming Languages, vol. 5, no. 5。1, pp. 1 - 101, 2018。DOI: 10.1561 / 2500000038。全文可在:http://dx.doi.org/10.1561/2500000038
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 去求助
来源期刊
自引率
0.00%
发文量
0
期刊最新文献
Refinement Types: A Tutorial Progress of Concurrent Objects Reconciling Abstraction with High Performance: A MetaOCaml approach Tutorial on Static Inference of Numeric Invariants by Abstract Interpretation Computer-Assisted Query Formulation
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
现在去查看 取消
×
提示
确定
0
微信
客服QQ
Book学术公众号 扫码关注我们
反馈
×
意见反馈
请填写您的意见或建议
请填写您的手机或邮箱
已复制链接
已复制链接
快去分享给好友吧!
我知道了
×
扫码分享
扫码分享
Book学术官方微信
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术
文献互助 智能选刊 最新文献 互助须知 联系我们:info@booksci.cn
Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。
Copyright © 2023 Book学术 All rights reserved.
ghs 京公网安备 11010802042870号 京ICP备2023020795号-1