gr grafter er a clang tool for tree traversals fusion
play

Gr Grafter er: A Clang tool for tree traversals fusion Laith - PowerPoint PPT Presentation

Gr Grafter er: A Clang tool for tree traversals fusion Laith Sakka Kirshanthan Sundararajah Milind Kulkarni What is Grafter? Grafter performs source to source transformations to fuse recursive functions that traverse trees computeHight


  1. Gr Grafter er: A Clang tool for tree traversals fusion Laith Sakka Kirshanthan Sundararajah Milind Kulkarni

  2. What is Grafter? Grafter performs source to source transformations to fuse recursive functions that traverse trees computeHight (render_tree); computeWidth(render_tree); computePos(render_tree); computeHight_ computeWidth_computePos(render_tree);

  3. What is Grafter? Sound, Fine-Grained Traversal Fusion for Heterogeneous Trees (PLDI 2019) https://dl.acm.org/citation.cfm?id=3314221.3314626 https://www.youtube.com/watch?v=j2henSFtZds https://github.com/laithsakka/Grafter

  4. This talk is not about Grafter! Its about utilizing Clang to implement Grafter 1. Embedded DSL in C++ 2. Static analysis 3. Code generation

  5. Why embedded DSL in C++ • Better Productivity. • Better Performance. • Ease of Integration.

  6. Embedded DSL in C++ • Annotate components • Verify annotated components against a set of rules. No aliasing Annotations No condition calls

  7. Static analysis 1. A function is represented as a sequence of _fuse_F3F4 clang::Stmt * Clang::Stmt* and Clang::CallExpr* nodes. Different schedules are achieved by S1/ F3 reordering statements and collapsing calls. clang::Stmt * S2/ F4 2. Understand accesses of statements and build Fused Calls call graphs to analyze dependences. F5_F6 C1 C2

  8. Code Generation • Grafter build the fused functions incrementally following a set of rewrite rules while tracking the original source code _fuse_F3F4 clang::Stmt * s1 clang::Stmt * s2 Fused Calls F5_F6 C2 C1

  9. Code generation example _fuse_F3F4 clang::Stmt * Parameters S1/ Track active traversals F3 clang::Stmt S2/ Call fused functions * F4 Fused Calls F5_F6 C1 C2 Computations

  10. Code generation example • Replace original calls with calls to fused functions, and create virtual switches functions as needed.

  11. It does scale.. We run Grafter on programs with more than 50 functions to be fused and automatically generate programs thousands lines of code that achieve significant speedups.

  12. Conclusions • Clang is useful in performing domain specific source to source transformations • Easy to implement an embedded DSL in C++ • Clang AST is useful in collecting source-level information needed for static analysis • Clang AST makes it easy to track input program while generating the output program

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend