-
Notifications
You must be signed in to change notification settings - Fork 256
[Enhancement] Introduce PassConfig TL_ENABLE_AGGRESSIVE_SHARED_MEMORY_MERGE
to enable aggressive shared memory reuse
#602
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
310f916
[Enhancement] Add aggressive shared memory merge option in memory all…
LeiWang1999 d9cdc61
lint fix
LeiWang1999 3319aa2
[Enhancement] Add aggressive shared memory merge configuration option
LeiWang1999 9191c38
[Enhancement] Update MergeSharedMemoryAllocations to support aggressi…
LeiWang1999 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,20 @@ def allow_global_thread_synchronization(pass_ctx: Optional[PassContext] = None) | |
return enable_global_thread_sync | ||
|
||
|
||
def should_enable_aggressive_merge(pass_ctx: Optional[PassContext] = None, | ||
target: Optional[Target] = None) -> bool: | ||
if pass_ctx is None: | ||
pass_ctx = tilelang.transform.get_pass_context() | ||
enable_aggressive_merge = bool( | ||
pass_ctx.config.get(tilelang.PassConfigKey.TL_ENABLE_AGGRESSIVE_SHARED_MEMORY_MERGE, False)) | ||
Comment on lines
+57
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The enable_aggressive_merge = pass_ctx.config.get(tilelang.PassConfigKey.TL_ENABLE_AGGRESSIVE_SHARED_MEMORY_MERGE, False) |
||
if allow_warp_specialized(pass_ctx=pass_ctx, target=target): | ||
# This is a workaround to avoid the bug in the MergeSharedMemoryAllocations pass | ||
# when warp specialization is enabled, as different warp threads may access different | ||
# buffers, but the liveness analysis is hard because we need to do pipeline. | ||
enable_aggressive_merge = False | ||
return enable_aggressive_merge | ||
|
||
|
||
def LowerAndLegalize(mod: IRModule, target: Target) -> IRModule: | ||
# Bind the target device information to the module | ||
mod = tir.transform.BindTarget(target)(mod) | ||
|
@@ -151,7 +165,9 @@ def OptimizeForTarget(mod: IRModule, target: Target) -> IRModule: | |
mod = tilelang.transform.AnnotateDeviceRegions()(mod) | ||
mod = tir.transform.SplitHostDevice()(mod) | ||
|
||
mod = tilelang.transform.MergeSharedMemoryAllocations()(mod) | ||
mod = tilelang.transform.MergeSharedMemoryAllocations( | ||
enable_aggressive_merge=should_enable_aggressive_merge(pass_ctx=pass_ctx, target=target))( | ||
mod) | ||
|
||
mod = tilelang.transform.ThreadSync("shared")(mod) | ||
mod = tilelang.transform.ThreadSync("shared.dyn")(mod) | ||
|
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
Oops, something went wrong.
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.
This logic block is duplicated in
VisitExpr_(const BufferLoadNode*)
(lines 196-201) andVisitExpr_(const VarNode*)
(lines 212-217). To improve maintainability and readability, consider refactoring this into a private helper method.Additionally, this block can be simplified using a ternary operator to avoid the
if/else
statement and the redundant local variable.