Fix issues of the interaction between cooperative_matrix and spirv_intrinsics

coopmat<> type definition allows type parameters. To make it accept
types defined by spirv_type directive, we add spirvType info to the type
parameters. This change is to support this case. And a test is added to
show the missing usage.
This commit is contained in:
Rex Xu 2024-03-21 23:09:00 +08:00 committed by GitHub
parent 10ee92feb0
commit 022aea431c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 1136 additions and 1022 deletions

View file

@ -0,0 +1,71 @@
spv.intrinsicsInteractWithCoopMat.comp
// Module Version 10000
// Generated by (magic number): 8000b
// Id's are bound by 36
Capability Shader
Capability Float16
Capability VulkanMemoryModelKHR
Capability CooperativeMatrixKHR
Extension "SPV_KHR_cooperative_matrix"
Extension "SPV_KHR_storage_buffer_storage_class"
Extension "SPV_KHR_vulkan_memory_model"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical VulkanKHR
EntryPoint GLCompute 4 "main"
ExecutionMode 4 LocalSize 32 1 1
Source GLSL 450
SourceExtension "GL_EXT_spirv_intrinsics"
SourceExtension "GL_KHR_cooperative_matrix"
SourceExtension "GL_KHR_memory_scope_semantics"
Name 4 "main"
Name 13 "tempArg"
Name 16 "Buf"
MemberName 16(Buf) 0 "x"
Name 18 "buf"
Name 26 "A"
Decorate 15 ArrayStride 16
MemberDecorate 16(Buf) 0 Offset 0
Decorate 16(Buf) Block
Decorate 18(buf) DescriptorSet 0
Decorate 18(buf) Binding 0
Decorate 35 BuiltIn WorkgroupSize
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 16
7: TypeInt 32 0
8: 7(int) Constant 3
9: 7(int) Constant 16
10: 7(int) Constant 0
11: TypeCooperativeMatrixKHR 6(float16_t) 8 9 9 10
12: TypePointer Function 11
14: TypeVector 7(int) 4
15: TypeRuntimeArray 14(ivec4)
16(Buf): TypeStruct 15
17: TypePointer StorageBuffer 16(Buf)
18(buf): 17(ptr) Variable StorageBuffer
19: TypeInt 32 1
20: 19(int) Constant 0
21: TypePointer StorageBuffer 14(ivec4)
23: 7(int) Constant 2
25: TypePointer Private 11
26(A): 25(ptr) Variable Private
29: 7(int) Constant 64
31: 7(int) Constant 4
32: TypeVector 7(int) 3
33: 7(int) Constant 32
34: 7(int) Constant 1
35: 32(ivec3) ConstantComposite 33 34 34
4(main): 2 Function None 3
5: Label
13(tempArg): 12(ptr) Variable Function
22: 21(ptr) AccessChain 18(buf) 20 10
24: 11 CooperativeMatrixLoadKHR 22 20 23 None
Store 13(tempArg) 24
27: 11 Load 13(tempArg)
Store 26(A) 27
28: 11 Load 26(A)
30: 21(ptr) AccessChain 18(buf) 20 29
CooperativeMatrixStoreKHR 30 28 20 31 None
Return
FunctionEnd

View file

@ -0,0 +1,20 @@
#version 450 core
#pragma use_vulkan_memory_model
#extension GL_KHR_memory_scope_semantics : enable
#extension GL_KHR_cooperative_matrix : enable
#extension GL_EXT_spirv_intrinsics : enable
layout(local_size_x = 32, local_size_y = 1, local_size_z = 1) in;
layout(set=0, binding=0, std430) buffer Buf { uvec4 x[]; } buf;
#define ELT_SIZE 16
#define half spirv_type(capabilities=[9], id = 22, 16)
coopmat<half, gl_ScopeSubgroup, 16, 16, gl_MatrixUseA> A;
void main() {
coopMatLoad(A, buf.x, 0, ELT_SIZE / 8, 0);
coopMatStore(A, buf.x, 64, 4, 0);
}