-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[MLIR][SCFToGPU] Guard operands before AffineApplyOp::create to avoid crash #167959
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
shashforge
wants to merge
6
commits into
llvm:main
Choose a base branch
from
shashforge:mlir-scf2gpu-affineapply-crash
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.
+64
−2
Open
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bb1d794
[MLIR][SCFToGPU] Guard operands before AffineApplyOp::create to avoid…
shashforge 8c7bafb
Merge branch 'main' into mlir-scf2gpu-affineapply-crash
shashforge 17d0144
Merge branch 'main' into mlir-scf2gpu-affineapply-crash
shashforge f5fbbba
Merge branch 'main' into mlir-scf2gpu-affineapply-crash
shashforge 33afa94
Merge branch 'main' into mlir-scf2gpu-affineapply-crash
shashforge 59235e6
Merge branch 'main' into mlir-scf2gpu-affineapply-crash
shashforge 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
31 changes: 31 additions & 0 deletions
31
mlir/test/Conversion/SCFToGPU/parallel-to-gpu-crash-regression.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 |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // RUN: mlir-opt %s --convert-parallel-loops-to-gpu | FileCheck %s | ||
|
|
||
| // Goal: exercise the per-dim index computation | ||
| // newIndex = hardware_id * step + lowerBound | ||
| // and ensure we see a gpu.launch and an affine.apply (no crash). | ||
|
|
||
| module { | ||
| func.func @two_dim_parallel_mapped() { | ||
| %c0 = arith.constant 0 : index | ||
| %c1 = arith.constant 1 : index | ||
| %c32 = arith.constant 32 : index | ||
|
|
||
| // Single 2‑D scf.parallel. Each dimension is mapped to a GPU dim. | ||
| // We *use* both IVs so the conversion must build indices. | ||
| scf.parallel (%bx, %tx) = (%c0, %c0) to (%c32, %c32) step (%c1, %c1) { | ||
| %u = arith.addi %bx, %c0 : index | ||
| %v = arith.addi %tx, %c0 : index | ||
| // No explicit terminator: the parser inserts an empty scf.reduce. | ||
| } { | ||
| mapping = [ | ||
| #gpu.loop_dim_map<processor = block_x, map = (d0) -> (d0), bound = (d0) -> (d0)>, | ||
| #gpu.loop_dim_map<processor = thread_x, map = (d0) -> (d0), bound = (d0) -> (d0)> | ||
| ] | ||
| } | ||
| return | ||
| } | ||
| } | ||
|
|
||
| // CHECK-LABEL: func.func @two_dim_parallel_mapped | ||
| // CHECK: gpu.launch | ||
| // CHECK: affine.apply | ||
24 changes: 24 additions & 0 deletions
24
mlir/test/Conversion/SCFToGPU/parallel-to-gpu-index-creation.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 |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // RUN: mlir-opt %s --convert-parallel-loops-to-gpu | FileCheck %s | ||
|
|
||
| module { | ||
| func.func @one_dim_parallel_mapped() { | ||
| %c0 = arith.constant 0 : index | ||
| %c1 = arith.constant 1 : index | ||
| %c64 = arith.constant 64 : index | ||
|
|
||
| // 1‑D loop mapped to thread_x; use the IV to force index computation. | ||
| scf.parallel (%t) = (%c0) to (%c64) step (%c1) { | ||
| %w = arith.addi %t, %c0 : index | ||
| // Implicit empty scf.reduce terminator. | ||
| } { | ||
| mapping = [ | ||
| #gpu.loop_dim_map<processor = thread_x, map = (d0) -> (d0), bound = (d0) -> (d0)> | ||
| ] | ||
| } | ||
| return | ||
| } | ||
| } | ||
|
|
||
| // CHECK-LABEL: func.func @one_dim_parallel_mapped | ||
| // CHECK: gpu.launch | ||
| // CHECK: affine.apply |
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.