Introduction
In the realm of General-Purpose GPU (GPGPU) programming, performance is highly sensitive to the characteristics of the input data. A code transformation that yields peak performance for a small dataset may prove disastrously inefficient for a larger one. To address this, the Futhark compiler employs "incremental flattening," a technique that generates multiple semantically equivalent versions of a program, each optimized for different degrees of nested parallelism.
The Challenge: Composition and Selection
The core difficulty lies in composition: how can a compiler build a single executable that dynamically selects the most efficient code version at runtime? Traditionally, this selection is governed by "thresholds"—parameters that determine when to switch from one parallel strategy to another.
Existing solutions often rely on general-purpose autotuners like OpenTuner. These tools treat the program as a "black box," using stochastic (randomized) search algorithms to explore the parameter space. However, this approach is frequently slow, unpredictable, and fails to exploit the underlying structure of the compiled code, often missing optimal configurations or failing to handle memory-constrained environments.
Methods: Leveraging the Tuning Forest
Researchers at the University of Copenhagen have proposed a more integrated approach: a "tighter compiler-autotuner co-design." Instead of a black-box search, their autotuner leverages the tuning forest, a hierarchical structure of code versions produced by the compiler.
The fundamental insight of this work is the Monotonicity Assumption. The authors posit that if a specific code version (e.g., one exploiting more complex nested parallelism) outperforms another for a given data size, it will likely remain the superior choice as the data size increases. This assumption allows the tuning process to be restructured as a deterministic search:
- Bottom-Up Tuning: The system tunes thresholds individually, starting from the leaves of the tuning tree and moving upward.
- Binary Search for Cross-over Points: For code where parallelism varies during execution (size-variant code), the tuner uses binary search to pinpoint the exact "cross-over point" where one version becomes more efficient than another.
- Interval Intersection: The tuner calculates optimal intervals for multiple datasets independently and then intersects these intervals to find a global configuration. If the intersection is empty, it alerts the developer to a failure in the monotonicity assumption or a need for better code generation.
Experimental Evaluation
The proposed method was evaluated against a suite of real-world applications and standard benchmarks, including:
- Heston and BFAST: Real-world applications for financial calibration and satellite imagery analysis.
- FinPar and Rodinia: Standard benchmark suites for financial and general GPGPU tasks.
- LUD: A benchmark for LU matrix factorization characterized by size-variant parallelism.
Key Results
The results demonstrate significant improvements over industry-standard stochastic tuners:
- Tuning Efficiency: The deterministic approach was 6.4x faster on average than OpenTuner. For the Heston benchmark, the speedup reached 22.6x, reducing tuning time from over an hour to less than three minutes.
- Execution Speed: In nearly half of the test cases, the programs tuned with this method were significantly faster than those tuned by OpenTuner, with performance gains of up to 10x in some instances.
- Robustness: The tool successfully handled the BFAST benchmark on large datasets where OpenTuner failed due to out-of-memory (OOM) errors, demonstrating superior navigation of hardware constraints.
Conclusion and Future Work
By replacing stochastic search with a compiler-aware, deterministic strategy based on monotonicity, the researchers have created a more efficient and reproducible autotuning pipeline for Futhark. While the current method is optimized for parallelism and load-balancing thresholds, it is not yet suitable for non-monotonic parameters like tile sizes. Future research aims to extend this logic to "piece-wise" monotonicity, potentially allowing the compiler to handle even more complex performance landscapes while maintaining the speed and reliability of the current approach.
Summary updated