-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AMDGPU] Add parameterization for optimized shared memory variables #82508
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
10 commits
Select commit
Hold shift + click to select a range
3659cbf
Add parameterization for optimized shared memory variables
erman-gurses 72a38aa
Add formatting
erman-gurses 030b521
Add fix for default values of transform dialect
erman-gurses 1a193b2
Update comments
erman-gurses 0214796
Remove global vars
erman-gurses 3e21d96
Update variable names
erman-gurses 1025f2b
Add the formatting
erman-gurses d5b8fcf
Add variables as options using ODS
erman-gurses f0d4f86
Add fix for data type
erman-gurses 4162542
Add the suggested formatting
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
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
50 changes: 22 additions & 28 deletions
50
mlir/test/Dialect/AMDGPU/optimize_shmem_reads_writes.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,50 @@ | ||
// RUN: mlir-opt %s --pass-pipeline='builtin.module(func.func(amdgpu-optimize-shared-memory))' | FileCheck %s | ||
// RUN: mlir-opt %s --pass-pipeline='builtin.module(func.func(amdgpu-optimize-shared-memory))' | FileCheck %s | ||
|
||
// CHECK: @optimize_shmem([[arg0:%.+]]: memref<{{.*}}>, [[readRow:%.+]]: index, [[readCol:%.+]]: index, [[writeRow:%.+]]: index, [[writeCol:%.+]]: index, [[fragRow:%.+]]: index, [[fragCol:%.+]]: index, [[fragColPerm:%.+]]: index, [[stRow:%.+]]: index, [[stCol:%.+]]: index) | ||
func.func @optimize_shmem(%arg0: memref<4096x4096xf16>, | ||
func.func @optimize_shmem(%arg0: memref<4096x4096xf16>, | ||
%readRow: index, %readCol: index, | ||
%writeRow: index, %writeCol: index, | ||
%fragRow: index, %fragCol: index, | ||
%fragRow: index, %fragCol: index, | ||
%fragColPerm: index, | ||
%stRow: index, %stCol: index) { | ||
// CHECK: %[[cst:.+]] = arith.constant 0.000000e+00 : f16 | ||
// CHECK: %[[cst:.+]] = arith.constant 0.000000e+00 : f16 | ||
%cst = arith.constant 0.000000e+00 : f16 | ||
|
||
// CHECK: [[shmA:%.+]] = memref.alloc | ||
// CHECK: [[shmB:%.+]] = memref.alloc | ||
%shmA = memref.alloc() {alignment = 64 : i64} : memref<128x32xf16, 3> | ||
%shmB = memref.alloc() {alignment = 64 : i64} : memref<256x32xf16, 3> | ||
|
||
// CHECK: %[[D0:.+]] = vector.transfer_read [[arg0:%.+]][[[readRow:%.+]], [[readCol:%.+]]], [[cst:.+]] {in_bounds = [true, true]} : memref<4096x4096xf16>, vector<1x8xf16> | ||
%0 = vector.transfer_read %arg0[%readRow, %readCol], %cst {in_bounds = [true, true]} : memref<4096x4096xf16>, vector<1x8xf16> | ||
// CHECK: [[c7:%.+]] = arith.constant 7 : index | ||
// CHECK: [[srcBits:%.+]] = arith.andi [[stRow:%.+]], [[c7]] | ||
// CHECK: [[c2:%.+]] = arith.constant 2 : index | ||
// CHECK: [[xorBits:%.+]] = arith.shli [[srcBits]], [[c2]] | ||
// CHECK: [[stColPerm:%.+]] = arith.xori [[stCol:%.+]], [[xorBits]] | ||
// CHECK: vector.transfer_write %[[D0:.+]], [[shmB]][[[writeRow:%.+]], [[writeCol:%.+]]] {in_bounds = [true, true]} : vector<1x8xf16>, memref<256x32xf16, 3> | ||
// CHECK: [[c6:%.+]] = arith.constant 6 : index | ||
// CHECK: [[srcBits:%.+]] = arith.andi [[stRow:%.+]], [[c6]] | ||
// CHECK: [[c2:%.+]] = arith.constant 2 : index | ||
// CHECK: [[xorBits:%.+]] = arith.shli [[srcBits]], [[c2]] | ||
// CHECK: [[stColPerm:%.+]] = arith.xori [[stCol:%.+]], [[xorBits]] | ||
vector.transfer_write %0, %shmB[%writeRow, %writeCol] {in_bounds = [true, true]} : vector<1x8xf16>, memref<256x32xf16, 3> | ||
gpu.barrier | ||
gpu.barrier | ||
// CHECK: [[c7:%.+]] = arith.constant 7 : index | ||
// CHECK: [[srcBits:%.+]] = arith.andi [[fragRow]], [[c7]] | ||
// CHECK: [[c2:%.+]] = arith.constant 2 : index | ||
// CHECK: [[xorBits:%.+]] = arith.shli [[srcBits]], [[c2]] | ||
// CHECK: [[c6:%.+]] = arith.constant 6 : index | ||
// CHECK: [[srcBits:%.+]] = arith.andi [[fragRow]], [[c6]] | ||
// CHECK: [[c2:%.+]] = arith.constant 2 : index | ||
// CHECK: [[xorBits:%.+]] = arith.shli [[srcBits]], [[c2]] | ||
// CHECK: [[fragColPerm:%.+]] = arith.xori [[fragCol:%.+]], [[xorBits]] | ||
// CHECK: vector.load [[shmB:%.+]][[[fragRow:%.+]], [[fragColPerm]]] : memref<256x32xf16, 3>, vector<8xf16> | ||
%1 = vector.load %shmB[%fragRow, %fragColPerm] : memref<256x32xf16, 3>, vector<8xf16> | ||
|
||
// CHECK: %[[D2:.+]] = vector.transfer_read [[arg0:%.+]][[[readRow:%.+]], [[readCol:%.+]]], [[cst:.+]] {in_bounds = [true, true]} : memref<4096x4096xf16>, vector<1x8xf16> | ||
%2 = vector.transfer_read %arg0[%readRow, %readCol], %cst {in_bounds = [true, true]} : memref<4096x4096xf16>, vector<1x8xf16> | ||
// CHECK: [[c7:%.+]] = arith.constant 7 : index | ||
// CHECK: [[srcBits:%.+]] = arith.andi [[stRow:%.+]], [[c7]] | ||
// CHECK: [[c2:%.+]] = arith.constant 2 : index | ||
// CHECK: [[xorBits:%.+]] = arith.shli [[srcBits]], [[c2]] | ||
// CHECK: [[stColPerm:%.+]] = arith.xori [[stCol:%.+]], [[xorBits]] | ||
// CHECK: vector.transfer_write %[[D2:.+]], [[shmA:%.+]][[[writeRow:%.+]], [[writeCol:%.+]]] {in_bounds = [true, true]} : vector<1x8xf16>, memref<128x32xf16, 3> | ||
// CHECK: [[c6:%.+]] = arith.constant 6 : index | ||
// CHECK: [[srcBits:%.+]] = arith.andi [[stRow:%.+]], [[c6]] | ||
// CHECK: [[c2:%.+]] = arith.constant 2 : index | ||
// CHECK: [[xorBits:%.+]] = arith.shli [[srcBits]], [[c2]] | ||
// CHECK: [[stColPerm:%.+]] = arith.xori [[stCol:%.+]], [[xorBits]] | ||
vector.transfer_write %2, %shmA[%writeRow, %writeCol] {in_bounds = [true, true]} : vector<1x8xf16>, memref<128x32xf16, 3> | ||
gpu.barrier | ||
gpu.barrier | ||
// CHECK: [[c7:%.+]] = arith.constant 7 : index | ||
// CHECK: [[srcBits:%.+]] = arith.andi [[fragRow]], [[c7]] | ||
// CHECK: [[c2:%.+]] = arith.constant 2 : index | ||
// CHECK: [[xorBits:%.+]] = arith.shli [[srcBits]], [[c2]] | ||
// CHECK: [[c6:%.+]] = arith.constant 6 : index | ||
// CHECK: [[srcBits:%.+]] = arith.andi [[fragRow]], [[c6]] | ||
// CHECK: [[c2:%.+]] = arith.constant 2 : index | ||
// CHECK: [[xorBits:%.+]] = arith.shli [[srcBits]], [[c2]] | ||
// CHECK: [[fragColPerm:%.+]] = arith.xori [[fragCol:%.+]], [[xorBits]] | ||
// CHECK: vector.load [[shmA:%.+]][[[fragRow:%.+]], [[fragColPerm]]] : memref<128x32xf16, 3>, vector<8xf16> | ||
%3 = vector.load %shmA[%fragRow, %fragColPerm] : memref<128x32xf16, 3>, vector<8xf16> | ||
return | ||
} |
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.