[go: up one dir, main page]
More Web Proxy on the site http://driver.im/ skip to main content
10.1145/3642921.3642922acmotherconferencesArticle/Chapter ViewAbstractPublication PagesrapidoConference Proceedingsconference-collections
research-article
Open access

A C Subset for Ergonomic Source-to-Source Analyses and Transformations

Published: 06 March 2024 Publication History

Abstract

Modern compiled software, written in languages such as C, relies on complex compiler infrastructure. However, developing new transformations and improving existing ones can be challenging for researchers and engineers. Often, transformations must be implemented bymodifying the compiler itself, which may not be feasible, for technical or legal reasons. Source-to-source compilers make it possible to directly analyse and transform the original source, making transformations portable across different compilers, and allowing rapid research and prototyping of code transformations. However, this approach has the drawback of exposing the researcher to the full breadth of the source language, which is often more extensive and complex than the IRs used in traditional compilers.
In this work, we propose a solution to tame the complexity of the source language and make source-to-source compilers an ergonomic platform for program analysis and transformation. We define a simpler subset of the C language that can implement the same programs with fewer constructs and implement a set of source-to-source transformations that automatically normalise the input source code into equivalent programs expressed in the proposed subset. Finally, we implement a function inlining transformation that targets the subset as a case study.
We show that for this case study, the assumptions afforded by using a simpler language subset greatly improves the number of cases the transformation can be applied, increasing the average success rate from 37%, before normalisation, to 97%, after normalisation. We also evaluate the performance of several benchmarks after applying a naive inlining algorithm, and obtained a 12% performance improvement in certain applications, after compiling with the flag O2, both in Clang and GCC, suggesting there is room for exploring source-level transformations as a complement to traditional compilers.

References

