一句话:提出 Fern,通过轻量级声明暴露数据依赖模式,在保持模块性的同时融合黑盒子程序,最高加速 5 倍。
子程序是软件设计的基本构件,但组合调用会在边界处降低局部性并增加内存开销,造成性能损失。算子融合可恢复此类损失,而现有方法要么手工将代码改写成单块融合子程序,要么依赖重量级编译器生成融合代码,均需理解整个计算语义,破坏模块性与复用性。本文寻找融合所需的最小要素,发现多数融合机会只需理解数据的生产与消费模式。基于此,论文对子程序声明做轻量级增强以暴露数据依赖模式,在黑盒子程序之上实现融合,并构建系统 Fern。评估表明,Fern 能与手工融合的最先进高性能库竞争,可跨库和领域边界融合未预见工作负载,相对未融合代码取得最高 5 倍加速。
Subroutines are essential building blocks in software design: users encapsulate common functionality in libraries and write applications by composing calls to subroutines. Unfortunately, performance may be lost at subroutine boundaries due to reduced locality and increased memory consumption. Operator fusion helps recover the performance lost at composition boundaries. Previous solutions fuse operators by manually rewriting code into monolithic fused subroutines, or by relying on heavy-weight compilers to generate code that performs fusion. Both approaches require a semantic understanding of the entire computation, breaking the decoupling necessary for modularity and reusability of subroutines. In this work, we attempt to identify the minimal ingredients required to fuse computations, enabling composition of subroutines without sacrificing performance or modularity. We find that, unlike previous approaches that require a semantic understanding of the computation, most opportunities for fusion require understanding only data production and consumption patterns. Exploiting this insight, we add fusion on top of black-box subroutines by proposing a lightweight enrichment of subroutine declarations to expose data-dependence patterns. We implement our approach in a system called Fern, and demonstrate Fern’s benefits by showing that it is competitive with state-of-the-art, high-performance libraries with manually fused operators, can fuse across library and domain boundaries for unforeseen workloads, and can deliver speedups of up to 5× over unfused code.
@article{paperbot3067,
title = {Lightweight and Locality-Aware Composition of Black-Box Subroutines},
author = {Manya Bansal and Dillon Sharlet and Jonathan Ragan-Kelley and Saman Amarasinghe},
journal = {Proceedings of the ACM on Programming Languages},
volume = {9},
number = {PLDI},
year = {2025},
doi = {10.1145/3729292}
}