Skip to content

Commit 44c9a64

Browse files
bob80905Finn Plummer
andauthored
Add WaveReadLaneAt tests (#349)
This PR implements testing for the WaveReadLaneAt intrinsic. It's an improved copy of @inbelic's work here: #295 - WaveReadLaneAt.[16|32|64].test adds testing of the basic types (and vectors) - WaveReadLaneAt.udt.test adds testing for a matrix, user defined struct and for floating point edge-case values - WaveReadLaneAt.index.test adds testing of various use-cases with different indices Resolves: #144 --------- Co-authored-by: Finn Plummer <[email protected]>
1 parent 53a117a commit 44c9a64

9 files changed

+906
-0
lines changed

test/WaveOps/WaveReadLaneAt.16.test

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<int16_t4> InInt : register(t0);
4+
RWStructuredBuffer<int16_t4> OutInt : register(u1);
5+
6+
StructuredBuffer<uint16_t4> InUInt : register(t2);
7+
RWStructuredBuffer<uint16_t4> OutUInt : register(u3);
8+
9+
StructuredBuffer<float16_t4> InFloat : register(t4);
10+
RWStructuredBuffer<float16_t4> OutFloat : register(u5);
11+
12+
[numthreads(4,1,1)]
13+
void main(uint32_t3 TID : SV_GroupThreadID) {
14+
uint OutIdx = TID.x * 3;
15+
16+
// Int
17+
OutInt[OutIdx] = WaveReadLaneAt(InInt[TID.x], TID.x);
18+
uint16_t4 ThreadInInt = {InInt[TID.x].xyz, InInt[TID.x].w};
19+
OutInt[OutIdx + 1] = WaveReadLaneAt(ThreadInInt, TID.x);;
20+
OutInt[OutIdx + 2].xy = WaveReadLaneAt(InInt[TID.x].xy, TID.x);
21+
22+
// UInt
23+
OutUInt[OutIdx] = WaveReadLaneAt(InUInt[TID.x], TID.x);
24+
int16_t4 ThreadInUInt = {InUInt[TID.x].xyz, InUInt[TID.x].w};
25+
OutUInt[OutIdx + 1] = WaveReadLaneAt(ThreadInUInt, TID.x);;
26+
OutUInt[OutIdx + 2].xy = WaveReadLaneAt(InUInt[TID.x].xy, TID.x);
27+
28+
// Float
29+
OutFloat[OutIdx] = WaveReadLaneAt(InFloat[TID.x], TID.x);
30+
float16_t4 ThreadInFloat = {InFloat[TID.x].xyz, InFloat[TID.x].w};
31+
OutFloat[OutIdx + 1] = WaveReadLaneAt(ThreadInFloat, TID.x);;
32+
OutFloat[OutIdx + 2].xy = WaveReadLaneAt(InFloat[TID.x].xy, TID.x);
33+
}
34+
35+
//--- pipeline.yaml
36+
37+
---
38+
Shaders:
39+
- Stage: Compute
40+
Entry: main
41+
DispatchSize: [4, 1, 1]
42+
Buffers:
43+
- Name: InInt
44+
Format: Int16
45+
Stride: 8
46+
Data: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]
47+
- Name: OutInt
48+
Format: Int16
49+
Stride: 8
50+
ZeroInitSize: 72
51+
- Name: ExpectedOutInt # The result we expect
52+
Format: Int16
53+
Stride: 8
54+
Data: [ 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 0, 0, 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 0, 0, 8, 9, 10, 11, 8, 9, 10, 11, 8, 9, 0, 0 ]
55+
- Name: InUInt
56+
Format: UInt16
57+
Stride: 8
58+
Data: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]
59+
- Name: OutUInt
60+
Format: UInt16
61+
Stride: 8
62+
ZeroInitSize: 72
63+
- Name: ExpectedOutUInt # The result we expect
64+
Format: UInt16
65+
Stride: 8
66+
Data: [ 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 0, 0, 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 0, 0, 8, 9, 10, 11, 8, 9, 10, 11, 8, 9, 0, 0 ]
67+
- Name: InFloat
68+
Format: Float16
69+
Stride: 8
70+
Data: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]
71+
- Name: OutFloat
72+
Format: Float16
73+
Stride: 8
74+
ZeroInitSize: 72
75+
- Name: ExpectedOutFloat # The result we expect
76+
Format: Float16
77+
Stride: 8
78+
Data: [ 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 0, 0, 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 0, 0, 8, 9, 10, 11, 8, 9, 10, 11, 8, 9, 0, 0 ]
79+
Results:
80+
- Result: TestInt
81+
Rule: BufferExact
82+
Actual: OutInt
83+
Expected: ExpectedOutInt
84+
- Result: TestUInt
85+
Rule: BufferExact
86+
Actual: OutUInt
87+
Expected: ExpectedOutUInt
88+
- Result: TestFloat
89+
Rule: BufferExact
90+
Actual: OutFloat
91+
Expected: ExpectedOutFloat
92+
DescriptorSets:
93+
- Resources:
94+
- Name: InInt
95+
Kind: StructuredBuffer
96+
DirectXBinding:
97+
Register: 0
98+
Space: 0
99+
VulkanBinding:
100+
Binding: 0
101+
- Name: OutInt
102+
Kind: RWStructuredBuffer
103+
DirectXBinding:
104+
Register: 1
105+
Space: 0
106+
VulkanBinding:
107+
Binding: 1
108+
- Name: InUInt
109+
Kind: StructuredBuffer
110+
DirectXBinding:
111+
Register: 2
112+
Space: 0
113+
VulkanBinding:
114+
Binding: 2
115+
- Name: OutUInt
116+
Kind: RWStructuredBuffer
117+
DirectXBinding:
118+
Register: 3
119+
Space: 0
120+
VulkanBinding:
121+
Binding: 3
122+
- Name: InFloat
123+
Kind: StructuredBuffer
124+
DirectXBinding:
125+
Register: 4
126+
Space: 0
127+
VulkanBinding:
128+
Binding: 4
129+
- Name: OutFloat
130+
Kind: RWStructuredBuffer
131+
DirectXBinding:
132+
Register: 5
133+
Space: 0
134+
VulkanBinding:
135+
Binding: 5
136+
...
137+
#--- end
138+
# Tracked by https://github.com/llvm/offload-test-suite/issues/351
139+
# XFAIL: Metal
140+
141+
# REQUIRES: Half, Int16
142+
143+
# RUN: split-file %s %t
144+
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
145+
# RUN: %offloader %t/pipeline.yaml %t.o

