Abstract
Efficient high-performance libraries often expose multiple tunable parameters to provide highly optimized routines. These can range from simple loop unroll factors or vector sizes all the way to algorithmic changes, given that some implementations can be more suitable for certain devices by exploiting hardware characteristics such as local memories and vector units. Traditionally, such parameters and algorithmic choices are tuned and then hard-coded for a specific architecture and for certain characteristics of the inputs. However, emerging applications are often data-driven, thus traditional approaches are not effective across the wide range of inputs and architectures used in practice. In this paper, we present a new adaptive framework for data-driven applications which uses a predictive model to select the optimal algorithmic parameters by training with synthetic and real datasets. We demonstrate the effectiveness of a BLAS library and specifically on its matrix multiplication routine. We present experimental results for two GPU architectures and show significant performance gains of up to 3x (on a high-end NVIDIA Pascal GPU) and 2.5x (on an embedded ARM Mali GPU) when compared to a traditionally optimized library.
Introduction
In the domain of High-Performance Computing (HPC), performance is typically achieved by meticulously tuning library routines for specific hardware targets. Developers often hard-code optimization parameters—such as loop unroll factors, vector sizes, or tiling strategies—based on what performs best for a "typical" input on a specific machine.
However, the modern "big data" landscape has challenged this static model. Applications in deep learning and graph analytics process data with unpredictable dimensions and irregular structures. A routine optimized for a standard square matrix might perform poorly on the thin, rectangular matrices common in neural network layers. Additionally, the proliferation of diverse hardware architectures, from high-end NVIDIA GPUs to embedded ARM Mali chips, makes manual tuning increasingly difficult. This paper proposes a framework for libraries that adapt their strategy dynamically based on the actual data being processed.
Methodology
The authors propose a "model-driven" framework that replaces traditional heuristics with predictive machine learning. The focus is on the General Matrix Multiplication (GEMM) routine within the CLBlast library. The workflow is divided into two phases: offline training and online deployment.
Offline Phase
The system utilizes an exhaustive tuner (CLTune) to identify the optimal configurations for thousands of different matrix dimension combinations on a target device. This data is then used to train a Decision Tree classifier (using the CART algorithm). The input features are the matrix dimensions ($M, N, K$), and the labels are the optimal tuning parameters.
Online Phase
The learned decision tree is converted into a simple, nested if-then-else C++ statement and compiled directly into the library. When a program calls GEMM, the library traverses this tree to select the best-fit routine for the specific input dimensions. This process is extremely efficient, with runtime overhead typically under 1%.
Implementation Details
The GEMM routine involves many tunable parameters, such as tiling and unrolling factors, which significantly impact performance. The framework's ability to select these parameters dynamically allows it to exploit hardware characteristics like local memories and vector units more effectively than static configurations.
The framework was evaluated using three datasets to study the impact of training data density:
- AntonNet: Real-world matrix dimensions from popular deep learning models (e.g., AlexNet, GoogLeNet).
- go2 (Grid of Two): A synthetic dataset with regular spacing.
- po2 (Power of Two): A synthetic dataset consisting of dimensions that are powers of two.
Results and Discussion
The model-driven approach demonstrates significant performance improvements across different architectures. On an NVIDIA Tesla P100, the framework achieved speedups of up to 3x over the traditionally tuned version of CLBlast. On an ARM Mali-T860 embedded GPU, it delivered up to 2.5x speedups.
Key insights include:
- White-Box Simplicity: Decision trees are interpretable and can be translated into fast C++ code with negligible overhead.
- Accuracy vs. Performance: The model does not require perfect classification accuracy. Even when the model misclassifies an input, it often selects a configuration that provides performance close to the theoretical peak.
- Data Density: Models trained on denser datasets (like
go2) generally performed better, highlighting the importance of representative sampling during the offline phase.
Conclusion
This research presents a viable path toward adaptive, data-aware HPC libraries. By utilizing decision trees to select optimal tuning parameters at runtime, significant performance gains can be achieved across diverse hardware and input characteristics. Future work will address the time-intensive nature of generating training data and explore extending this approach to other complex domains such as graph analytics.
Summary updated