arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1109.0777cs.PL
收藏

基于模式匹配和静态类型的高效正确的模板计算

Efficient and Correct Stencil Computation via Pattern Matching and Static Typing

Dominic Orchard, Alan Mycroft

摘要:

涉及对数组元素的操作的模板计算是科学计算、游戏和图像处理中的常见编程模式。作为一种编程模式,模板计算是高度规则的,并且易于优化和并行化。然而,通用语言对编译器甚至程序员隐藏了这种规则模式,从而阻止了优化和混淆正确性。本文进一步研究了嵌入在Haskell中的用于模板计算的Ypnos域特定语言。Ypnos允许模板计算的声明式抽象规范,通过专门的语法向编译器和程序员暴露问题的结构。在本文中,我们证明了可判定的安全保证,格式良好,类型良好的Ypnos程序不能索引数组边界之外。因此,在Ypnos中索引是安全的,并且可以消除运行时边界检查。程序信息被编码为类型,使用Glasgow Haskell编译器的高级类型系统特性,在编译时通过类型检查强制执行安全索引不变式。

英文摘要:

Stencil computations, involving operations over the elements of an array, are a common programming pattern in scientific computing, games, and image processing. As a programming pattern, stencil computations are highly regular and amenable to optimisation and parallelisation. However, general-purpose languages obscure this regular pattern from the compiler, and even the programmer, preventing optimisation and obfuscating (in)correctness. This paper furthers our work on the Ypnos domain-specific language for stencil computations embedded in Haskell. Ypnos allows declarative, abstract specification of stencil computations, exposing the structure of a problem to the compiler and to the programmer via specialised syntax. In this paper we show the decidable safety guarantee that well-formed, well-typed Ypnos programs cannot index outside of array boundaries. Thus indexing in Ypnos is safe and run-time bounds checking can be eliminated. Program information is encoded as types, using the advanced type-system features of the Glasgow Haskell Compiler, with the safe-indexing invariant enforced at compile time via type checking.

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

↑