GridTools
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # GT4Py passes to GTC migration ###### tags: `cycle 0` ## Problem With Eve we are developing a library to implement IRs, transformations and code generators. GT4Py's backend will directly profit from this development. We see the following advantages for moving to Eve now: - We will use a common infrastructure for Cartesian backends and the prototype work for unstructured meshes. - Vulcan actively works on the optimizations in GT4Py. Implementing these optimizations directly on the new infrastructure will save us work to migrate them later. - Develop a testing methodology for transformation passes that can be applied later to unstructured meshes. ## Appetite Full cycle (Rico, Hannes, help from Johann) ## Solution Migrate current GT4Py functionality to the Eve infrastructure using the new GTC IRs. A NumPy backend and a GridTools (CPU backend) will be used to test implementation. A focus will be on testability of transformation passes. Subtopics: - Complete GTIR with focus on validation (narrowing it as much as possible to the parallel model). - Design a middle IR that allows for optimizations like fusing etc (OIR = optimizable IR) - Complete the low-level IRs (npir, gtcppir) - Implement analysis passes for information necessary to lower - Describe testing patterns and develop simple infrastructure for testing passes: how to add a new testcase without much overhead - Implement optimization passes (nice to have) No-goal: - At this point we don't focus on CUDA backends. They should be available via gtcppir. But not testing explicitly now, will reduce compile time etc. - Don't extend existing integration/regression tests of GT4Py (GTScript -> code + execution), but pass all existing tests ## Testing strategy - Definition IR to GTIR: unit tests as needed for implementation (developer's choice) - Test as much as possible by a narrow GTIR (pydantic types and validators) - Analysis passes: - Programmatically construct IRs and check against annotations of result IR - Unit tests for components used in the passes - Optimization passes: - Programmatically construct IRs and check against features of result IR - Unit tests see above - Lowering: - Unittests for individual nodes lowering - No tests from full IR -> full IR (rely on integration tests) - Codegen: - testing for edge cases for compilability - Integration tests (GTScript -> code + execution): - no new tests (only existing GT4Py tests) ### How to programmatically create IRs - Provide helpers to construct IRs (make it easy to construct similar IRs with small differences) - Builder pattern (keep an eye on complexity of the builders) ## Migration of transformation passes - Transformation split into analysis (e.g. compute merge canditates) and apply. Current passes in the order they would most likely be ported (form essential to nice-to-have). ### Lowering - InitInfoPass: Transcribe definition IR structure into blocks. The following `transform_data` attributes are changed: - `symbols`: SymbolInfo for each used symbol. - `blocks`: Block structure following the original Definition IR. Composed of 3 sub-passes: - IntervalMaker - SymbolMaker - BlockMaker --> integrate into Lowering DefIR -> GTIR (gt4py side) - NormalizeBlocksPass: Create a DomainBlockInfo for each StatementInfo. The following `transform_data` attributes are changed: - `blocks`: DomainBlockInfo each contain only a single StatementInfo. --> integrate into Lowering DefIR -> GTIR - BuildIIRPass: Transcribe `transform_data.blocks` to `transform_data.implementation_ir`. ``` DomainBlockInfo -> MultiStage IJBlockInfo -> Stage IntervalBlockInfo -> ApplyBlock ``` --> Lowering Def IR -> GTIR ### Analysis - DataTypePass: Fills in the concrete data_type for all set to `DataType.AUTO` These should be limited to: - NativeFuncCall - Ternary - Binary - Unary - FieldRef - VarRef - lhs of Assign --> Analysis on GTIR: annotate each Expr with its type -> OIR has subnode with dtype for leaves, e.g. Literal, FieldRef, VarRef until we can rely on symbol table to give us this information (no AUTO anywhere) - ComputeExtentsPass: Loop over blocks backwards and accumulate extents. Writes to `transform_data.blocks` and fills each IJBlockInfo.compute_extent, and creates `transform_data.implementation_ir.fields_extent`. --> Analysis on OIR? If on GTIR, then the lowering to (and optimizations in) OIR would have to keep this info intact. Required for code generators (i.e. lower-level IRs) and optimizations. - ComputeUsedSymbolsPass: Fills the SymbolInfo `in_use` attribute in `transform_data.symbols`. (nice to have) It does this because an entry was originally created for each Decl in the SymbolMaker part of InitInfoPass, and some of these may not be referenced. This allows to have Fields which are defaulted to None. - No checks are done on these fields - They are not passed to the C++ side --> Currently required in Tasmania ### Optimization - MergeBlocksPass: Merges `transform_data.blocks` using a greedy algorithm. The first step merges IJBlockInfos as long as compatibility conditions are met, then proceeds to try and merge IJBlockInfos. The secondary merging step attempts to create as few IntervalBlockInfos as necessary, by re-using existing blocks with the same interval. Note that this could be re-implemented as a third merging step for every IJBlockInfo instead. The following `transform_data` attributes are changed: - `blocks`: Merged as far as possible without reordering. --> Optimization on Optimization IR (keep greedy merge strategy) 2 passes: - First Vertical loop merging - Then Horizontal loop merging Strategy for each: - Find merge candidates - Merge - DemoteLocalTemporariesToVariablePass: Demote symbols only used within a single stage to scalars. This may occur because these can be local variables in the scope, and therefore do not need to be fields. --> Optimization IR optimization - HouseKeepingPass: Misc clean-up... They should be separated. - WarnIfNoEffect: Warn if StencilImplementation has no effect. --> probably on GTIR (maybe implicitly checked by GTIR restrictions) - PruneEmptyNodes: Removes empty multi-stages, stage groups, and stages --> optimization on OIR? Test optimization passes to not leave over empty nodes?

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully