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

Sham:一种用于快速DSL的DSL

Sham: A DSL for Fast DSLs

Rajan Walia, Chung-chieh Shan, Sam Tobin-Hochstadt

摘要:

领域特定语言(DSL)被吹捧为易于嵌入程序和易于优化。然而,这些目标往往处于紧张状态。嵌入式或内部DSL自然适合宿主语言,同时继承宿主的性能特征。外部DSL可以使用外部优化器和语言,但与主机分开。我们提出了Sham,一个旨在使内部DSL具有高性能的工具包。Sham提供了一种特定于域的语言(嵌入在Racket中),用于实现其他高性能DSL,并在运行时透明编译为汇编代码。Sham非常适合作为其他嵌入式DSL的编译目标,也非常适合用更快的版本透明地替换DSL支持代码。Sham提供了与其宿主语言的无缝互操作,而无需用户进行任何额外的工作。Sham还提供了一个定义语言语法的框架,该框架也实现了Sham自己的语言接口。我们验证了一系列的案例研究,从克里希那穆提的经典自动机DSL的声音合成DSL和概率程序设计语言的设计。所有这些都是现有的DSL,我们使用Sham替换了后端,从而获得了重大的性能提升。我们提出了一个例子驱动的说明如何骗可以顺利地提高现有的DSL到一个高性能的。与现有的实现高性能DSL的方法相比,Sham的设计旨在简化和程序员控制。这使得将我们的技术移植到其他语言和框架更容易,或者借用Sham的创新“点菜”而不采用整个方法。Sham构建了一个复杂而强大的DSL构造工具包,它基于基本的语言功能,包括高阶函数、数据结构和外部函数接口(FFI),所有这些都可以在其他语言中使用。此外,Sham的方法允许DSL开发人员简单地编写函数,无论是使用Sham还是生成Sham,而不需要通过复杂的阶段或部分评估系统。

英文摘要:

Domain-specific languages (DSLs) are touted as both easy to embed in programs and easy to optimize. Yet these goals are often in tension. Embedded or internal DSLs fit naturally with a host language, while inheriting the host's performance characteristics. External DSLs can use external optimizers and languages but sit apart from the host. We present Sham, a toolkit designed to enable internal DSLs with high performance. Sham provides a domain-specific language (embedded in Racket) for implementing other high-performance DSLs, with transparent compilation to assembly code at runtime. Sham is well suited as both a compilation target for other embedded DSLs and for transparently replacing DSL support code with faster versions. Sham provides seamless inter-operation with its host language without requiring any additional effort from its users. Sham also provides a framework for defining language syntax which implements Sham's own language interface as well. We validate Sham's design on a series of case studies, ranging from Krishnamurthi's classic automata DSL to a sound synthesis DSL and a probabilistic programming language. All of these are existing DSLs where we replaced the backend using Sham, resulting in major performance gains. We present an example-driven description of how Sham can smoothly enhance an existing DSL into a high-performance one. When compared to existing approaches for implementing high-performance DSLs, Sham's design aims for both simplicity and programmer control. This makes it easier to port our techniques to other languages and frameworks, or borrow Sham's innovations "à la carte" without adopting the whole approach. Sham builds a sophisticated and powerful DSL construction toolkit atop fundamental language features including higher-order functions, data structures, and a foreign-function interface (FFI), all readily available in other languages. Furthermore, Sham's approach allows DSL developers to simply write functions, either using Sham or generating Sham, without needing to work through complex staging or partial evaluation systems.

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

↑