Skip to content
Snippets Groups Projects

Symbol Canonicalization, Loop-Invariant Code Motion, and AST Factory

This MR introduces AST passes for symbol canonicalization and loop-invariant code motion, and an AST factory for more convenient creation of syntax trees..

Symbol Canonicalization The CanonicalizeSymbols pass will transform an AST into a canonical form with respect to the symbols occuring inside it:

  • Ensure each symbol has at most one declaration, by duplicating and renaming symbols that have multiple declarations
  • Add the const qualifier to the data type of any symbol that is never written to

Loop-Invariant Motion of Declarations The HoistLoopInvariantDeclarations pass moves declarations that are independent of loop iterations outside of the loop nest. For it to work, all symbols may have at most one declaration, so a CanonicalizeSymbols pass may have to be run before.

Both passes are now called by create_kernel.

AST Factory The newly added backend.kernelcreation.AstFactory exposes methods to quickly parse SymPy expressions and create loop nests, and is open to be extended in the future.

This MR also introduces various minor changes:

  • Support for augmented assignments is added to FreezeExpressions
  • Refactor FullIterationSpace.create_from_slice and the GenericCpu platform to use AstFactory
Edited by Frederik Hennig

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Daniel Bauer
  • Daniel Bauer
  • Frederik Hennig added 2 commits

    added 2 commits

    • 5a65bc4e - fix infinite recursion; add test cases for hoisting with conditionals and multiple loops
    • 0a252c24 - move CanonicalizeSymbols pass to optimize_cpu

    Compare with previous version

  • Daniel Bauer resolved all threads

    resolved all threads

  • removed ongoing label

  • Daniel Bauer approved this merge request

    approved this merge request

  • added 1 commit

    • 99c3a8db - remove two superfluous code lines

    Compare with previous version

  • Frederik Hennig enabled an automatic merge when the pipeline for 99c3a8db succeeds

    enabled an automatic merge when the pipeline for 99c3a8db succeeds

  • Frederik Hennig mentioned in commit e3f9ba35

    mentioned in commit e3f9ba35

  • Frederik Hennig mentioned in task #84

    mentioned in task #84

  • Please register or sign in to reply
    Loading