Skip to content

Add offload-test-suite support for ldexp #200

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 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
62 changes: 62 additions & 0 deletions test/Feature/HLSLLib/ldexp.32.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#--- source.hlsl

StructuredBuffer<float4> In : register(t0);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we use float4 instead of float?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way each version can easily be tested. If it was float, a float4, etc, would need to be constructed.
Line 8 tests the float4 version of ldexp, like 10 tests float3 etc

RWStructuredBuffer<float4> Out : register(u1);

[numthreads(1,1,1)]
void main() {
Out[0] = ldexp(In[0], In[1]);
Out[1].x = ldexp(In[1].x, In[1].y);
Out[1].yzw = ldexp(In[1].yzw, In[0].yzw);
Out[2].xy = ldexp(In[0].xy, In[1].yw);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be helpful to add a comment showing what value combinations are being tested; I believe this is correct (but the formatting is messed up)

// Num       Exp
// 3.14159  1
// 0             1.5
// -inf          -0.5
// Nan         inf
// 3.14159   0
// 1.5           0
// -.05         -inf
// inf           Nan
// 3.14159  1.5
// 0             inf

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this in the main function but didn't know if that made sense. Lmk if you think there's a better place to move it


//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: In
Format: Float32
Stride: 16
Data: [ 3.14159, 0, -inf, NaN, 1, 1.5, -0.5, inf ]
- Name: Out
Format: Float32
Stride: 16
ZeroInitSize: 48
- Name: ExpectedOut # The result we expect
Format: Float32
Stride: 16
Data: [ 6.28318, 0, -inf, NaN, 2.828427, 1.5, -0, NaN, 8.885758, NaN, 0, 0 ]
Results:
- Result: Test1
Rule: BufferFuzzy
ULPT: 1
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

# UNSUPPORTED: Clang-Vulkan
# 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
64 changes: 64 additions & 0 deletions test/Feature/HLSLLib/ldexp.fp16.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#--- source.hlsl

StructuredBuffer<half4> In : register(t0);
RWStructuredBuffer<half4> Out : register(u1);

[numthreads(1,1,1)]
void main() {
Out[0] = ldexp(In[0], In[1]);
Out[1].x = ldexp(In[1].x, In[1].y);
Out[1].yzw = ldexp(In[1].yzw, In[0].yzw);
Out[2].xy = ldexp(In[0].xy, In[1].yw);
}

//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: In
Format: Float16
Stride: 8
Data: [ 0x4248, 0x0000, 0xFC00, 0x7E00, 0x3C00, 0x3E00, 0xB800, 0x7C00 ]
- Name: Out
Format: Float16
Stride: 8
ZeroInitSize: 24
- Name: ExpectedOut # The result we expect
Format: Float16
Stride: 8
Data: [ 0x4648, 0x0000, 0xFC00, 0x7E00, 0x41A8, 0x3E00, 0x8000, 0x7E00, 0x4871, 0x7E00, 0x0000, 0x0000 ]
Results:
- Result: Test1
Rule: BufferFuzzy
ULPT: 1
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

# UNSUPPORTED: Clang-Vulkan
# 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
Loading