test/WaveOps/WaveReadLaneAt.32.test

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<int4> InInt : register(t0);
4+
RWStructuredBuffer<int4> OutInt : register(u1);
5+
6+
StructuredBuffer<uint4> InUInt : register(t2);
7+
RWStructuredBuffer<uint4> OutUInt : register(u3);
8+
9+
StructuredBuffer<float4> InFloat : register(t4);
10+
RWStructuredBuffer<float4> OutFloat : register(u5);
11+
12+
// Checks for edge-case floats
13+
StructuredBuffer<float> InEdgeFloat : register(t6);
14+
RWStructuredBuffer<float> OutEdgeFloat : register(u7);
15+
16+
[numthreads(4,1,1)]
17+
void main(uint3 TID : SV_GroupThreadID) {
18+
uint OutIdx = TID.x * 3;
19+
20+
// Int
21+
OutInt[OutIdx] = WaveReadLaneAt(InInt[TID.x], TID.x);
22+
uint4 ThreadInInt = {InInt[TID.x].xyz, InInt[TID.x].w};
23+
OutInt[OutIdx + 1] = WaveReadLaneAt(ThreadInInt, TID.x);
24+
OutInt[OutIdx + 2].xy = WaveReadLaneAt(InInt[TID.x].xy, TID.x);
25+
26+
// UInt
27+
OutUInt[OutIdx] = WaveReadLaneAt(InUInt[TID.x], TID.x);
28+
uint4 ThreadInUInt = {InUInt[TID.x].xyz, InUInt[TID.x].w};
29+
OutUInt[OutIdx + 1] = WaveReadLaneAt(ThreadInUInt, TID.x);
30+
OutUInt[OutIdx + 2].xy = WaveReadLaneAt(InUInt[TID.x].xy, TID.x);
31+
32+
// Float
33+
OutFloat[OutIdx] = WaveReadLaneAt(InFloat[TID.x], TID.x);
34+
uint4 ThreadInFloat = {InFloat[TID.x].xyz, InFloat[TID.x].w};
35+
OutFloat[OutIdx + 1] = WaveReadLaneAt(ThreadInFloat, TID.x);
36+
OutFloat[OutIdx + 2].xy = WaveReadLaneAt(InFloat[TID.x].xy, TID.x);
37+
38+
// Edge-Cases
39+
OutEdgeFloat[TID.x] = WaveReadLaneAt(InEdgeFloat[TID.x], TID.x);
40+
}
41+
42+
//--- pipeline.yaml
43+
44+
---
45+
Shaders:
46+
- Stage: Compute
47+
Entry: main
48+
DispatchSize: [4, 1, 1]
49+
Buffers:
50+
- Name: InInt
51+
Format: Int32
52+
Stride: 16
53+
Data: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]
54+
- Name: OutInt
55+
Format: Int32
56+
Stride: 16
57+
ZeroInitSize: 144
58+
- Name: ExpectedOutInt # The result we expect
59+
Format: Int32
60+
Stride: 16
61+
Data: [ 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 0, 0, 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 0, 0, 8, 9, 10, 11, 8, 9, 10, 11, 8, 9, 0, 0 ]
62+
- Name: InUInt
63+
Format: UInt32
64+
Stride: 16
65+
Data: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]
66+
- Name: OutUInt
67+
Format: UInt32
68+
Stride: 16
69+
ZeroInitSize: 144
70+
- Name: ExpectedOutUInt # The result we expect
71+
Format: UInt32
72+
Stride: 16
73+
Data: [ 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 0, 0, 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 0, 0, 8, 9, 10, 11, 8, 9, 10, 11, 8, 9, 0, 0 ]
74+
- Name: InFloat
75+
Format: Float32
76+
Stride: 16
77+
Data: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]
78+
- Name: OutFloat
79+
Format: Float32
80+
Stride: 16
81+
ZeroInitSize: 144
82+
- Name: ExpectedOutFloat # The result we expect
83+
Format: Float32
84+
Stride: 16
85+
Data: [ 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 0, 0, 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 0, 0, 8, 9, 10, 11, 8, 9, 10, 11, 8, 9, 0, 0 ]
86+
- Name: InEdgeFloat
87+
Format: Float32
88+
Stride: 4
89+
Data: [inf, -inf, nan, 0 ]
90+
- Name: OutEdgeFloat
91+
Format: Float32
92+
Stride: 4
93+
ZeroInitSize: 16
94+
- Name: ExpectedOutEdgeFloat # The result we expect
95+
Format: Float32
96+
Stride: 4
97+
Data: [ inf, -inf, nan, 0]
98+
Results:
99+
- Result: TestInt
100+
Rule: BufferExact
101+
Actual: OutInt
102+
Expected: ExpectedOutInt
103+
- Result: TestUInt
104+
Rule: BufferExact
105+
Actual: OutUInt
106+
Expected: ExpectedOutUInt
107+
- Result: TestFloat
108+
Rule: BufferExact
109+
Actual: OutFloat
110+
Expected: ExpectedOutFloat
111+
- Result: TestEdgeFloat
112+
Rule: BufferExact
113+
Actual: OutEdgeFloat
114+
Expected: ExpectedOutEdgeFloat
115+
DescriptorSets:
116+
- Resources:
117+
- Name: InInt
118+
Kind: StructuredBuffer
119+
DirectXBinding:
120+
Register: 0
121+
Space: 0
122+
VulkanBinding:
123+
Binding: 0
124+
- Name: OutInt
125+
Kind: RWStructuredBuffer
126+
DirectXBinding:
127+
Register: 1
128+
Space: 0
129+
VulkanBinding:
130+
Binding: 1
131+
- Name: InUInt
132+
Kind: StructuredBuffer
133+
DirectXBinding:
134+
Register: 2
135+
Space: 0
136+
VulkanBinding:
137+
Binding: 2
138+
- Name: OutUInt
139+
Kind: RWStructuredBuffer
140+
DirectXBinding:
141+
Register: 3
142+
Space: 0
143+
VulkanBinding:
144+
Binding: 3
145+
- Name: InFloat
146+
Kind: StructuredBuffer
147+
DirectXBinding:
148+
Register: 4
149+
Space: 0
150+
VulkanBinding:
151+
Binding: 4
152+
- Name: OutFloat
153+
Kind: RWStructuredBuffer
154+
DirectXBinding:
155+
Register: 5
156+
Space: 0
157+
VulkanBinding:
158+
Binding: 5
159+
- Name: InEdgeFloat
160+
Kind: StructuredBuffer
161+
DirectXBinding:
162+
Register: 6
163+
Space: 0
164+
VulkanBinding:
165+
Binding: 6
166+
- Name: OutEdgeFloat
167+
Kind: RWStructuredBuffer
168+
DirectXBinding:
169+
Register: 7
170+
Space: 0
171+
VulkanBinding:
172+
Binding: 7
173+
...
174+
#--- end
175+
# Tracked by https://github.com/llvm/offload-test-suite/issues/351
176+
# XFAIL: Metal
177+
178+
179+
# RUN: split-file %s %t
180+
# RUN: %dxc_target -T cs_6_5 -Gis -Fo %t.o %t/source.hlsl
181+
# RUN: %offloader %t/pipeline.yaml %t.o

