Skip to main content
Log in

Tsoa: a two-stage optimization approach for GCC compilation options to minimize execution time

  • Published:
Automated Software Engineering Aims and scope Submit manuscript

Abstract

The open-source compiler GCC offers numerous options to improve execution time. Two categories of approaches, machine learning-based and design space exploration, have emerged for selecting the optimal set of options. However, they continue to face challenge in quickly obtaining high-quality solutions due to the large and discrete optimization space, time-consuming utility evaluation for selected options, and complex interactions among options. To address these challenges, we propose TSOA, a Two-Stage Optimization Approach for GCC compilation options to minimize execution time. In the first stage, we present OPPM, an Option Preselection algorithm based on Pattern Mining. OPPM generates diverse samples to cover a wide range of option interactions. It subsequently mines frequent options from both objective-improved and non-improved samples. The mining results are further validated using CRC codes to precisely preselect options and reduce the optimization space. Transitioning to the second stage, we present OSEA, an Option Selection Evolutionary optimization Algorithm. OSEA is grounded in solution preselection and an option interaction graph. The solution preselection employs a random forest to build a classifier, efficiently identifying promising solutions for the next-generation population and thereby reducing the time spent on utility evaluation. Simultaneously, the option interaction graph is built to capture option interplays and their influence on objectives from evaluated solutions. Then, high-quality solutions are generated based on the option interaction graph. We evaluate the performance of TSOA by comparing it with representative machine learning-based and design space exploration approaches across a diverse set of 20 problem instances from two benchmark platforms. Additionally, we validate the effectiveness of OPPM and conduct related ablation experiments. The experimental results show that TSOA outperforms state-of-the-art approaches significantly in both optimization time and solution quality. Moreover, OPPM outperforms other option preselection algorithms, while the effectiveness of random forest-assisted solution preselection, along with new solution generation based on the option interaction graph, has been verified.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Algorithm 1
Algorithm 2
Algorithm 3
Fig. 2
Algorithm 4
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9
Fig. 10
Fig. 11

Similar content being viewed by others

Data Availability

We have published all the raw and generated data on GitHub at https://github.com/YuanJieLai/.github.io.git. The data is organized according to the structure of the experimental results section.

