论文标题

假:快速DSL的DSL

Sham: A DSL for Fast DSLs

论文作者

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

论文摘要

特定于域的语言(DSL)被吹捧为易于嵌入程序又易于优化。然而,这些目标通常是紧张的。嵌入或内部DSL自然符合宿主语言,同时继承主机的性能特征。外部DSL可以使用外部优化器和语言,但与主机分开。我们提出了Sham,这是一种工具包,旨在使内部DSL具有高性能。 Sham提供了一种特定于域的语言(嵌入了球拍中),用于实现其他高性能DSL,并在运行时透明地汇编对汇编代码。 Sham非常适合作为其他嵌入式DSL的汇编目标,也是用更快的版本透明地替换DSL支持代码的汇编目标。 Sham提供了无缝的互操作与主机语言的无缝互操作,而无需用户提供任何额外的努力。 Sham还提供了定义语言语法的框架,该语言也实现了Sham自己的语言界面。我们在一系列案例研究中验证了Sham的设计,从Krishnamurthi的经典自动机DSL到声音综合DSL和概率编程语言。所有这些都是现有的DSL,我们使用假手术替换了后端,从而导致了重大的性能增长。我们提供了一个示例驱动的描述,说明假方法如何将现有的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.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源