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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
//TEST(compute):SIMPLE(filecheck=CHECK): -entry computeMain -stage compute -target spirv
// This test checks that the correct SPIRV Cooperative Matrix Operands are emitted for OpCooperativeMatrixMulAddKHR operaions
RWStructuredBuffer<uint32_t> outputBuffer1;
RWStructuredBuffer<uint32_t> outputBuffer2;
RWStructuredBuffer<uint32_t> outputBuffer3;
RWStructuredBuffer<int> outputBuffer4;
RWStructuredBuffer<uint32_t> outputBuffer5;
RWStructuredBuffer<int> outputBuffer6;
using namespace linalg;
__generic<T : __BuiltinArithmeticType>
typealias CoopMatAType = CoopMat<T, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixA>;
__generic<T : __BuiltinArithmeticType>
typealias CoopMatBType = CoopMat<T, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixB>;
__generic<T : __BuiltinArithmeticType>
typealias CoopMatCType = CoopMat<T, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>;
[numthreads(32, 1, 1)]
void computeMain()
{
// CHECK: OpCooperativeMatrixMulAddKHR {{.*}} NoneKHR
coopMatMulAdd<uint32_t, false>(
CoopMatAType<uint16_t>(2),
CoopMatBType<uint32_t>(3),
CoopMatCType<uint16_t>(4)
).Store<CoopMatMatrixLayout::RowMajor>(outputBuffer1, 0, 16);
// CHECK: OpCooperativeMatrixMulAddKHR {{.*}} MatrixASignedComponentsKHR|MatrixBSignedComponentsKHR
coopMatMulAdd<uint32_t, false>(
CoopMatAType<int16_t>(2),
CoopMatBType<int32_t>(3),
CoopMatCType<uint16_t>(4)
).Store<CoopMatMatrixLayout::RowMajor>(outputBuffer2, 0, 16);
// CHECK: OpCooperativeMatrixMulAddKHR {{.*}} MatrixCSignedComponentsKHR
coopMatMulAdd<uint32_t, false>(
CoopMatAType<uint16_t>(2),
CoopMatBType<uint32_t>(3),
CoopMatCType<int16_t>(4)
).Store<CoopMatMatrixLayout::RowMajor>(outputBuffer3, 0, 16);
// CHECK: OpCooperativeMatrixMulAddKHR {{.*}} MatrixResultSignedComponentsKHR
coopMatMulAdd<int, false>(
CoopMatAType<uint16_t>(2),
CoopMatBType<uint32_t>(3),
CoopMatCType<uint16_t>(4)
).Store<CoopMatMatrixLayout::RowMajor>(outputBuffer4, 0, 16);
// CHECK: OpCooperativeMatrixMulAddKHR {{.*}} SaturatingAccumulationKHR
coopMatMulAdd<uint32_t, true>(
CoopMatAType<uint16_t>(2),
CoopMatBType<uint32_t>(3),
CoopMatCType<uint16_t>(4)
).Store<CoopMatMatrixLayout::RowMajor>(outputBuffer5, 0, 16);
// CHECK: OpCooperativeMatrixMulAddKHR {{.*}} MatrixASignedComponentsKHR|MatrixBSignedComponentsKHR|MatrixCSignedComponentsKHR|MatrixResultSignedComponentsKHR|SaturatingAccumulationKHR
coopMatMulAdd<int, true>(
CoopMatAType<int16_t>(2),
CoopMatBType<int32_t>(3),
CoopMatCType<int16_t>(4)
).Store<CoopMatMatrixLayout::RowMajor>(outputBuffer6, 0, 16);
}
|