yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Jay KwakSupport Vulkan memory model (#7057)d58243d90

master
2.7 KiB68 linesraw
1//TEST(compute):SIMPLE(filecheck=CHECK): -entry computeMain -stage compute -target spirv
2
3// This test checks that the correct SPIRV Cooperative Matrix Operands are emitted for OpCooperativeMatrixMulAddKHR operaions
4RWStructuredBuffer<uint32_t> outputBuffer1;
5RWStructuredBuffer<uint32_t> outputBuffer2;
6RWStructuredBuffer<uint32_t> outputBuffer3;
7RWStructuredBuffer<int> outputBuffer4;
8RWStructuredBuffer<uint32_t> outputBuffer5;
9RWStructuredBuffer<int> outputBuffer6;
10
11using namespace linalg;
12
13__generic<T : __BuiltinArithmeticType>
14typealias CoopMatAType = CoopMat<T, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixA>;
15
16__generic<T : __BuiltinArithmeticType>
17typealias CoopMatBType = CoopMat<T, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixB>;
18
19__generic<T : __BuiltinArithmeticType>
20typealias CoopMatCType = CoopMat<T, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>;
21
22[numthreads(32, 1, 1)]
23void computeMain()
24{
25    // CHECK: OpCooperativeMatrixMulAddKHR {{.*}} NoneKHR
26    coopMatMulAdd<uint32_t, false>(
27        CoopMatAType<uint16_t>(2),
28        CoopMatBType<uint32_t>(3),
29        CoopMatCType<uint16_t>(4)
30    ).Store<CoopMatMatrixLayout::RowMajor>(outputBuffer1, 0, 16);
31
32    // CHECK: OpCooperativeMatrixMulAddKHR {{.*}} MatrixASignedComponentsKHR|MatrixBSignedComponentsKHR
33    coopMatMulAdd<uint32_t, false>(
34        CoopMatAType<int16_t>(2),
35        CoopMatBType<int32_t>(3),
36        CoopMatCType<uint16_t>(4)
37    ).Store<CoopMatMatrixLayout::RowMajor>(outputBuffer2, 0, 16);
38
39    // CHECK: OpCooperativeMatrixMulAddKHR {{.*}} MatrixCSignedComponentsKHR
40    coopMatMulAdd<uint32_t, false>(
41        CoopMatAType<uint16_t>(2),
42        CoopMatBType<uint32_t>(3),
43        CoopMatCType<int16_t>(4)
44    ).Store<CoopMatMatrixLayout::RowMajor>(outputBuffer3, 0, 16);
45
46    // CHECK: OpCooperativeMatrixMulAddKHR {{.*}} MatrixResultSignedComponentsKHR
47    coopMatMulAdd<int, false>(
48        CoopMatAType<uint16_t>(2),
49        CoopMatBType<uint32_t>(3),
50        CoopMatCType<uint16_t>(4)
51    ).Store<CoopMatMatrixLayout::RowMajor>(outputBuffer4, 0, 16);
52
53    // CHECK: OpCooperativeMatrixMulAddKHR {{.*}} SaturatingAccumulationKHR
54    coopMatMulAdd<uint32_t, true>(
55        CoopMatAType<uint16_t>(2),
56        CoopMatBType<uint32_t>(3),
57        CoopMatCType<uint16_t>(4)
58    ).Store<CoopMatMatrixLayout::RowMajor>(outputBuffer5, 0, 16);
59
60    // CHECK: OpCooperativeMatrixMulAddKHR {{.*}} MatrixASignedComponentsKHR|MatrixBSignedComponentsKHR|MatrixCSignedComponentsKHR|MatrixResultSignedComponentsKHR|SaturatingAccumulationKHR
61    coopMatMulAdd<int, true>(
62        CoopMatAType<int16_t>(2),
63        CoopMatBType<int32_t>(3),
64        CoopMatCType<int16_t>(4)
65    ).Store<CoopMatMatrixLayout::RowMajor>(outputBuffer6, 0, 16);
66}
67
68