Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transformations: convert type_offsets in ptr to arith.constant #3394

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mamanain
Copy link
Collaborator

@mamanain mamanain commented Nov 4, 2024

It seems like having a separate test for this is a little wasteful, so I decided to test it in loop folding.

@mamanain mamanain added the transformations Changes or adds a transformatio label Nov 4, 2024
@mamanain mamanain self-assigned this Nov 4, 2024
@@ -0,0 +1,90 @@
// RUN: xdsl-opt -p convert-memref-to-ptr,convert-ptr-type-offsets --print-op-generic --split-input-file %s | mlir-opt --allow-unregistered-dialect --mlir-print-op-generic -pass-pipeline 'builtin.module(func.func(scf-for-loop-canonicalization,scf-for-loop-range-folding,scf-for-loop-canonicalization))' | xdsl-opt -p scf-for-loop-flatten --print-op-generic | mlir-opt --allow-unregistered-dialect --mlir-print-op-generic -pass-pipeline 'builtin.module(func.func(scf-for-loop-canonicalization,scf-for-loop-range-folding,scf-for-loop-canonicalization))'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please try using the mlir opt pass in xDSL? should simplify the pipeline a little bit

Copy link

codecov bot commented Nov 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.18%. Comparing base (87e1a46) to head (2ac5e3f).
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3394      +/-   ##
==========================================
+ Coverage   90.13%   90.18%   +0.04%     
==========================================
  Files         452      455       +3     
  Lines       57157    57282     +125     
  Branches     5498     5504       +6     
==========================================
+ Hits        51519    51657     +138     
+ Misses       4180     4173       -7     
+ Partials     1458     1452       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@superlopuh
Copy link
Member

It would be great to add an individual filecheck test for the pass also

@@ -0,0 +1,79 @@
// RUN: xdsl-opt -p convert-memref-to-ptr,convert-ptr-type-offsets,mlir-opt[scf-for-loop-canonicalization,scf-for-loop-range-folding,scf-for-loop-canonicalization],scf-for-loop-flatten,mlir-opt[scf-for-loop-canonicalization,scf-for-loop-range-folding,scf-for-loop-canonicalization] --split-input-file %s | filecheck %s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much are we missing in xDSL from the mlir-opt pipeline here? If it's not a lot, I'd much rather have this logic in xDSL.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe both scf-for-loop-canonicalization and scf-for-loop-range-folding are missing. Do you think it's worth porting them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep definitely, I'd love to keep the Snitch compilation flow entirely working without the need of MLIR, for environments like WASM, and for when we start the work of schedule exploration, and whatever hackery we need to do to make it fast, it's much easier to play with all this in one environment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scf-for-loop-range-folding is already in, and was less buggy than the MLIR one until recently, where I upstreamed a bug fix to MLIR after noticing the difference with xDSL :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we bench it first? I'm just curious to see if it makes any improvements. Plus, if there is no speed increase, maybe the port won't be worth it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right, there is. But I think it's only for the riscv loops. Do we want a general scf version?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can guarantee speed improvements, and register pressure improvements in the final assembly, if that's what you mean

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, I think it would be worth having an scf version for this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I'll port them to xdsl

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we now have everything we need?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
transformations Changes or adds a transformatio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants