Skip to content

Add test for dot4add_i8packed #123

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
3 tasks
Tracked by #221
llvm-beanz opened this issue May 1, 2025 · 0 comments · May be fixed by #192
Open
3 tasks
Tracked by #221

Add test for dot4add_i8packed #123

llvm-beanz opened this issue May 1, 2025 · 0 comments · May be fixed by #192
Assignees

Comments

@llvm-beanz
Copy link
Collaborator

llvm-beanz commented May 1, 2025

Add a test to Test/Feature/HLSLLib that exercises the dot4add_i8packed function:

uint32 dot4add_i8packed(uint32 a, uint32 b, uint32 acc);

This function operates on 8-byte values packed into 32 bit words. See https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/hlsl-shader-model-6-4-features-for-direct3d-12#signed-integer-dot-product-of-4-elements-and-accumulate for details.


Generic HLSL function test guidelines follow.

A .test file should contain

  • a source portion; If multiple .test files can use the same source; it can go in its own file and be referenced in the run portion of each .test file instead.
@@ -0,0 +1,54 @@
#--- source.hlsl

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

[numthreads(1,1,1)]
void main() {
// A single test can test for all scalar/vector length as shown here.
  Out[0] = length(In[0]); // Test float4
  Out[1] = length(In[1].x); // Test float
  Out[2] = length(In[1].yzw); // Test float3
  Out[3] = length(In[1].yz); // Test float2
}
  • a yaml portion; If multiple .test files can use the same YAML, it can go in its own file and be referenced in the run portion of each .test file instead.
//--- pipeline.yaml

---
Shaders:
  - Stage: Compute
    Entry: main
    DispatchSize: [1, 1, 1]
Buffers:
  - Name: In
    Format: Float32
    Stride: 16
    Data: [ 4, 4, 4, 4, 3.14159, 0, 5, 12 ]
  - Name: Out
    Format: Float32
    Stride: 4
    ZeroInitSize: 12
  - Name: ExpectedOut # The result we expect
    Format: Float32
    Stride: 4
    Data: [ 8, 3.14159, 13, 5 ]
Results:  # A test might have more than 1 result.
  - Result: Test1
    Rule: BufferFuzzy # there is also a BufferExact rule
    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
  • A run portion; which will be unique to each .test file.
# 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 

Currently all tests should include # UNSUPPORTED: Clang-Vulkan.
Tests for 16 bit floating point should have a # REQUIRES: Half.
Tests for 16 bit integer should have a # REQUIRES: Int16.
Tests for 64 bit floating point should have a # REQUIRES: Double.
Tests for 64 bit integer should have a # REQUIRES: Int64.

@damyanp damyanp moved this to Planning in HLSL Support May 7, 2025
@bogner bogner removed their assignment May 7, 2025
@bogner bogner removed the status in HLSL Support May 7, 2025
@bogner bogner moved this to Planning in HLSL Support May 7, 2025
@bogner bogner self-assigned this May 8, 2025
@bogner bogner moved this from Planning to Ready in HLSL Support May 8, 2025
@bogner bogner moved this from Ready to Active in HLSL Support May 16, 2025
bogner added a commit to bogner/HLSLTest that referenced this issue May 16, 2025
We test `dot4add_i8packed` and `dot4add_u8packed` on the same inputs, showing
the difference in signed vs unsigned results.

Fixes llvm#123 and llvm#149.
bogner added a commit to bogner/HLSLTest that referenced this issue May 16, 2025
We test `dot4add_i8packed` and `dot4add_u8packed` on the same inputs, showing
the difference in signed vs unsigned results.

Fixes llvm#123 and llvm#149.
@bogner bogner linked a pull request May 16, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Active
Development

Successfully merging a pull request may close this issue.

2 participants