[1]
Alfred V Aho, Monica S Lam, Ravi Sethi, and Jeffrey D Ullman. 2006. Compilers: Principles, Techniques, and Tools (2nd Edition). Addison-Wesley Longman Publishing Co., Inc.
[2]
Hamid Arabnejad, João Bispo, João M P Cardoso, and Jorge G Barbosa. 2020. Source-to-source compilation targeting OpenMP-based automatic parallelization of C applications. The Journal of Supercomputing 76 (2020), 6753–6785. https://doi.org/10.1007/s11227-019-03109-9
[3]
Hansang Bae, Dheya Mustafa, Jae-Woo Lee, Hao Lin, Chirag Dave, Rudolf Eigenmann, Samuel P Midkiff, H Bae, D Mustafa, J w Lee, H Lin, R Eigenmann, S P Midkiff, and C Dave. 2013. The Cetus Source-to-Source Compiler Infrastructure: Overview and Evaluation. Int J Parallel Prog 41 (2013), 753–767. https://doi.org/10.1007/s10766-012-0211-z
[4]
Jairo Balart, Alejandro Duran, Marc Gonzàlez, Xavier Martorell, Eduard Ayguadé, and Jesús Labarta. 2004. Nanos mercurium: a research compiler for openmp. In Proceedings of the European Workshop on OpenMP, Vol. 8. 2004.
[5]
Jeff Bezanson, Stefan Karpinski, Viral Shah, Alan Edelman, 2022. JThe Julia Language v1.8.2. The Julia Project. https://raw.githubusercontent.com/JuliaLang/docs.julialang.org/assets/julia-1.8.2.pdf (2022), 1–1563.
[6]
João Bispo and João M.P. Cardoso. 2020. Clava: C/C++ source-to-source compilation using LARA. SoftwareX 12 (7 2020), 100565. https://doi.org/10.1016/J.SOFTX.2020.100565
[7]
Amy Brown and Greg Wilson. 2011. The Architecture of Open Source Applications: Elegance, Evolution, and a Few Fearless Hacks. Vol. 1. Lulu. com.
[8]
Nicola Capodieci, Roberto Cavicchioli, Marko Bertogna, and Aingara Paramakuru. 2018. Deadline-based scheduling for GPU with preemption support. In 2018 IEEE Real-Time Systems Symposium (RTSS). IEEE, 119–130.
[9]
Keith D Cooper, Mary W Hall, and Linda Torczon. 1991. An experiment with inline substitution. Software: Practice and Experience 21, 6 (1991), 581–601.
[10]
Iván Cores, Gabriel Rodríguez, Patricia González, and María J Martín. 2014. Failure avoidance in MPI applications using an application-level approach. Comput. J. 57, 1 (2014), 100–114.
[11]
Jeffrey Dean and Craig Chambers. 1994. Towards better inlining decisions using inlining trials. In Proceedings of the 1994 ACM Conference on LISP and Functional Programming. 273–282.
[12]
Christophe Denis, Pablo De Oliveira Castro, and Eric Petit. 2015. Verificarlo: Checking floating point accuracy through monte carlo arithmetic. arXiv preprint arXiv:1509.01347 (2015).
[13]
Tom Duff. 1988. "Tom Duff on Duff’s Device". Email correspondence, archived at: http://www.lysator.liu.se/c/duffs-device.html. Accessed 2022-07-01.
[14]
Philipp Gschwandtner, Juan J Durillo, and Thomas Fahringer. 2014. Multi-objective auto-tuning with insieme: Optimization and trade-off analysis for time, energy and resource usage. In European Conf. on Par. Processing. Springer, 87–98.
[15]
Suresh Jagannathan and Andrew Wright. 1996. Flow-directed inlining. ACM SIGPLAN Notices 31, 5 (1996), 193–205.
[16]
Simon Peyton Jones and Simon Marlow. 2002. Secrets of the glasgow haskell compiler inliner. Journal of Functional Programming 12, 4-5 (2002), 393–434.
[17]
Herbert Jordan. 2014. Insieme: A Compiler Infrastructure for Parallel Programs. Ph. D. Dissertation. https://diglib.uibk.ac.at/ulbtirolhs/download/pdf/179200?originalFilename=true
[18]
Ralf Jung, Hoang-Hai Dang, Jeehoon Kang, and Derek Dreyer. 2019. Stacked borrows: an aliasing model for Rust. Proceedings of the ACM on Programming Languages 4, POPL (2019), 1–32.
[19]
Chris Lattner and Vikram Adve. 2004. LLVM: A Compilation Framework for Lifelong Program Analysis & Transformation. (2004). https://doi.org/10.1109/CGO.2004.1281665
[20]
Chris Lattner, Mehdi Amini, Uday Bondhugula, Albert Cohen, Andy Davis, Jacques Pienaar, River Riddle, Tatiana Shpeisman, Nicolas Vasilache, and Oleksandr Zinenko. 2021. MLIR: Scaling Compiler Infrastructure for Domain Specific Computation. CGO 2021 - Proceedings of the 2021 IEEE/ACM International Symposium on Code Generation and Optimization (2 2021), 2–14. https://doi.org/10.1109/CGO51591.2021.9370308
[21]
Bernardo Cardoso Lopes and Nathan Lanza. 2022. [RFC] An MLIR based Clang IR (CIR) - Clang Frontend - LLVM Discussion Forums. 2022. Available at https://discourse.llvm.org/t/rfc-an-mlir-based-clang-ir-cir/63319. Accessed 2022-07-05.
[22]
Reed Milewicz, Peter Pirkelbauer, Prema Soundararajan, Hadia Ahmed, and Tony Skjellum. 2021. Negative Perceptions About the Applicability of Source-to-Source Compilers in HPC: A Literature Review. In International Conference on High Performance Computing. Springer, 233–246.
[23]
George C. Necula, Scott McPeak, Shree P. Rahul, and Westley Weimer. 2002. CIL: Intermediate language and tools for analysis and transformation of C programs. Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics) 2304 (2002), 213–228. https://doi.org/10.1007/3-540-45937-5_16/COVER/
[24]
Marek Palkowski and Wlodzimierz Bielecki. 2016. TRACO: source-to-source parallelizing compiler. Computing and Informatics 35, 6 (2016), 1277–1306.
[25]
Aleksandar Prokopec, Gilles Duboscq, David Leopoldseder, and Thomas Wïrthinger. 2019. An optimization-driven incremental inline substitution algorithm for just-in-time compilers. In 2019 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). IEEE, 164–179.
[26]
Dan Quinlan and Chunhua Liao. 2011. The ROSE source-to-source compiler infrastructure. In Cetus users and compiler infrastructure workshop, in conjunction with PACT, Vol. 2011. Citeseer, 1.
[27]
Robert W Scheifler. 1977. An analysis of inline substitution for a structured programming language. Commun. ACM 20, 9 (1977), 647–654.
[28]
Theodoros Theodoridis, Tobias Grosser, and Zhendong Su. 2022. Understanding and exploiting optimal function inlining. In Proceedings of the 27th ACM International Conference on Architectural Support for Programming Languages and Operating Systems. 977–989.
[29]
Daniil Tiganov, Jeff Cho, Karim Ali, and Julian Dolby. 2020. SWAN: A static analysis framework for Swift. In Proceedings of the 28th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering. 1640–1644.
[30]
Jessica Vandebon, Jose GF Coutinho, Wayne Luk, Eriko Nurvitadhi, and Tim Todman. 2020. Artisan: A meta-programming approach for codifying optimisation strategies. In 2020 IEEE 28th Annual International Symposium on Field-Programmable Custom Computing Machines (FCCM). IEEE, 177–185.
[31]
Peter Zangerl, Herbert Jordan, Peter Thoman, Philipp Gschwandtner, and Thomas Fahringer. 2018. Exploring the semantic gap in compiling embedded DSLs. ACM International Conference Proceeding Series (7 2018), 195–201. https://doi.org/10.1145/3229631.3239371

Cited By

View all

Index Terms

  1. A C Subset for Ergonomic Source-to-Source Analyses and Transformations

      Recommendations

      Comments

      Please enable JavaScript to view thecomments powered by Disqus.

      Information & Contributors

      Information

      Published In

      cover image ACM Other conferences
      RAPIDO '24: Proceedings of the 16th Workshop on Rapid Simulation and Performance Evaluation for Design
      January 2024
      54 pages
      ISBN:9798400717918
      DOI:10.1145/3642921
      This work is licensed under a Creative Commons Attribution-ShareAlike International 4.0 License.

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      Published: 06 March 2024

      Check for updates

      Author Tags

      1. C
      2. Compilers
      3. Meta-programming
      4. Source-to-source

      Qualifiers

      • Research-article
      • Research
      • Refereed limited

      Funding Sources

      • Fundação para a Ciência e a Tecnologia

      Conference

      RAPIDO '24

      Acceptance Rates

      Overall Acceptance Rate 14 of 28 submissions, 50%

      Contributors

      Other Metrics

      Bibliometrics & Citations

      Bibliometrics

      Article Metrics

      • 0
        Total Citations
      • 171
        Total Downloads
      • Downloads (Last 12 months)171
      • Downloads (Last 6 weeks)39
      Reflects downloads up to 04 Jan 2025

      Other Metrics

      Citations

      Cited By

      View all

      View Options

      View options

      PDF

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      HTML Format

      View this article in HTML Format.

      HTML Format

      Login options

      Media

      Figures

      Other

      Tables

      Share

      Share

      Share this Publication link

      Share on social media