Skip to content

Commit 5aa4602

Browse files
Icohedrontex3d
andauthored
Add tests for sin and cos on 32-bit NaN, Inf, and denorm values (#702)
As a follow up to #699 this PR re-adds the NaN, Inf, and denorm tests for sin and cos as separate test files. This PR also adds a new feature flag for Apple M1 (`AppleM1`) to XFAIL non Apple M1 devices, a bug being tracked by #701 --------- Co-authored-by: Tex Riddell <texr@microsoft.com>
1 parent 0d2bfd8 commit 5aa4602

3 files changed

Lines changed: 147 additions & 0 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<float4> In : register(t0);
4+
5+
RWStructuredBuffer<float4> Out : register(u1);
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
float4 Tmp = {cos(In[0].x), cos(In[0].yzw)};
10+
Out[0] = Tmp;
11+
Out[1] = cos(In[1].xyzw);
12+
}
13+
14+
15+
//--- pipeline.yaml
16+
17+
---
18+
Shaders:
19+
- Stage: Compute
20+
Entry: main
21+
DispatchSize: [1, 1, 1]
22+
Buffers:
23+
- Name: In
24+
Format: Float32
25+
Stride: 16
26+
Data: [ nan, -inf, -0x1.e7d42cp-127, 0x1.e7d42cp-127, inf, nan, nan, nan ]
27+
# NaN, -Inf, -denorm, denorm, Inf, NaN, NaN, NaN
28+
- Name: Out
29+
Format: Float32
30+
Stride: 16
31+
FillSize: 32
32+
- Name: ExpectedOut # The result we expect
33+
Format: Float32
34+
Stride: 16
35+
Data: [ nan, nan, 1.0, 1.0, nan, nan, nan, nan ]
36+
# NaN, NaN, 1.0, 1.0, NaN, NaN, NaN, NaN
37+
Results:
38+
- Result: Test1
39+
Rule: BufferFloatEpsilon
40+
Epsilon: 0.0008
41+
Actual: Out
42+
Expected: ExpectedOut
43+
DescriptorSets:
44+
- Resources:
45+
- Name: In
46+
Kind: StructuredBuffer
47+
DirectXBinding:
48+
Register: 0
49+
Space: 0
50+
VulkanBinding:
51+
Binding: 0
52+
- Name: Out
53+
Kind: RWStructuredBuffer
54+
DirectXBinding:
55+
Register: 1
56+
Space: 0
57+
VulkanBinding:
58+
Binding: 1
59+
...
60+
#--- end
61+
62+
# Bug https://github.com/KhronosGroup/SPIRV-Cross/issues/2525
63+
# XFAIL: Vulkan && MoltenVK
64+
65+
# Bug: https://github.com/llvm/offload-test-suite/issues/701
66+
# XFAIL: Metal && !AppleM1 && Clang
67+
68+
# RUN: split-file %s %t
69+
# RUN: %dxc_target -Gis -T cs_6_5 -Fo %t.o %t/source.hlsl
70+
# RUN: %offloader %t/pipeline.yaml %t.o
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<float4> In : register(t0);
4+
5+
RWStructuredBuffer<float4> Out : register(u1);
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
float4 Tmp = {sin(In[0].x), sin(In[0].yzw)};
10+
Out[0] = Tmp;
11+
Out[1] = sin(In[1].xyzw);
12+
}
13+
14+
15+
//--- pipeline.yaml
16+
17+
---
18+
Shaders:
19+
- Stage: Compute
20+
Entry: main
21+
DispatchSize: [1, 1, 1]
22+
Buffers:
23+
- Name: In
24+
Format: Float32
25+
Stride: 16
26+
Data: [ nan, -inf, -0x1.e7d42cp-127, 0x1.e7d42cp-127, inf, nan, nan, nan ]
27+
# NaN, -Inf, -denorm, denorm, Inf, NaN, Nan, NaN
28+
- Name: Out
29+
Format: Float32
30+
Stride: 16
31+
FillSize: 32
32+
- Name: ExpectedOut # The result we expect
33+
Format: Float32
34+
Stride: 16
35+
Data: [ nan, nan, -0, 0, nan, nan, nan, nan ]
36+
# NaN, NaN, -0, 0, NaN, NaN, NaN, NaN
37+
Results:
38+
- Result: Test1
39+
Rule: BufferFloatEpsilon
40+
Epsilon: 0.0008
41+
Actual: Out
42+
Expected: ExpectedOut
43+
DescriptorSets:
44+
- Resources:
45+
- Name: In
46+
Kind: StructuredBuffer
47+
DirectXBinding:
48+
Register: 0
49+
Space: 0
50+
VulkanBinding:
51+
Binding: 0
52+
- Name: Out
53+
Kind: RWStructuredBuffer
54+
DirectXBinding:
55+
Register: 1
56+
Space: 0
57+
VulkanBinding:
58+
Binding: 1
59+
...
60+
#--- end
61+
62+
# Bug https://github.com/KhronosGroup/SPIRV-Cross/issues/2525
63+
# XFAIL: Vulkan && MoltenVK
64+
65+
# Bug: https://github.com/llvm/offload-test-suite/issues/701
66+
# XFAIL: Metal && !AppleM1 && Clang
67+
68+
# RUN: split-file %s %t
69+
# RUN: %dxc_target -Gis -T cs_6_5 -Fo %t.o %t/source.hlsl
70+
# RUN: %offloader %t/pipeline.yaml %t.o

test/lit.cfg.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ def setDeviceFeatures(config, device, compiler):
104104
config.available_features.add("AMD")
105105
if "Qualcomm" in device["Description"]:
106106
config.available_features.add("QC")
107+
if "Apple M1" in device["Description"]:
108+
# As tracked by issue
109+
# https://github.com/llvm/offload-test-suite/issues/701, Apple M1 Macs
110+
# appear to be handling NaN, Inf, and denorm 32-bit floating-point
111+
# values correctly while newer SoCs are not, even with the -Gis compiler
112+
# flag.
113+
config.available_features.add("AppleM1")
107114

108115
HighestShaderModel = getHighestShaderModel(device["Features"])
109116
if (6, 6) <= HighestShaderModel:

0 commit comments

Comments
 (0)