arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2409.07950cs.PLcs.PF
收藏

Repr Types:一种统御所有类型的抽象

Repr Types: One Abstraction to Rule Them All

Viktor Palmkvist, Anders Ågren Thuné, Elias Castegren, David Broman

AI总结:

针对主流编译器无法高层优化抽象类型表示、现有方案可扩展性受限的问题,提出基于内置$\texttt{repr}$类型和带成本标注函数重载的方法,实现无限制的表示灵活数据类型,经集合与图库验证可显著提升程序性能。

摘要:

抽象类型的表示方式选择会对程序性能产生重大影响,但主流编译器无法在如此高的层级上执行优化。在处理数据类型表示的优化时,一个重要特性是具备可扩展的表示灵活数据类型:即程序员无需修改编译器或预先定义的库,就能添加新的抽象类型、操作以及这些类型的具体实现的能力。许多研究项目通过静态分析、插桩或基准测试支持高层优化,但它们至少在可扩展性的某一方面存在限制。\n 本文提出了一种无此类限制、且仍能找到高效优化方案的表示灵活数据类型新方法。我们的方法以单个内置类型$\texttt{repr}$和带有操作实现成本标注的函数重载为核心。我们通过两方面评估该方法:(1)将通用集合类型定义为一个库,用单一类型涵盖所有常规集合;(2)设计并实现一个表示灵活的图库。只要编译器能为所有操作找到合适的实现,使用$\texttt{repr}$类型的程序通常比采用惯用表示选择的程序运行速度更快,有时提升幅度极大。我们的编译器能快速找到优化解,并复用先前结果避免重复计算,从而高效执行分析。

英文摘要:

The choice of how to represent an abstract type can have a major impact on the performance of a program, yet mainstream compilers cannot perform optimizations at such a high level. When dealing with optimizations of data type representations, an important feature is having extensible representation-flexible data types; the ability for a programmer to add new abstract types and operations, as well as concrete implementations of these, without modifying the compiler or a previously defined library. Many research projects support high-level optimizations through static analysis, instrumentation, or benchmarking, but they are all restricted in at least one aspect of extensibility. This paper presents a new approach to representation-flexible data types without such restrictions and which still finds efficient optimizations. Our approach centers around a single built-in type $\texttt{repr}$ and function overloading with cost annotations for operation implementations. We evaluate our approach (i) by defining a universal collection type as a library, a single type for all conventional collections, and (ii) by designing and implementing a representation-flexible graph library. Programs using $\texttt{repr}$ types are typically faster than programs with idiomatic representation choices -- sometimes dramatically so -- as long as the compiler finds good implementations for all operations. Our compiler performs the analysis efficiently by finding optimized solutions quickly and by reusing previous results to avoid recomputations.

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

↑