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

dialects: (vector) add pure trait to vector.broadcast and vector.fma #3094

Merged
merged 2 commits into from
Aug 31, 2024

Conversation

knickish
Copy link
Contributor

@knickish knickish commented Aug 24, 2024

Add Pure trait to vector.broadcast and vector.fma, fixes #3019

Copy link

codecov bot commented Aug 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.91%. Comparing base (30dcaa1) to head (3bc7b99).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3094   +/-   ##
=======================================
  Coverage   89.91%   89.91%           
=======================================
  Files         425      425           
  Lines       53391    53394    +3     
  Branches     8268     8268           
=======================================
+ Hits        48006    48009    +3     
  Misses       4047     4047           
  Partials     1338     1338           

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

@superlopuh
Copy link
Member

Thank you for this! Could you please add a minimal filecheck test that tests that these get dce'd away? Should be a minimal test with "test.op"s that produce the required inputs for the ops, and no uses, and that checks that the operations are removed after calling the dce pass

@webmiche
Copy link
Collaborator

Honestly, I am surprised that the broadcast op would be pure. If MLIR models it this way, it's fine to have it here aswell, I guess.

@superlopuh
Copy link
Member

https://mlir.llvm.org/docs/Dialects/Vector/#vectorbroadcast-vectorbroadcastop
You're right

@knickish
Copy link
Contributor Author

Is that indicated by the Effects: MemoryEffects::Effect{} line? Looks like nearly all of them have that

@superlopuh
Copy link
Member

Yep! We now have a similar trait in xDSL, if you could add the NoMemoryEffect trait instead of Pure that would be ideal. And then also a filecheck test that check that they still get removed by dce

@PapyChacal
Copy link
Collaborator

@webmiche @superlopuh As I discovered similarly on #3103 (resolved discussion); MLIR tend to not report some AlwaysSpeculatable operations properly in their documentation.

See:

Those ops are indeed Pure and @knickish was right 🙂

Copy link
Collaborator

@PapyChacal PapyChacal left a comment

Choose a reason for hiding this comment

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

(Plus, I personally don't think we should check traits' behaviour on dialect operations everytime, those are tested on their own through test operations, just my 2 cents on that front)

@superlopuh
Copy link
Member

We don't need to go into a full debate here but to me they're two separate things, the trait is just one way to achieve the desired behaviour, and are an implementation detail, and I think it's worth having a test for each dialect to make sure that the operations have the expected behaviour, in this case that the operations can be eliminated if their results are not used.

@knickish
Copy link
Contributor Author

Ok, so leave as Pure and add the filecheck tests, correct?

@superlopuh
Copy link
Member

Yes, please :)

@knickish knickish marked this pull request as draft August 31, 2024 21:13
@knickish knickish force-pushed the vector_broadcast_fma_pure branch from 4628149 to 975aad9 Compare August 31, 2024 21:31
@knickish
Copy link
Contributor Author

I gave the test a shot, not sure if that's exactly what it's supposed to be though

@knickish knickish marked this pull request as ready for review August 31, 2024 21:33
/// Check that unused results from vector.broadcast and vector.fma are eliminated

// CHECK: builtin.module {
// CHECK-NEXT: func.func private @vector_cse_test(%0 : memref<4x4xindex>, %1 : vector<1xi1>, %2 : index) {
Copy link
Member

Choose a reason for hiding this comment

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

ok but now the func is gone so one more change :)

@knickish knickish force-pushed the vector_broadcast_fma_pure branch from 57b7ca9 to 3bc7b99 Compare August 31, 2024 22:16
@superlopuh superlopuh merged commit dddc8cc into xdslproject:main Aug 31, 2024
14 checks passed
@superlopuh
Copy link
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vector.broadcast and vector.fma are missing the Pure trait
4 participants