Skip to content

add tests for rcp #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions test/Feature/HLSLLib/rcp.16.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#--- source.hlsl

StructuredBuffer<half4> In : register(t0);

RWStructuredBuffer<half4> Out : register(u1);

[numthreads(1,1,1)]
void main() {
Out[0] = rcp(In[0]);
half4 Tmp = {rcp(In[1].xyz), rcp(In[1].w)};
Out[1] = Tmp;
half4 Tmp2 = {rcp(In[2].xy), rcp(In[2].zw)};
Out[2] = Tmp2;
}


//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: In
Format: Float16
Stride: 8
Data: [ 0x7e00, 0xfc00, 0x8001, 0x8000, 0x0000, 0x0001, 0x7c00, 0x3c00, 0xbc00, 0x4100, 0xb400, 0x4000]
# NaN, -Inf, -denorm, -0, 0, denorm, Inf, 1, -1, 2.5, -0.25, 2
- Name: Out
Format: Float16
Stride: 8
ZeroInitSize: 24
- Name: ExpectedOut # The result we expect
Format: Float16
Stride: 8
Data: [ 0x7e00, 0x8000, 0xfc00, 0xfc00, 0x7c00, 0x7c00, 0x0, 0x3c00, 0xbc00, 0x3666, 0xc400, 0x3800]
# NaN, -0, -Inf, -Inf, Inf, Inf, 0, 1, -1, 0.4, -4, 0.5
Results:
- Result: Test1
Rule: BufferFloatULP
ULPT: 2
Actual: Out
Expected: ExpectedOut
DescriptorSets:
- Resources:
- Name: In
Kind: StructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: Out
Kind: RWStructuredBuffer
DirectXBinding:
Register: 1
Space: 0
VulkanBinding:
Binding: 1
...
#--- end

# REQUIRES: Half
# RUN: split-file %s %t
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
# RUN: %offloader %t/pipeline.yaml %t.o
67 changes: 67 additions & 0 deletions test/Feature/HLSLLib/rcp.32.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#--- source.hlsl

StructuredBuffer<float4> In : register(t0);

RWStructuredBuffer<float4> Out : register(u1);

[numthreads(1,1,1)]
void main() {
Out[0] = rcp(In[0]);
float4 Tmp = {rcp(In[1].xyz), rcp(In[1].w)};
Out[1] = Tmp;
float4 Tmp2 = {rcp(In[2].xy), rcp(In[2].zw)};
Out[2] = Tmp2;
}


//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: In
Format: Float32
Stride: 16
Data: [ nan, -inf, -0x1.e7d42cp-127, -0, 0, 0x1.e7d42cp-127, inf, 1, -1, 2.5, -0.25, 2]
# NaN, -Inf, -denorm, -0, 0, denorm, Inf, 1, -1, 2.5, -0.25, 2
- Name: Out
Format: Float32
Stride: 16
ZeroInitSize: 48
- Name: ExpectedOut # The result we expect
Format: Float32
Stride: 16
Data: [ nan, -0, -inf, -inf, inf, inf, 0, 1, -1, 0.4, -4 , 0.5]
# NaN, NaN, Inf, Inf, Inf, Inf, NaN, 1, -1, 0.4, -4, 0.5
Results:
- Result: Test1
Rule: BufferFloatULP
ULPT: 2
Actual: Out
Expected: ExpectedOut
DescriptorSets:
- Resources:
- Name: In
Kind: StructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: Out
Kind: RWStructuredBuffer
DirectXBinding:
Register: 1
Space: 0
VulkanBinding:
Binding: 1
...
#--- end


# RUN: split-file %s %t
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
# RUN: %offloader %t/pipeline.yaml %t.o
67 changes: 67 additions & 0 deletions test/Feature/HLSLLib/rcp.64.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#--- source.hlsl

StructuredBuffer<double4> In : register(t0);

RWStructuredBuffer<double4> Out : register(u1);

[numthreads(1,1,1)]
void main() {
Out[0] = rcp(In[0]);
float4 Tmp = {rcp(In[1].xyz), rcp(In[1].w)};
Out[1] = Tmp;
float4 Tmp2 = {rcp(In[2].xy), rcp(In[2].zw)};
Out[2] = Tmp2;
}


//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: In
Format: Float64
Stride: 32
Data: [ nan, -inf, -0x0.fffffffffffffp-1022, -0, 0, 0x0.fffffffffffffp-1022, inf, 1, -1, 2.5, -0.25, 2]
# NaN, -Inf, -denorm, -0, 0, denorm, Inf, 1, -1, 2.5, -0.25, 2
- Name: Out
Format: Float64
Stride: 32
ZeroInitSize: 96
- Name: ExpectedOut # The result we expect
Format: Float64
Stride: 32
Data: [ nan, -0, -0x1.0000000000001p+1022, -inf, inf, inf, 0, 1, -1, 0x1.99999a0000000p-2, -4 , 0.5]
# NaN, NaN, -4.49423e+307, Inf, Inf, Inf, NaN, 1, -1, 0.4, -4, 0.5
Results:
- Result: Test1
Rule: BufferFloatULP
ULPT: 2
Actual: Out
Expected: ExpectedOut
DescriptorSets:
- Resources:
- Name: In
Kind: StructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: Out
Kind: RWStructuredBuffer
DirectXBinding:
Register: 1
Space: 0
VulkanBinding:
Binding: 1
...
#--- end

# REQUIRES: Double
# RUN: split-file %s %t
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
# RUN: %offloader %t/pipeline.yaml %t.o
Loading