A Brief Reading of GroupTuner: Efficient Group-Aware Compiler Auto-tuning
English (current) | 简体中文
Preface
As a CSIS student, my Final Year Project (FYP) focuses on Compiler Flag Optimisation using Machine Learning, an interdisciplinary field combining machine learning and computer science. Following the timeline, extensive preparatory work will be conducted during the autumn semester, including literature review, knowledge accumulation, and project proposal, among others.
This document records the progress of the entire FYP for future reference and knowledge consolidation.
Currently, there are ten papers in my reading list, and I’ve decided to start with this one, which was specifically assigned by my supervisor.
Background
Machine learning-based compiler flag optimization is not an emerging field. The 2018 paper A Survey on Compiler Autotuning using Machine Learning outlined various historical approaches to compiler optimization. From then until now, numerous methods have been proposed to find optimal parameter combinations, including Bayesian classifiers and more modern LLM-based optimizations. These methods invariably aim to identify combinations from hundreds of flags that minimize execution time, thus sharing common limitations. Exhaustively traversing all possible parameter combinations would require more time than there are atoms in the universe - their iteration count is inherently limited. This leads to sparse, noisy data that ultimately results in local optima.
The approach proposed in this paper involves grouping all compiler functionalities into multiple clusters, placing parameters of related functionalities into the same group. This process is actually much more complex, involving analysis of GCC source code to group options that are either invoked in the same compilation pass or functionally tightly coupled. For example, all code alignment-related options (-falign-loops, -falign-jumps, -falign-functions) are grouped together, as they all serve the common goal of “alignment.”

Option Grouping
This involves static grouping - since not all parameter combinations are meaningful, dynamic grouping would only add complexity while ensuring granularity remains within acceptable ranges.
Specifically, there are three steps:
-
Flag-pass mapping: The authors use a static analysis tool called CodeQL to analyze GCC source code. This identifies which compilation optimization pass each compiler flag is used in, establishing associations between options and passes. All options belonging to the same pass are initially grouped together.
-
Merge overlapping groups: After initial grouping, the authors found that some options affect multiple passes, causing overlaps between different groups. To ensure that closely associated options are grouped together, they merge all groups with overlapping options into larger groups.
-
Assign leftover options: After merging, some options still belong to independent, non-overlapping passes. To avoid overly fine-grained grouping, the authors assign these “leftover” options to the nearest existing groups based on the execution order of these passes in the GCC compilation pipeline.
The “nearest existing group” concept in the original paper is somewhat abstract. Based on my understanding, it refers to passes with similar positions in the compilation process. The gcc/passes.def file defines the execution order of all optimization passes. Suppose we have created two “option groups” based on pass_A and pass_D. Now there’s a “leftover option” belonging to pass_C. In execution order, pass_C is “closer” to pass_D than to pass_A. Therefore, this leftover option belonging to pass_C would be assigned to the group containing pass_D.
Through this purely static process based on GCC internal structure analysis, the authors divided 206 optimization options into 15 functionally cohesive groups.
Group-Aware Mutation Search
Initialization
The authors start with -O3 optimization as the baseline and perform group-level random mutations to generate n initial candidate combinations, placing them in a “candidate list” (candidate_list).
Note that this differs somewhat from typical compiler options usage. For rigorous, automated scientific research, the on/off state of each option must be explicitly specified rather than relying on compiler defaults. Therefore, GroupTuner is actually a state vector model based on internal state representation - this took me considerable time to understand.
All sequences in the candidate list undergo performance testing, with the highest-scoring sequence selected as the best sequence.
History-Based Search
A sequence is randomly selected from the candidate list as the base sequence, then a group is randomly chosen for random toggling of its internal options, while all other groups remain unchanged. The performance of the new sequence is then evaluated using a simulated annealing-based approach. Specifically, if the new sequence outperforms the worst one in the candidate list, it directly replaces the worst. If the new combination performs worse than the worst, the algorithm accepts it with a specific probability that decreases as the “temperature” decreases. This helps the algorithm escape local optima.
Through continuous iteration, the final best sequence represents the optimal option combination.
The paper subsequently discusses superior performance and execution time compared to other methods, which I won’t elaborate on here. My consideration is: what insights does this offer for the FYP?
The project requires using GA/RL methods to predict Cbench scores for compiler options. I have the following hypotheses, to be validated after specific requirements are released:
-
Perhaps instead of having the model directly learn the impact of 206 independent options, it could learn the influence of these 15 “feature groups.” This might significantly reduce the model’s learning difficulty.
-
If using GA, standard mutation randomly flips any gene (flag) on the chromosome, while a new operator could be modified to: randomly select a “gene group” (i.e., an option group) and only perform gene flipping within this group, potentially making the evolution process more directional.
References
B. Gao, M. Yao, Z. Wang, D. Liu, D. Li, X. Chen, and Y. Guo, “Grouptuner: Efficient Group-Aware Compiler Auto-tuning,” in
Proceedings of the 26th ACM SIGPLAN/SIGBED International Conference on Languages, Compilers, and Tools for Embedded Systems (LCTES ‘25), Seoul, Republic of Korea, 2025, doi: 10.1145/3735452.3735530.