-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[mlir][gpu] Add subgroup_broadcast
op
#152808
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
Open
Hardcode84
wants to merge
3
commits into
llvm:main
Choose a base branch
from
Hardcode84:broadcast-lane
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+185
−5
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// RUN: mlir-opt %s --loop-invariant-code-motion | FileCheck %s | ||
|
||
func.func private @side_effect(%arg0 : f32, %arg1 : f32, %arg2 : f32) | ||
|
||
// CHECK-LABEL: func @broadcast_hoisting | ||
// CHECK-SAME: (%[[ARG:.*]]: f32, %[[IDX:.*]]: i32, {{.*}}: index) | ||
func.func @broadcast_hoisting(%arg0 : f32, %arg1 : i32, %arg2 : index) { | ||
%c0 = arith.constant 0 : index | ||
%c1 = arith.constant 1 : index | ||
// `any_lane` and `specific_lane` can be speculated across the control flow, but | ||
// `first_active_lane` cannot as active lanes can change. | ||
// CHECK: %[[V1:.*]] = gpu.subgroup_broadcast %[[ARG]], any_lane : f32 | ||
// CHECK: %[[V2:.*]] = gpu.subgroup_broadcast %[[ARG]], specific_lane %[[IDX]] : f32 | ||
// CHECK: scf.for | ||
// CHECK: %[[V0:.*]] = gpu.subgroup_broadcast %[[ARG]], first_active_lane : f32 | ||
// CHECK: func.call @side_effect(%[[V0]], %[[V1]], %[[V2]]) | ||
scf.for %i = %c0 to %arg2 step %c1 { | ||
%0 = gpu.subgroup_broadcast %arg0, first_active_lane : f32 | ||
%1 = gpu.subgroup_broadcast %arg0, any_lane : f32 | ||
%2 = gpu.subgroup_broadcast %arg0, specific_lane %arg1 : f32 | ||
func.call @side_effect(%0, %1, %2) : (f32, f32, f32) -> () | ||
} | ||
func.return | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the
any_lane
semantics got lost during lowering, I assume thatany_lane
is designed to help MLIR optimization at GPU dialect level and target-independent.Could you please describe what is the optimization passes you plan to do for
any_lane
, and what is the use case you target for?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any_lane
allows freely speculate across the control flow, see mlir/test/Dialect/GPU/broadcast-speculatability.mlir test