Skip to content

Commit e939efa

Browse files
luciechois-perron
andauthored
Add tests for maximal reconvergence. (#473)
Added 2 tests based on the [article](https://www.khronos.org/blog/khronos-releases-maximal-reconvergence-and-quad-control-extensions-for-vulkan-and-spir-v), subgroup uniform control flow and loop peeling. Addresses llvm/llvm-project#136930 --------- Co-authored-by: Steven Perron <stevenperron@google.com>
1 parent 2e266da commit e939efa

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#--- source.hlsl
2+
RWStructuredBuffer<uint> Out : register(u0);
3+
4+
[numthreads(8,1,1)]
5+
void main(uint3 TID : SV_GroupThreadID) {
6+
for (uint i = 0; i < 8; i++) {
7+
if (i == TID.x) {
8+
Out[TID.x] = WaveActiveMax(TID.x);
9+
break;
10+
}
11+
}
12+
}
13+
14+
//--- pipeline.yaml
15+
16+
---
17+
Shaders:
18+
- Stage: Compute
19+
Entry: main
20+
DispatchSize: [1, 1, 1]
21+
Buffers:
22+
- Name: Out
23+
Format: UInt32
24+
Data: [ 0, 0, 0, 0, 0, 0, 0, 0 ]
25+
DescriptorSets:
26+
- Resources:
27+
- Name: Out
28+
Kind: RWStructuredBuffer
29+
DirectXBinding:
30+
Register: 0
31+
Space: 0
32+
VulkanBinding:
33+
Binding: 0
34+
...
35+
36+
#--- end
37+
# UNSUPPORTED: Vulkan && !VK_KHR_shader_maximal_reconvergence
38+
39+
# BUG: https://github.com/llvm/llvm-project/issues/164496
40+
# XFAIL: Clang && Vulkan
41+
42+
# BUG: https://github.com/llvm/offload-test-suite/issues/490
43+
# XFAIL: WARP && DirectX && Clang
44+
45+
# BUG: https://github.com/llvm/llvm-project/issues/165288
46+
# XFAIL: !WARP && Clang && (DirectX || Metal)
47+
48+
# RUN: split-file %s %t
49+
# RUN: %dxc_target -T cs_6_5 -fspv-enable-maximal-reconvergence -Fo %t.o %t/source.hlsl
50+
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s
51+
52+
# CHECK: Name: Out
53+
# CHECK: Format: UInt32
54+
# CHECK: Data: [ 0, 1, 2, 3, 4, 5, 6, 7 ]
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#--- source.hlsl
2+
RWStructuredBuffer<uint> Out : register(u0);
3+
4+
[numthreads(8,1,1)]
5+
void main(uint3 TID : SV_GroupThreadID) {
6+
// First non-uniform branch
7+
if (TID.x < 4) {
8+
// Second non-uniform branch
9+
if (TID.x % 2 == 0) {
10+
Out[TID.x] = WaveActiveSum(TID.x);
11+
} else {
12+
Out[TID.x] = WaveActiveMax(TID.x);
13+
}
14+
// Must reconverge here with maximal reconvergence
15+
Out[TID.x] += WaveActiveMax(TID.x);
16+
} else {
17+
Out[4] = WaveActiveMax(TID.x);
18+
}
19+
Out[TID.x] += WaveActiveMax(TID.x);
20+
}
21+
22+
//--- pipeline.yaml
23+
24+
---
25+
Shaders:
26+
- Stage: Compute
27+
Entry: main
28+
DispatchSize: [1, 1, 1]
29+
Buffers:
30+
- Name: Out
31+
Format: UInt32
32+
Data: [ 0, 0, 0, 0, 0, 0, 0, 0 ]
33+
DescriptorSets:
34+
- Resources:
35+
- Name: Out
36+
Kind: RWStructuredBuffer
37+
DirectXBinding:
38+
Register: 0
39+
Space: 0
40+
VulkanBinding:
41+
Binding: 0
42+
...
43+
44+
#--- end
45+
# UNSUPPORTED: Vulkan && !VK_KHR_shader_maximal_reconvergence
46+
47+
# BUG: https://github.com/llvm/offload-test-suite/issues/490
48+
# XFAIL: WARP && DirectX
49+
50+
# BUG: https://github.com/llvm/llvm-project/issues/165288
51+
# XFAIL: !WARP && Clang && (DirectX || Metal)
52+
53+
# RUN: split-file %s %t
54+
# RUN: %dxc_target -T cs_6_0 -fspv-enable-maximal-reconvergence -Fo %t.o %t/source.hlsl
55+
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s
56+
57+
# CHECK: Name: Out
58+
# CHECK: Format: UInt32
59+
# CHECK: Data: [ 12, 13, 12, 13, 14, 7, 7, 7 ]

0 commit comments

Comments
 (0)