diff --git a/test/Feature/MaximalReconvergence/loop_peeling.test b/test/Feature/MaximalReconvergence/loop_peeling.test new file mode 100644 index 00000000..1143f628 --- /dev/null +++ b/test/Feature/MaximalReconvergence/loop_peeling.test @@ -0,0 +1,44 @@ +#--- source.hlsl +RWStructuredBuffer Out : register(u0); + +[numthreads(8,1,1)] +void main(uint3 TID : SV_GroupThreadID) { + for (uint i = 0; i < 8; i++) { + if (i == TID.x) { + Out[TID.x] = WaveActiveMax(TID.x); + break; + } + } +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: Out + Format: UInt32 + Data: [ 0, 0, 0, 0, 0, 0, 0, 0 ] +DescriptorSets: + - Resources: + - Name: Out + Kind: RWStructuredBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... + +#--- end + +# RUN: split-file %s %t +# RUN: %dxc_target -T cs_6_5 -fspv-enable-maximal-reconvergence -Fo %t.o %t/source.hlsl +# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s + +# CHECK: Name: Out +# CHECK: Format: UInt32 +# CHECK: Data: [ 0, 1, 2, 3, 4, 5, 6, 7 ] diff --git a/test/Feature/MaximalReconvergence/subgroup_uniform_control_flow.test b/test/Feature/MaximalReconvergence/subgroup_uniform_control_flow.test new file mode 100644 index 00000000..ccfe1dbf --- /dev/null +++ b/test/Feature/MaximalReconvergence/subgroup_uniform_control_flow.test @@ -0,0 +1,52 @@ +#--- source.hlsl +RWStructuredBuffer Out : register(u0); + +[numthreads(8,1,1)] +void main(uint3 TID : SV_GroupThreadID) { + // First non-uniform branch + if (TID.x < 4) { + // Second non-uniform branch + if (TID.x % 2 == 0) { + Out[TID.x] = WaveActiveSum(TID.x); + } else { + Out[TID.x] = WaveActiveMax(TID.x); + } + // Must reconverge here with maximal reconvergence + Out[TID.x] += WaveActiveMax(TID.x); + } else { + Out[4] = WaveActiveMax(TID.x); + } + Out[TID.x] += WaveActiveMax(TID.x); +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: Out + Format: UInt32 + Data: [ 0, 0, 0, 0, 0, 0, 0, 0 ] +DescriptorSets: + - Resources: + - Name: Out + Kind: RWStructuredBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... + +#--- end + +# RUN: split-file %s %t +# RUN: %dxc_target -T cs_6_0 -fspv-enable-maximal-reconvergence -Fo %t.o %t/source.hlsl +# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s + +# CHECK: Name: Out +# CHECK: Format: UInt32 +# CHECK: Data: [ 12, 13, 12, 13, 14, 7, 7, 7 ]