test/WaveOps/WaveReadLaneAt.Bool.test

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<bool4> InBool : register(t0);
4+
RWStructuredBuffer<bool4> OutBool : register(u1);
5+
6+
7+
[numthreads(4,1,1)]
8+
void main(uint32_t3 TID : SV_GroupThreadID) {
9+
uint OutIdx = TID.x * 3;
10+
11+
// Bool
12+
OutBool[OutIdx] = WaveReadLaneAt(InBool[TID.x], TID.x);
13+
bool4 ThreadInBool = {InBool[TID.x].xyz, InBool[TID.x].w};
14+
OutBool[OutIdx + 1] = WaveReadLaneAt(ThreadInBool, TID.x);
15+
OutBool[OutIdx + 2].xy = WaveReadLaneAt(InBool[TID.x].xy, TID.x);
16+
}
17+
18+
//--- pipeline.yaml
19+
20+
---
21+
Shaders:
22+
- Stage: Compute
23+
Entry: main
24+
DispatchSize: [4, 1, 1]
25+
Buffers:
26+
- Name: InBool
27+
Format: Bool
28+
Stride: 16
29+
Data: [ 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1 ]
30+
- Name: OutBool
31+
Format: Bool
32+
Stride: 16
33+
ZeroInitSize: 144
34+
- Name: ExpectedOutBool # The result we expect
35+
Format: Bool
36+
Stride: 16
37+
Data: [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0 ]
38+
Results:
39+
- Result: TestBool
40+
Rule: BufferExact
41+
Actual: OutBool
42+
Expected: ExpectedOutBool
43+
DescriptorSets:
44+
- Resources:
45+
- Name: InBool
46+
Kind: StructuredBuffer
47+
DirectXBinding:
48+
Register: 0
49+
Space: 0
50+
VulkanBinding:
51+
Binding: 0
52+
- Name: OutBool
53+
Kind: RWStructuredBuffer
54+
DirectXBinding:
55+
Register: 1
56+
Space: 0
57+
VulkanBinding:
58+
Binding: 1
59+
...
60+
#--- end
61+
# https://github.com/llvm/llvm-project/issues/140824
62+
# XFAIL: Clang
63+
64+
# RUN: split-file %s %t
65+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
66+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)