summaryrefslogtreecommitdiff
path: root/tests/cooperative-matrix/comparison.slang
blob: da4ac7a2eecf84a0a9c377d5080fbf5718807ab4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -emit-spirv-directly

// CHECK: type: uint32_t
// CHECK-NEXT: 0
// CHECK-NEXT: 1
// CHECK-NEXT: 1

//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 4.0], stride=4, count=256),name=input1
ByteAddressBuffer input1;

//TEST_INPUT:ubuffer(data=[1.0 3.0 2.0 4.0], stride=4, count=256),name=input2
ByteAddressBuffer input2;

//TEST_INPUT:ubuffer(data=[0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<uint> outputBuffer;

using namespace linalg;

typealias CoopMatType = CoopMat<float, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>;

[numthreads(32, 1, 1)]
void computeMain(uint3 threadIndex : SV_DispatchThreadID)
{
    let stride = 4;
    let matrixLayout = CoopMatMatrixLayout::RowMajor;

    let mat1 = CoopMatType.Load<CoopMatMatrixLayout::RowMajor>(input1, 0, stride);
    let mat2 = CoopMatType.Load<CoopMatMatrixLayout::RowMajor>(input2, 0, stride);

    uint32_t equals = mat1 == mat2 ? 1 : 0;
    uint32_t lessThan = mat1 < mat2 ? 1 : 0;
    uint32_t lessThanOrEquals = mat1 <= mat2 ? 1 : 0;

    outputBuffer[0] = equals;
    outputBuffer[1] = lessThan;
    outputBuffer[2] = lessThanOrEquals;
}