References

  • Agakov, F., Bonilla, E., Cavazos, J., Franke, B., Fursin, G., O’Boyle, M.F., Thomson, J., Toussaint, M., Williams, C.K.: Using machine learning to focus iterative optimization. In: International Symposium on Code Generation and Optimization (CGO’06), pp. 11–pp. IEEE (2006)

  • Asher, Y.B., Haber, G., Stein, E.: A study of conflicting pairs of compiler optimizations. In: 2017 IEEE 11th International Symposium on Embedded Multicore/Many-core Systems-on-Chip (MCSoC), pp. 52–58. IEEE (2017)

  • Ashouri, A..H., Killian, W., Cavazos, e.a: A survey on compiler autotuning using machine learning. ACM Comput. Surv. (CSUR) 51(5), 1–42 (2018)

    Article  Google Scholar 

  • Ashouri, A.H., Mariani, G., Palermo, G., Park, E., Cavazos, J., Silvano, C.: Cobayn: compiler autotuning framework using Bayesian networks. ACM Trans. Arch. Code Optim. (TACO) 13(2), 1–25 (2016)

    Article  Google Scholar 

  • Ashouri A.H., P.G.C.J.S.C.: Selecting the best compiler optimizations: A bayesian network approach. In: Automatic Tuning of Compilers Using Machine Learning, pp. 41–70. Springer (2017)

  • Bajpai, V., Gorthi, R.P.: On non-functional requirements: A survey. In: 2012 IEEE Students’ Conference on Electrical, Electronics and Computer Science, pp. 1–4. IEEE (2012)

  • Blackmore, C., Ray, O., Eder, K.: Automatically tuning the gcc compiler to optimize the performance of applications running on embedded systems. arXiv preprint arXiv:1703.08228 (2017)

  • Cavazos, J., Fursin, G., Agakov, F., Bonilla, E., O’Boyle, M.F., Temam, O.: Rapidly selecting good compiler optimizations using performance counters. In: International Symposium on Code Generation and Optimization (CGO’07), pp. 185–197. IEEE (2007)

  • CBench: https://ctuning.org/wiki/index.php/ctools:cbench (2020)

  • Cervantes, J., Garcia-Lamont, F., Rodríguez-Mazahua, L., Lopez, A.: A comprehensive survey on support vector machine classification: applications, challenges and trends. Neurocomputing 408, 189–215 (2020)

    Article  Google Scholar 

  • Chen, J., Xu, N., Chen, P., Zhang, H.: Efficient compiler autotuning via bayesian optimization. In: 2021 IEEE/ACM 43rd International Conference on Software Engineering (ICSE), pp. 1198–1209. IEEE (2021)

  • Davidson, J.W., Tyson, G.S., Whalley, D.B., Kulkarni, P.A.: Evaluating heuristic optimization phase order search algorithms. In: International Symposium on Code Generation and Optimization (CGO’07), pp. 157–169. IEEE (2007)

  • Demšar, J.: Statistical comparisons of classifiers over multiple data sets. J. Mach. Learn. Res. 7, 1–30 (2006)

    MathSciNet  Google Scholar 

  • Fursin, G.: Collective tuning initiative: automating and accelerating development and optimization of computing systems. In: GCC Developers’ Summit (2009)

  • Fursin, G., Kashnikov, Y., Memon, A..W., Chamski, Z., Temam, O., Namolaru, e.a: Milepost GCC: machine learning enabled self-tuning compiler. Int. J. Parallel Prog. 39, 296–327 (2011)

    Article  Google Scholar 

  • Garciarena, U., Santana, R.: Evolutionary optimization of compiler flag selection by learning and exploiting flags interactions. In: Proceedings of the 2016 on Genetic and Evolutionary Computation Conference Companion, pp. 1159–1166 (2016)

  • Georgiou, K., Blackmore, C., Xavier-de Souza, S., Eder, K.: Less is more: Exploiting the standard compiler optimization levels for better performance and energy consumption. In: Proceedings of the 21st International Workshop on Software and Compilers for Embedded Systems, pp. 35–42 (2018)

  • Glek, T., Hubicka, J.: Optimizing real world applications with GCC link time optimization. arXiv preprint arXiv:1010.2196 (2010)

  • Glinz, M.: On non-functional requirements. In: 15th IEEE international requirements engineering conference (RE 2007), pp. 21–26. IEEE (2007)

  • Kulkarni, P., Hines, S., Hiser, J., Whalley, D., Davidson, J., Jones, D.: Fast searches for effective optimization phase sequences. ACM SIGPLAN Not. 39(6), 171–182 (2004)

    Article  Google Scholar 

  • Kulkarni, P.A., Hines, S.R., Whalley, D.B., Hiser, J.D., Davidson, J.W., Jones, D.L.: Fast and efficient searches for effective optimization-phase sequences. ACM Trans. Arch. Code Optim. (TACO) 2(2), 165–198 (2005)

    Article  Google Scholar 

  • Leather, H., Cummins, C.: Machine learning in compilers: past, present and future. In: 2020 Forum for Specification and Design Languages (FDL), pp. 1–8. IEEE (2020)

  • Lin, S.C., Chang, C.K., Lin, N.W.: Automatic selection of GCC optimization options using a gene weighted genetic algorithm. In: 2008 13th Asia-Pacific Computer Systems Architecture Conference, pp. 1–8. IEEE (2008)

  • Liu, H., Xu, J., Chen, S.,Guo, T.: Compiler optimization sequence selection method based on learning model. J. Comput. Res. Dev. 56(9), 2012–2026 (2019)

    Google Scholar 

  • Liu, H., Xu, J., Chen, S., Guo, T.: Compiler optimization parameter selection method based on ensemble learning. Electronics 11(15), 2452 (2022)

    Article  Google Scholar 

  • López-Ibáñez, M., Dubois-Lacoste, J., Cáceres, L.P., Birattari, M., Stützle, T.: The irace package: iterated racing for automatic algorithm configuration. Oper. Res. Perspect. 3, 43–58 (2016)

    MathSciNet  Google Scholar 

  • Martins, L.G., Nobre, R., Cardoso, J.M., Delbem, A.C., Marques, E.: Clustering-based selection for the exploration of compiler optimization sequences. ACM Trans. Arch. Code Optim. (TACO) 13(1), 1–28 (2016)

    Article  Google Scholar 

  • Ni, Y., Du, X., Ye, P., Xiao, R., Yuan, Y., Li, W.: Frequent pattern mining assisted energy consumption evolutionary optimization approach based on surrogate model at gcc compile time. Swarm Evol. Comput. 50, 100574 (2019)

    Article  Google Scholar 

  • Nobre, R., Martins, L.G., Cardoso, J.M.: A graph-based iterative compiler pass selection and phase ordering approach. ACM SIGPLAN Not. 51(5), 21–30 (2016)

    Article  Google Scholar 

  • Pallister, J., Hollis, S.J., Bennett, J.: Identifying compiler options to minimize energy consumption for embedded platforms. Comput. J. 58(1), 95–109 (2015)

    Article  Google Scholar 

  • Paul, A., Mukherjee, D.P., Das, P., Gangopadhyay, A., Chintha, A.R., Kundu, S.: Improved random forest for classification. IEEE Trans. Image Process. 27(8), 4012–4024 (2018)

    Article  MathSciNet  Google Scholar 

  • PolyBench: https://web.cse.ohio-state.edu/pouchet.2/software /polybench/ (2020)

  • Potena, P.: Composition and tradeoff of non-functional attributes in software systems: research directions. In: Proceedings of the the 6th Joint Meeting of the European Software Engineering Conference and the ACM SIGSOFT Symposium on The Foundations of Software Engineering, pp. 583–586 (2007)

  • Safavian, S.R., Landgrebe, D.: A survey of decision tree classifier methodology. IEEE Trans. Syst. Man Cybern. 21(3), 660–674 (1991)

    Article  MathSciNet  Google Scholar 

  • Sarwate, D.V.: Computation of cyclic redundancy checks via table look-up. Commun. ACM 31(8), 1008–1013 (1988)

    Article  Google Scholar 

  • Schwender, H., Ruczinski, I.: Logic regression and its extensions. Adv. Genet. 72, 25–45 (2010)

    Article  Google Scholar 

  • Tağtekin, B., Höke, B., Sezer, M.K., Öztürk, M.U.: Foga: flag optimization with genetic algorithm. In: 2021 International Conference on INnovations in Intelligent SysTems and Applications (INISTA), pp. 1–6. IEEE (2021)

  • Wang, Z., O’Boyle, M.: Machine learning in compiler optimization. Proc. IEEE 106(11), 1879–1901 (2018)

    Article  Google Scholar 

  • Youcong, N., Rui W, X..D..P..Y..W..L., X, R.: Evolutionary algorithm for optimization of energy consumption at GCC compile time based on frequent pattern mining. J. Softw. 30(5), 1269–1287 (2019)

    MathSciNet  Google Scholar 

Download references

Acknowledgements

This work is supported by the National Natural Science Foundation of China (No. 62172097), the Natural Science of Fujian Province (No. 2021J01166).

Author information

Authors and Affiliations

Authors

Contributions

YN: Conceptualization, Methodology; XD: Data curation, Writing- Original draft preparation; YY: Software, Investigation; RX: Supervision; GC: Validation, Resources.

Corresponding author

Correspondence to Xin Du.

Ethics declarations

Conflict of interest

The authors declared that they have no Conflict of interest.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Springer Nature or its licensor (e.g. a society or other partner) holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Ni, Y., Du, X., Yuan, Y. et al. Tsoa: a two-stage optimization approach for GCC compilation options to minimize execution time. Autom Softw Eng 31, 39 (2024). https://doi.org/10.1007/s10515-024-00437-w

Download citation

  • Received:

  • Accepted:

  • Published:

  • DOI: https://doi.org/10.1007/s10515-024-00437-w

Keywords

Navigation