Abstract
Rewriting code for cleanliness, API changes, and new programming models is a common, yet time-consuming task. Localized or syntax-based changes are often mechanical and can be automated with text-based rewriting tools, like sed. However, non-localized or semantic-based changes require specialized tools that usually come with complex, hard-coded rules that require expertise in compilers. This means techniques for source rewriting are either too simple for complex tasks or too complex to be customized by non-expert users; in either case, developers are often forced to manually update their code instead. This work describes a new approach to code rewriting which exposes complex and semantic-driven rewrite capabilities to users in a simple and natural way. Rewrite rules are expressed as a pair of parameterized “before-and-after” source code snippets, one to describe what to match and one to describe what the replacement looks like. Through this novel and user-friendly interface, programmers can automate and customize complex code changes which require a deep understanding of the language without any knowledge of compiler internals. As our prototype, MARTINI, is built on top of Clang, we can (conceptually) handle all Clang’s input languages, including CUDA, SYCL, and many other C/C++-based interfaces, like Kokkos and OpenMP. To showcase usability, we implemented the clang-tidy rule “modernize-use-nullptr” and a simple instrumentation example. To further illustrate the potential of MARTINI, we reimplemented HIPIFY, which translates CUDA to HIP. Compared to hipify-perl and hipify-clang from HIPIFY, our version is easier to implement, more understandable, and customizable. The latter allows us to outperform HIPIFY-generated code by slightly modifying the translation rules of MARTINI-HIPIFY.
| Original language | English |
|---|---|
| Title of host publication | Euro-Par 2022 |
| Subtitle of host publication | Parallel Processing - 28th International Conference on Parallel and Distributed Computing, Proceedings |
| Editors | José Cano, Phil Trinder |
| Publisher | Springer Science and Business Media Deutschland GmbH |
| Pages | 19-34 |
| Number of pages | 16 |
| ISBN (Print) | 9783031125966 |
| DOIs | |
| Publication status | Published - 2022 |
| Externally published | Yes |
| Event | 28th International European Conference on Parallel and Distributed Computing, Euro-Par 2022 - Glasgow, United Kingdom Duration: 22 Aug 2022 → 26 Aug 2022 |
Publication series
| Name | Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics) |
|---|---|
| Volume | 13440 LNCS |
| ISSN (Print) | 0302-9743 |
| ISSN (Electronic) | 1611-3349 |
Conference
| Conference | 28th International European Conference on Parallel and Distributed Computing, Euro-Par 2022 |
|---|---|
| Country/Territory | United Kingdom |
| City | Glasgow |
| Period | 22/08/22 → 26/08/22 |
!!!Keywords
- AST matchers
- metaprogramming
- refactoring
Fingerprint
Dive into the research topics of 'MARTINI: The Little Match and Replace Tool for Automatic Application Rewriting with Code Examples'. These topics are generated from the title and abstract of the publication. Together, they form a unique fingerprint.Datasets
-
Artifact Instructions for MARTINI: The Little Match and Replace Tool
Johnson, A. (Creator), Coti, C. (Creator), Malony, A. (Creator) & Doerfert, J. (Creator), figshare, 2022
DOI: 10.6084/m9.figshare.19993454
Dataset
Cite this
- APA
- Author
- BIBTEX
- Harvard
- Standard
- RIS
- Vancouver