Skip to content
Open
141 changes: 141 additions & 0 deletions test/Feature/HLSLLib/fma.matrix.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#--- source.hlsl

StructuredBuffer<double4> A : register(t0);
StructuredBuffer<double4> B : register(t1);
StructuredBuffer<double4> C : register(t2);

RWStructuredBuffer<double4> Out : register(u3);

[numthreads(1,1,1)]
void main() {
double3x2 r32 = fma(double3x2(A[0].xyz, A[1].xyz),
double3x2(B[0].xyz, B[1].xyz),
double3x2(C[0].xyz, C[1].xyz));

double2x4 r24 = fma(double2x4(A[2], A[3]),
double2x4(B[2], B[3]),
double2x4(C[2], C[3]));

double3x1 r31 = fma(double3x1(A[4].xyz),
double3x1(B[4].xyz),
double3x1(C[4].xyz));

double4x4 r44 = fma(double4x4(A[5], A[6], A[7], A[8]),
double4x4(B[5], B[6], B[7], B[8]),
double4x4(C[5], C[6], C[7], C[8]));

Out[0] = double4(r32[0], r32[1]);
Out[1] = double4(r32[2], 0.0, 0.0);
Out[2] = r24[0];
Out[3] = r24[1];
Out[4] = double4(r31[0][0], r31[1][0], r31[2][0], 0.0);
Out[5] = r44[0];
Out[6] = r44[1];
Out[7] = r44[2];
Out[8] = r44[3];
}

//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: A
Format: Float64
Stride: 32
Data: [ 1.5, -2.5, 0.5, 0.0,
-0.5, 2.0, 3.0, 0.0,
0.25, -0.25, 10.4, -10.6,
0.0, 10.0, -10.0, 10.5,
1.25, -4.0, 2.5, 0.0,
1.0, 2.0, 3.0, 4.0,
-1.0, -2.0, -3.0, -4.0,
0.5, 1.5, -0.5, -1.5,
10.0, -10.0, 2.25, -2.25 ]
- Name: B
Format: Float64
Stride: 32
Data: [ 2.0, -1.0, 4.0, 0.0,
4.0, -0.5, 1.5, 0.0,
1.0, 1.0, 1.0, 1.0,
1.0, 2.0, -1.0, 1.0,
2.0, -0.5, 3.0, 0.0,
2.0, -1.0, 0.5, 3.0,
4.0, 0.5, -2.0, -1.0,
1.0, 2.0, 3.0, 4.0,
-0.5, 1.5, -1.0, 2.0 ]
- Name: C
Format: Float64
Stride: 32
Data: [ 0.25, 0.75, -1.5, 0.0,
1.5, 1.0, -2.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.5, 0.5, 0.0,
0.5, 1.0, -1.5, 0.0,
0.5, 1.0, -1.5, 0.0,
-0.5, 2.0, 1.0, 3.0,
1.5, -2.0, 0.5, -4.0,
5.0, -5.0, 0.25, -0.25 ]
- Name: Out
Format: Float64
Stride: 32
FillSize: 288
- Name: Expected
Format: Float64
Stride: 32
Data: [ 3.25, 3.25, 0.5, -0.5,
0.0, 2.5, 0.0, 0.0,
0.25, -0.25, 10.4, -10.6,
0.0, 20.5, 10.5, 10.5,
3.0, 3.0, 6.0, 0.0,
2.5, -1.0, 0.0, 12.0,
-4.5, 1.0, 7.0, 7.0,
2.0, 1.0, -1.0, -10.0,
0.0, -20.0, -2.0, -4.75 ]
Results:
- Result: Result
Rule: BufferExact
Actual: Out
Expected: Expected
DescriptorSets:
- Resources:
- Name: A
Kind: StructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: B
Kind: StructuredBuffer
DirectXBinding:
Register: 1
Space: 0
VulkanBinding:
Binding: 1
- Name: C
Kind: StructuredBuffer
DirectXBinding:
Register: 2
Space: 0
VulkanBinding:
Binding: 2
- Name: Out
Kind: RWStructuredBuffer
DirectXBinding:
Register: 3
Space: 0
VulkanBinding:
Binding: 3
#--- end

