-
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
bb1d794
8c7bafb
17d0144
f5fbbba
33afa94
59235e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -673,3 +673,55 @@ func.func @nested_parallel_with_side_effect() { | |
|
|
||
| // CHECK: gpu.launch | ||
| // CHECK-NOT: scf.parallel | ||
|
|
||
| // ----- | ||
|
|
||
| // RUN: mlir-opt %s --convert-parallel-loops-to-gpu | FileCheck %s --check-prefix=CRASH-REG | ||
| // Minimal 2-D mapped case that used to tickle index creation: | ||
| // newIndex = id * step + lowerBound | ||
| // After the fix it must lower and contain a gpu.launch and an affine.apply. | ||
| func.func @scf2gpu_index_creation_2d() { | ||
| %c0 = arith.constant 0 : index | ||
| %c1 = arith.constant 1 : index | ||
| %c32 = arith.constant 32 : index | ||
|
|
||
| // Single 2-D scf.parallel mapped to block_x and thread_x. | ||
| // Use both IVs so the conversion must compute 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 | ||
| } { | ||
| 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 | ||
| } | ||
|
|
||
| // CRASH-REG-LABEL: func.func @scf2gpu_index_creation_2d | ||
| // CRASH-REG: gpu.launch | ||
| // CRASH-REG: affine.apply | ||
|
|
||
|
Member
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. // CHECK-LABEL: func.func @scf2gpu_index_creation_2d -> // CHECK-LABEL: func @scf2gpu_index_creation_2d and You should capture the SSA value and then match it.rather than a simple matching operation.
Member
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. |
||
| // ----- | ||
|
|
||
| // RUN: mlir-opt %s --convert-parallel-loops-to-gpu | FileCheck %s --check-prefix=IDX-OK | ||
| // Sanity: 1-D mapped loop still lowers and computes index. | ||
| func.func @scf2gpu_index_creation_1d() { | ||
| %c0 = arith.constant 0 : index | ||
| %c1 = arith.constant 1 : index | ||
| %c64 = arith.constant 64 : index | ||
|
|
||
| scf.parallel (%t) = (%c0) to (%c64) step (%c1) { | ||
| %w = arith.addi %t, %c0 : index | ||
| } { | ||
| mapping = [ | ||
| #gpu.loop_dim_map<processor = thread_x, map = (d0) -> (d0), bound = (d0) -> (d0)> | ||
| ] | ||
| } | ||
| return | ||
| } | ||
|
|
||
| // IDX-OK-LABEL: func.func @scf2gpu_index_creation_1d | ||
| // IDX-OK: gpu.launch | ||
| // IDX-OK: affine.apply | ||
Uh oh!
There was an error while loading. Please reload this page.