summaryrefslogtreecommitdiffstats
path: root/tests/cooperative-matrix/mod.slang
blob: fe87714b07d2c522342caafac4531f3d00426100 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -emit-spirv-directly

// CHECK: 0
// CHECK-NEXT: 0
// CHECK-NEXT: 1
// CHECK-NEXT: 2

// CHECK: 0
// CHECK-NEXT: 0
// CHECK: 1
// CHECK-NEXT: 2

// CHECK: 0
// CHECK-NEXT: 0
// CHECK: 1
// CHECK-NEXT: 2

//TEST_INPUT:ubuffer(stride=4, count=256):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;

//TEST_INPUT:ubuffer(data=[4 3 5 7], stride=4, count=256),name=input1
ByteAddressBuffer input1;

//TEST_INPUT:ubuffer(data=[2 3 4 5], stride=4, count=256),name=input2
ByteAddressBuffer input2;

using namespace linalg;

typealias CoopMatIntType = CoopMat<int32_t, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>;
typealias CoopMatUintType = CoopMat<uint32_t, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>;
typealias CoopMatFloatType = CoopMat<float, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>;

[numthreads(32, 1, 1)]
void computeMain()
{
    let stride = 16;

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

    let mat3 = CoopMatFloatType(mat1);
    let mat4 = CoopMatFloatType(mat2);

    let mat5 = CoopMatUintType(mat1);
    let mat6 = CoopMatUintType(mat2);

    let result = mat1 % mat2;
    let result2 = CoopMatIntType(mat3 % mat4);
    let result3 = CoopMatIntType(mat5 % mat6);

    result.Store<CoopMatMatrixLayout::RowMajor>(outputBuffer, 0, stride);
    result2.Store<CoopMatMatrixLayout::RowMajor>(outputBuffer, 16, stride);
    result3.Store<CoopMatMatrixLayout::RowMajor>(outputBuffer, 32, stride);
}