[Paper Review] Fusion of Array Operations at Runtime
This paper introduces the Weighted Subroutine Partition (WSP) problem, a unified framework for fusing array operations, loops, and combinators at runtime by modeling fusion as a graph partitioning problem with customizable cost functions. It proposes a branch-and-bound algorithm for optimal fusion and a fast greedy approximation suitable for JIT compilation, demonstrating significant speedups (2x–30x) in 15 benchmarks, with minimal performance difference between optimal and approximate methods.
We address the problem of fusing array operations based on criteria such as shape compatibility, data reusability, and communication. We formulate the problem as a graph partition problem that is general enough to handle loop fusion, combinator fusion, and other types of subroutines.
Motivation & Objective
- To unify loop fusion, array operation fusion, and combinator fusion under a single formal framework.
- To model fusion decisions using a flexible cost function that captures data locality, memory access, communication, and other optimization objectives.
- To develop efficient algorithms—both optimal and approximate—that can be used in Just-In-Time (JIT) compilation for high-performance computing.
- To evaluate the impact of different cost models and fusion strategies on real-world benchmarks.
- To demonstrate that fast approximation algorithms can achieve most of the performance gains of optimal methods.
Proposed method
- Formalize the fusion problem as a Weighted Subroutine Partition (WSP) problem on a mixed graph, where vertices represent subroutines, directed edges encode dependencies, and undirected edges encode fusibility constraints.
- Define a monotonic cost function that penalizes data accesses, memory usage, and communication, with fusion being cost-neutral or beneficial.
- Prove that WSP is NP-hard, justifying the need for efficient algorithms.
- Implement a branch-and-bound algorithm to compute optimal fusion partitions, with pruning based on cost bounds.
- Design a greedy approximation algorithm that runs in under 20 iterations per JIT compilation, amortizing overhead.
- Integrate all algorithms into the Bohrium framework to evaluate fusion on 15 real-world benchmarks with varying cost models.
Experimental results
Research questions
- RQ1Can a single formalism unify loop fusion, array operation fusion, and combinator fusion under a common optimization framework?
- RQ2How does the inclusion of a customizable cost function affect the expressiveness and performance of fusion strategies?
- RQ3What is the trade-off between optimal fusion (via branch-and-bound) and fast approximation (via greedy algorithm) in terms of performance and compilation overhead?
- RQ4How do different cost models—such as Max Locality, Max Contract, and Robinson—compare in practice across diverse benchmarks?
- RQ5To what extent do approximation algorithms achieve performance close to optimal solutions in real-world workloads?
Key findings
- The WSP formulation successfully unifies loop, array, and combinator fusion under a single graph partitioning model with customizable cost functions.
- The branch-and-bound algorithm found optimal solutions for 10 out of 15 benchmarks within reasonable time, validating its feasibility for compilation.
- The greedy approximation algorithm achieved near-optimal performance in practice, with only a 1.3x speedup difference on the best-case benchmark (Game of Life) compared to the optimal method.
- Approximation algorithms provided most of the performance gains, indicating that further optimization toward exactness yields diminishing returns.
- The Max Contract cost model uniquely maximized array contractions in cases where other models prioritized data locality at the expense of contraction opportunities.
- Overall, fusion reduced data accesses and improved performance by 2x to 30x across benchmarks, with minimal differences between cost models in most cases.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.