Skip to content

Commit d74fa87

Browse files
authored
Add offload-test-suite support for ldexp (#200)
Closes #95. - Test for Half type (`ldexp.fp16.test`) - Test for 32 bit types (`ldexp.32.test`)
1 parent 14fd423 commit d74fa87

File tree

2 files changed

+156
-0
lines changed

2 files changed

+156
-0
lines changed

test/Feature/HLSLLib/ldexp.16.test

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<half4> In : register(t0);
4+
RWStructuredBuffer<half4> Out : register(u1);
5+
6+
[numthreads(1,1,1)]
7+
void main() {
8+
// X Exp
9+
// ------------------
10+
// 0x4248 0x8000
11+
// 0x0000 0x3C00
12+
// 0xFC00 0xB800
13+
// 0x7E00 0x7C00
14+
// 0x8000 0x3C00
15+
// 0x3C00 0x0000
16+
// 0xB800 0xFC00
17+
// 0x7C00 0x7E00
18+
// 0x4248 0xB800
19+
// 0x0000 0x7C00
20+
// 0x3C00 0x4C00 (overflow)
21+
// 0x3C00 0xCE40 (underflow)
22+
Out[0] = ldexp(In[0], In[1]);
23+
Out[1].x = ldexp(In[1].x, In[1].y);
24+
Out[1].yzw = ldexp(In[1].yzw, In[0].yzw);
25+
Out[2].xy = ldexp(In[0].xy, In[1].zw);
26+
Out[2].zw = ldexp(In[2].xy, In[2].zw);
27+
}
28+
29+
//--- pipeline.yaml
30+
31+
---
32+
Shaders:
33+
- Stage: Compute
34+
Entry: main
35+
DispatchSize: [1, 1, 1]
36+
Buffers:
37+
- Name: In
38+
Format: Float16
39+
Stride: 8
40+
Data: [ 0x4248, 0x0000, 0xFC00, 0x7E00, 0x8000, 0x3C00, 0xB800, 0x7C00, 0x3C00, 0x3C00, 0x4C00, 0xCE40 ] # [ 3.140625, 0, -inf, NaN, -0, 1, -0.5, inf, 1, 1, 16, -25 ]
41+
- Name: Out
42+
Format: Float16
43+
Stride: 8
44+
ZeroInitSize: 24
45+
- Name: ExpectedOut # The result we expect
46+
Format: Float16
47+
Stride: 8
48+
Data: [ 0x4248, 0x0000, 0xFC00, 0x7E00, 0x8000, 0x3C00, 0x8000, 0x7E00, 0x4071, 0x7E00, 0x7C00, 0x0000 ] # [ 3.140625, 0, -inf, NaN, -0, 1, -0, NaN, 2.220703, NaN, inf, 0 ]
49+
Results:
50+
- Result: Test1
51+
Rule: BufferFuzzy
52+
ULPT: 1
53+
Actual: Out
54+
Expected: ExpectedOut
55+
DescriptorSets:
56+
- Resources:
57+
- Name: In
58+
Kind: StructuredBuffer
59+
DirectXBinding:
60+
Register: 0
61+
Space: 0
62+
VulkanBinding:
63+
Binding: 0
64+
- Name: Out
65+
Kind: RWStructuredBuffer
66+
DirectXBinding:
67+
Register: 1
68+
Space: 0
69+
VulkanBinding:
70+
Binding: 1
71+
...
72+
#--- end
73+
74+
# REQUIRES: Half
75+
76+
# UNSUPPORTED: Clang-Vulkan
77+
# RUN: split-file %s %t
78+
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
79+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/ldexp.32.test

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<float4> In : register(t0);
4+
RWStructuredBuffer<float4> Out : register(u1);
5+
6+
[numthreads(1,1,1)]
7+
void main() {
8+
// X Exp
9+
// ------------------
10+
// 3.14159 -0
11+
// 0 1
12+
// -inf -0.5
13+
// NaN inf
14+
// -0 1
15+
// 1 0
16+
// -0.5 -inf
17+
// inf NaN
18+
// 3.14159 -0.5
19+
// 0 inf
20+
// 1 128 (overflow)
21+
// 1 -150 (underflow)
22+
Out[0] = ldexp(In[0], In[1]);
23+
Out[1].x = ldexp(In[1].x, In[1].y);
24+
Out[1].yzw = ldexp(In[1].yzw, In[0].yzw);
25+
Out[2].xy = ldexp(In[0].xy, In[1].zw);
26+
Out[2].zw = ldexp(In[2].xy, In[2].zw);
27+
}
28+
29+
//--- pipeline.yaml
30+
31+
---
32+
Shaders:
33+
- Stage: Compute
34+
Entry: main
35+
DispatchSize: [1, 1, 1]
36+
Buffers:
37+
- Name: In
38+
Format: Float32
39+
Stride: 16
40+
Data: [ 3.14159, 0, -inf, NaN, -0, 1, -0.5, inf, 1, 1, 128, -150 ]
41+
- Name: Out
42+
Format: Float32
43+
Stride: 16
44+
ZeroInitSize: 48
45+
- Name: ExpectedOut # The result we expect
46+
Format: Float32
47+
Stride: 16
48+
Data: [ 3.14159, 0, -inf, NaN, -0, 1, -0, NaN, 2.2214396, NaN, inf, 0 ]
49+
Results:
50+
- Result: Test1
51+
Rule: BufferFuzzy
52+
ULPT: 1
53+
Actual: Out
54+
Expected: ExpectedOut
55+
DescriptorSets:
56+
- Resources:
57+
- Name: In
58+
Kind: StructuredBuffer
59+
DirectXBinding:
60+
Register: 0
61+
Space: 0
62+
VulkanBinding:
63+
Binding: 0
64+
- Name: Out
65+
Kind: RWStructuredBuffer
66+
DirectXBinding:
67+
Register: 1
68+
Space: 0
69+
VulkanBinding:
70+
Binding: 1
71+
...
72+
#--- end
73+
74+
# UNSUPPORTED: Clang-Vulkan
75+
# RUN: split-file %s %t
76+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
77+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)