Introduction
In the realm of High-Performance Computing (HPC), optimizing code requires a deep understanding of how software interacts with hardware. This is traditionally achieved through Hardware Performance Counters (HwPCs)—specialized registers within CPUs and GPUs that track low-level events such as cache misses, branch mispredictions, and floating-point operations.
However, modern architectures present a significant challenge: while they expose hundreds of potential HwPCs, they typically only possess a small number of physical registers (often 4 to 8) capable of reading these counters simultaneously. This limitation forces developers into a difficult choice: either re-execute the application multiple times to collect all necessary metrics—a process that is prohibitively slow and expensive—or use "multiplexing," which swaps counters during execution but severely degrades measurement precision. This paper addresses this bottleneck by introducing a fully automated, machine learning-based pipeline designed to identify the absolute minimum set of HwPCs required to accurately characterize code regions.
Methodology
The proposed solution is an architecture-agnostic pipeline that utilizes an ensemble of supervised Machine Learning (ML) models to rank and reduce HwPCs. Unlike previous manual approaches using Principal Component Analysis (PCA) or correlation studies, this method is designed to scale across diverse hardware and massive datasets without human intervention.
The methodology follows a rigorous three-step process:
- Ensemble Training and Validation: The system trains four distinct ML models: Logistic Regression with Elastic Net, Random Forest, XGBoost, and TabNet. This ensemble approach is critical because it captures both linear and complex non-linear relationships between hardware events and code behavior, ensuring robustness regardless of the dataset size or hardware architecture.
- Weighted Feature Extraction: Each model in the ensemble generates importance scores for every available HwPC. To ensure the most reliable models have the most influence, the pipeline calculates a weighted average of these scores based on each model's validation accuracy.
- Knee-Point Reduction: After ranking the HwPCs by their weighted importance, the system employs an iterative process. It adds one HwPC at a time to a training set and monitors the resulting classification accuracy. The process stops at the "knee point"—the mathematical threshold where the addition of further counters yields diminishing returns in accuracy.
Ensemble Weighting and Feature Importance
A core innovation of this work is the automated weighting mechanism. By combining tree-based models (XGBoost and Random Forest) with neural networks (TabNet) and linear models, the pipeline can adapt to the specific characteristics of the profiling data.
As shown in the importance extraction phase, models that achieve higher accuracy on the validation set are granted higher weights. This ensures that if a linear model fails to capture the nuances of a specific GPU architecture, its lower accuracy will naturally reduce its influence on the final selection of counters, allowing more capable non-linear models to lead the reduction process.
Experimental Evaluation and Results
The methodology was validated across multiple CPU and GPU architectures, demonstrating its ability to achieve extreme dimensionality reduction without sacrificing classification precision.
- CPU Performance: On a Xeon E5-4620 dataset featuring over 12 million configurations across 18 different kernels, the pipeline reduced 50 available HwPCs down to just 6, maintaining a 96.95% classification accuracy. In a baseline test against manual PCA methods on a Xeon E5645, the automated system reduced 58 counters to 5 with 99.20% accuracy.
- GPU Performance: The results on GPU architectures were even more striking. On the NVIDIA Pascal architecture, the system reduced a staggering 167 available HwPCs down to just 4, while maintaining 99.81% accuracy. On the Kepler architecture, the set was reduced to 3 counters with 99.94% accuracy.
Conclusion and Future Work
This research proves that extreme dimensionality reduction in hardware profiling is not only possible but can be fully automated. By identifying a "fingerprint" of just 3 to 6 counters, developers can characterize complex parallel code regions in a single execution run with high precision.
While the current work focuses on classification—identifying which code region is running—future efforts are directed toward regression. The goal is to use these reduced HwPC sets to predict performance and automatically tune application parameters in real-time. This would enable a new generation of self-optimizing software capable of adapting to hardware constraints on the fly.
Summary updated