We are proposing a second hands-on tutorial on creating high-performance DSLs (Domain Specific Languages) with the BuildIt framework [1, 2, 3]. The BuildIt project makes it possible to rapidly prototype embedded DSLs using a multi-stage programming approach while targeting parallel CPUs, GPUs and now FPGAs. BuildIt is targeted towards domain experts who have limited experience with compiler technology. However it also greatly simplifies the development process for compiler experts allowing implementing analyses, transformations and code generations for various architectures with a fraction of lines of code as compared to traditional compilers.
We previously organized a tutorial at PLDI 2024. The first iteration of this tutorial focused on understanding the basics of BuildIt and using it to implement a high-performance “Array DSL” for targeting CPUs and GPUs while doing some basic optimizations. We received feedback from some of the attendees after the tutorial that they would like us to cover in-depth details of more optimizations on top of BuildIt. Hence with this iteration we want to focus on walking the attendees through implementing some very interesting optimizations that we discovered in the DSLs we have built with BuildIt in the past year namely BREeze[4], StreamIt[6] and NetBlocks[5]. The BREeze system which is a high-performance regular expressions compiler will be used to demonstrate generation of rich and complex control-flow combined with scheduling to handle non-determinism. The NetBlocks DSL demonstrates how to apply the ideas of staging to specializing data-layouts programmatically to obtain maximum throughput in network stacks. The StreamIt compiler system implements a streaming applications DSL that demonstrates compilation for single system and distributed settings.
To make the tutorial accessible for new attendees, we plan to recap the basics of BuildIt in the first half with a shorter version of the tutorial from the previous year and then getting into the more interesting optimizations.
The previous iteration of this tutorial at PLDI 2024 had about 10 attendees which were primarily composed of early stage PhD students and some industry folks. We are hoping with a full length tutorial, more attendees would be interested. We presented a similar tutorial for industry engineers at CSAIL, MIT which was attended by over 80 engineers.
Here is a brief agenda/summary of the topics we plan to cover:
Agenda
- Basics of BuildIt and Recap [1 hr, including setup time]
- Writing programs in multiple stages using BuildIt’s dyn and static types
- Implementing a simple DSL that generates naive code for user programs
- Optimizations with BuildIt [1.5 hr]
- Implementing a whole-program analysis for the DSL that enables optimizations without writing any “compiler-ish” code. Technique described in [2].
- Using analysis results and user schedules to specialize and optimize the generated code.
- New DSL Walkthrough [3 hrs]
- Generating complex control-flow in BREze leveraging BuildIt’s re-execution strategy
- Programmatically generating data-layouts with the NetBlocks DSL for high-performance network protocols
- Generating code for streaming applications for single-system and distributed settings
The tutorial will be completely hands-on, with presentations from the organizers and relevant skeleton code shared for development.
We also have some BuildIt swag for attendees :)
References
- Ajay Brahmakshatriya, and Saman Amarasinghe. BuildIt: A Type-Based Multi-stage Programming Framework for Code Generation in C++. Proceedings of the International Symposium on Code Generation and Optimization (CGO), 2021.
- Ajay Brahmakshatriya, and Saman Amarasinghe. GraphIt to CUDA compiler in 2021 LOC: A case for high-performance DSL implementation via staging with BuilDSL Proceedings of the International Symposium on Code Generation and Optimization (CGO), 2022.
- Ajay Brahmakshatriya, and Saman Amarasinghe. D2X: An eXtensible conteXtual Debugger for Modern DSLs Proceedings of the International Symposium on Code Generation and Optimization (CGO), 2023.
- Tamara Mitrovska: Implementing BREeze - a High-Performance Regular Expression Library Using Code Generation with BuildIt. Master’s Thesis, MIT, Cambridge
- Ajay Brahmakshatriya, Chris Rinard, Manya Ghobadi, and Saman Amarasinghe. 2024. NetBlocks: Staging Layouts for High-Performance Custom Host Network Stacks. Proc. ACM Program. Lang. 8, PLDI
- Kaustubh Dighe: Fast Multistage Compilation of Machine Learning Computation Graphs. Master’s Thesis, MIT, Cambridge