# Bug https://github.com/llvm/offload-test-suite/issues/1000
# XFAIL: arm64 && WARP

# REQUIRES: Double
# RUN: split-file %s %t
# RUN: %dxc_target -Gis -HV 202x -T cs_6_5 -Fo %t.o %t/source.hlsl
# RUN: %offloader %t/pipeline.yaml %t.o
104 changes: 104 additions & 0 deletions test/Feature/HLSLLib/fma.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#--- source.hlsl

StructuredBuffer<double4> A : register(t0);
StructuredBuffer<double4> B : register(t1);
StructuredBuffer<double4> C : register(t2);

RWStructuredBuffer<double4> Out : register(u3);

[numthreads(1,1,1)]
void main() {
Out[0] = fma(A[0], B[0], C[0]);
Out[1] = double4(fma(A[1].xyz, B[1].xyz, C[1].xyz), fma(A[1].w, B[1].w, C[1].w));
Out[2] = double4(fma(A[2].xy, B[2].xy, C[2].xy), fma(A[2].zw, B[2].zw, C[2].zw));
Out[3] = fma(double4(1.0000000149011612l, -1.0000000149011612l, 1.0000000000000002l, 0.5l), double4(67108865.0l, 67108865.0l, -0.9999999999999998l, -8.0l), double4(-67108866.0l, 67108866.0l, 1.0l, 1.0l));
}

//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: A
Format: Float64
Stride: 32
Data: [ 1.5, -2.0, 0.75, -3.25,
2.5, -4.0, 1.25, 3.5,
1.0000000149011612, -1.0000000149011612, 1.0000000000000002, 0.5 ]
# last row: (1 + 2^-26), -(1 + 2^-26), (1 + 2^-52), 0.5
- Name: B
Format: Float64
Stride: 32
Data: [ 2.25, 4.5, -8.0, -2.0,
-1.5, -2.0, 8.0, -2.0,
67108865.0, 67108865.0, -0.9999999999999998, -8.0 ]
# last row: (2^26 + 1), (2^26 + 1), -(1 - 2^-52), -8
- Name: C
Format: Float64
Stride: 32
Data: [ 0.125, 1.25, 2.5, -0.5,
0.25, -1.5, -0.75, 0.5,
-67108866.0, 67108866.0, 1.0, 1.0 ]
# last row: -(2^26 + 2), (2^26 + 2), 1, 1
- Name: Out
Format: Float64
Stride: 32
FillSize: 128
- Name: Expected
Format: Float64
Stride: 32
Data: [ 3.5, -7.75, -3.5, 6.0,
-3.5, 6.5, 9.25, -6.5,
0x1.0000000000000p-26, -0x1.0000000000000p-26, 0x1.0000000000000p-104, -3.0,
0x1.0000000000000p-26, -0x1.0000000000000p-26, 0x1.0000000000000p-104, -3.0 ]
# last two rows: 2^-26, -(2^-26), 2^-104, -3
Results:
- Result: Result
Rule: BufferExact
Actual: Out
Expected: Expected
DescriptorSets:
- Resources:
- Name: A
Kind: StructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: B
Kind: StructuredBuffer
DirectXBinding:
Register: 1
Space: 0
VulkanBinding:
Binding: 1
- Name: C
Kind: StructuredBuffer
DirectXBinding:
Register: 2
Space: 0
VulkanBinding:
Binding: 2
- Name: Out
Kind: RWStructuredBuffer
DirectXBinding:
Register: 3
Space: 0
VulkanBinding:
Binding: 3
#--- end

# Bug https://github.com/llvm/offload-test-suite/issues/1000
# XFAIL: arm64 && WARP

# Bug https://github.com/llvm/offload-test-suite/issues/1026
# XFAIL: Intel && Vulkan && DXC

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