TL;DR
This paper introduces Apophenia, a system that automatically identifies and traces repetitive computational patterns in task-based runtime systems. By eliminating the need for manual programmer annotations, Apophenia significantly improves the performance of complex, composable applications and makes tracing accessible to a wider range of programs.
What Problem Does This Paper Address?
Implicitly parallel task-based runtime systems are designed to automatically extract parallelism from sequential code. A key technique to boost their performance is "tracing," where the results of expensive dependency analysis for recurring program fragments are memoized and reused. However, existing tracing methods require manual annotations by programmers, which is brittle, error-prone, and difficult to manage in complex, modular applications built from independent components. This manual burden limits the adoption of tracing and hinders the performance gains it offers, especially for applications with small task granularities that can't amortize the analysis cost.
Methods
Apophenia acts as a "JIT compiler" for the dependency analysis in task-based runtime systems. Its core innovation is the automatic identification of these repetitive program fragments, or "traces." This is achieved through a novel approach that analyzes the stream of tasks issued by the application. Instead of relying on code structure (like basic blocks), Apophenia uses a series of dynamic string analysis techniques. It first converts tasks and their arguments into hash tokens to create a stream of "tokens." Then, it employs a specialized algorithm (Algorithm 2) that leverages suffix arrays and longest common prefix arrays to find non-overlapping repeated sub-strings within a buffer of these tokens. This algorithm runs in O(n log n) time, where n is the buffer size. A trace replayer then uses this information to identify and replay these automatically discovered traces, effectively bypassing the expensive dependency analysis.
Datasets
The paper evaluates Apophenia on several large-scale, production-grade scientific simulations and machine learning applications. These include:
- S3D: A combustion chemistry simulation code.
- HTR: A hypersonic aerodynamics application.
- CFD: A cuPyNumeric application solving Navier-Stokes equations.
- TorchSWE: A cuPyNumeric port of an MPI-based shallow-water equation solver.
- FlexFlow: A deep neural network framework.
The paper does not introduce new benchmarks but rather uses existing complex applications to demonstrate Apophenia's effectiveness.
Key Insights and Ideas
- Manual tracing is a bottleneck: The need for manual annotations is a significant barrier to adopting performance-enhancing tracing techniques in complex, composable software.
- String analysis for task streams: The core idea of treating task streams as strings and applying advanced string matching algorithms is a powerful way to discover repetitive patterns without relying on program structure.
- Automatic trace identification is feasible and effective: Apophenia demonstrates that it's possible to automatically find traces that are comparable in performance to manually traced code, and even outperform untraced code significantly.
- Balancing exploration and exploitation: Apophenia's trace replayer intelligently balances discovering new traces (exploration) with replaying known, high-performing traces (exploitation) to optimize performance over time.
- Sub-quadratic trace finding is crucial: For large task streams, an efficient O(n log n) algorithm for finding repeated sub-strings is essential to avoid quadratic complexity.
Key Results
Apophenia achieves performance comparable to manually traced programs, often within 0.92x-1.03x of the performance. Crucially, it enables significant speedups for previously untraced programs, ranging from 0.91x to 2.82x on the Perlmutter and Eos supercomputers. For example, on TorchSWE, Apophenia achieved nearly perfect scalability on 64 GPUs, yielding up to a 2.82x speedup. The overhead for task launches introduced by Apophenia is minimal (7µs vs. 12µs), and this overhead is hidden by the asynchronous runtime architecture.
Limitations and Future Work
- Speculation: Apophenia does not currently employ speculation for trace prediction. The authors found that the potential upside of speculation was not worth the implementation complexity given the relative costs of Legion's pipeline stages.
- Distributed analysis coordination: While Apophenia aims for deterministic trace decisions across nodes, the asynchronous nature of its analysis jobs can lead to temporary divergence. They resolve this by having nodes agree on a count of processed operations before ingesting analysis results.
- Future work: The paper suggests that Apophenia's ideas can be applied to other task-based runtime systems. Further exploration of speculation and more advanced trace prediction could be beneficial. The authors also note that while their algorithm finds good solutions, it doesn't guarantee an optimal solution to the trace selection problem.
Summary updated