-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[mlir][amdgpu] Shared memory access optimization pass #75627
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
12 commits
Select commit
Hold shift + click to select a range
87689f1
[mlir][amdgpu] Shared memory access optimization pass
erman-gurses c072744
Add a fix for bad line break
erman-gurses 5384eba
Remove constructor to enable autogeneration
erman-gurses d78fd01
Remove unused constant expressions
erman-gurses 811fea3
Add simplification for read/write ops initialization
erman-gurses f8b4c06
Add description for utils
erman-gurses 653c1ae
Add description
erman-gurses fe9f5a9
Add change the pass data type as struct
erman-gurses 983e956
Remove anonymous namespace
erman-gurses b722dd7
Add optional for the util function
erman-gurses 085d629
Add interface for get and set indices functions
erman-gurses 49b043f
Revert back to the original get and set indices methods
erman-gurses 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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//===- Transforms.h - AMDGPU Dialect transformations --------------*- | ||
// C++-*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file declares functions that assist transformations for the amdgpu | ||
// dialect. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
#ifndef MLIR_DIALECT_AMDGPU_TRANSFORMS_TRANSFORMS_H_ | ||
#define MLIR_DIALECT_AMDGPU_TRANSFORMS_TRANSFORMS_H_ | ||
|
||
#include "mlir/IR/Operation.h" | ||
#include "mlir/Support/LogicalResult.h" | ||
|
||
namespace mlir { | ||
class RewriterBase; | ||
|
||
namespace amdgpu { | ||
|
||
/// | ||
/// Passes | ||
/// | ||
|
||
/// Optimizes vectorized accesses to a shared memory buffer specified by | ||
/// memrefValue. This transformation assumes the following: | ||
/// 1) All relevant accesses to `memrefValue` are contained with `parentOp`. | ||
/// 2) The function will fail precondition checks if any subviews are | ||
/// taken of `memrefValue`. All reads/writes to `memrefValue` should occur | ||
/// through `memrefValue` directly. | ||
/// | ||
/// Shared memory bank conflicts occur when multiple threads attempt to read or | ||
/// write locations assigned to the same shared memory bank. For `2^N` byte | ||
/// vectorized accesses, we need to be concerned with conflicts among threads | ||
/// identified as `(tid) -> tid.floordiv(2^{7-N})`. As such, this transformation | ||
/// changes any indexed memory access (vector.load, memref.load, etc) | ||
/// such that the final dimension's index value is permuted such that | ||
/// `newColIndex = oldColIndex % vectorSize + | ||
/// perm[rowIndex](oldColIndex/vectorSize, rowIndex)` where `rowIndex` is the | ||
/// index for the second-to last dimension and `perm[rowIndex]` is a permutation | ||
/// function that depends on the row Index. The permutation function is chosen | ||
/// to ensure that sequential distributed+vectorized reads/writes down a single | ||
/// dimension of the memref have minimal conflicts. | ||
mlir::LogicalResult optimizeSharedMemoryReadsAndWrites(Operation *parentOp, | ||
Value memrefValue); | ||
|
||
} // namespace amdgpu | ||
} // namespace mlir | ||
|
||
#endif // MLIR_DIALECT_AMDGPU_TRANSFORMS_TRANSFORMS_H_ |
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 @@ | ||
//===- Utils.h - Transform utilities -----------------------------*- C++-*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "mlir/IR/Operation.h" | ||
|
||
namespace mlir { | ||
namespace amdgpu { | ||
|
||
/// Get and set the indices that the given load/store operation is operating on. | ||
/// Preconditions: | ||
/// - The Op must have memory affects | ||
/// - Considers memref::LoadOp, vector::LoadOp, vector::TransferReadOp | ||
/// - Considers memref::StoreOp, vector::StoreOp, vector::TransferWriteOp | ||
/// - Excludes subview op | ||
std::optional<Operation::operand_range> getIndices(Operation *op); | ||
void setIndices(Operation *op, ArrayRef<Value> indices); | ||
erman-gurses marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
} // namespace amdgpu | ||
} // namespace mlir |
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.
Uh oh!
There was an error while loading. Please reload this page.