Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions SPIRV/GlslangToSpv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,10 @@ spv::LoopControlMask TGlslangToSpvTraverser::TranslateLoopControl(const glslang:
operands.push_back(loopNode.getPartialCount());
}
}
if (loopNode.getMultipleWaitQueuesQCOM() != loopNode./*TIntermLoop::*/noMultipleQaitQueues) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented out code, you should remove it.

control = control | spv::LoopControlMask::MultipleWaitQueuesQCOM;
operands.push_back(loopNode.getMultipleWaitQueuesQCOM());
}

return control;
}
Expand Down
1 change: 1 addition & 0 deletions SPIRV/doc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,7 @@ const char* LoopControlString(int cont)
case (int)LoopControlShift::IterationMultiple: return "IterationMultiple";
case (int)LoopControlShift::PeelCount: return "PeelCount";
case (int)LoopControlShift::PartialCount: return "PartialCount";
case (int)LoopControlShift::MultipleWaitQueuesQCOM: return "MultipeWaitQueuesQCOM";

case LoopControlCeiling:
default: return "Bad";
Expand Down
4 changes: 4 additions & 0 deletions SPIRV/spirv.hpp11
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@ enum class LoopControlShift : unsigned {
NoFusionINTEL = 23,
LoopCountINTEL = 24,
MaxReinvocationDelayINTEL = 25,
MultipleWaitQueuesQCOM = 28,
Max = 0x7fffffff,
};

Expand All @@ -871,6 +872,7 @@ enum class LoopControlMask : unsigned {
NoFusionINTEL = 0x00800000,
LoopCountINTEL = 0x01000000,
MaxReinvocationDelayINTEL = 0x02000000,
MultipleWaitQueuesQCOM = 0x10000000,
};

enum class FunctionControlShift : unsigned {
Expand Down Expand Up @@ -1122,6 +1124,7 @@ enum class Capability : unsigned {
TileShadingQCOM = 4495,
CooperativeMatrixConversionQCOM = 4496,
TextureBlockMatch2QCOM = 4498,
MultipleWaitQueuesQCOM = 4539,
Float16ImageAMD = 5008,
ImageGatherBiasLodAMD = 5009,
FragmentMaskAMD = 5010,
Expand Down Expand Up @@ -4126,6 +4129,7 @@ inline const char* CapabilityToString(Capability value) {
case Capability::TileShadingQCOM: return "TileShadingQCOM";
case Capability::CooperativeMatrixConversionQCOM: return "CooperativeMatrixConversionQCOM";
case Capability::TextureBlockMatch2QCOM: return "TextureBlockMatch2QCOM";
case Capability::MultipleWaitQueuesQCOM: return "MultipleWaitQueuesQCOM";
case Capability::Float16ImageAMD: return "Float16ImageAMD";
case Capability::ImageGatherBiasLodAMD: return "ImageGatherBiasLodAMD";
case Capability::FragmentMaskAMD: return "FragmentMaskAMD";
Expand Down
1 change: 1 addition & 0 deletions Test/baseResults/460.frag.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ERROR: 0:22: 'attribute' : required extension not requested: Possible extensions include:
GL_EXT_control_flow_attributes
GL_EXT_control_flow_attributes2
GL_QCOM_multiple_wait_queues
ERROR: 0:23: 'attribute' : required extension not requested: GL_EXT_control_flow_attributes
ERROR: 0:30: 'dependency_length' : must be positive
ERROR: 0:31: 'dependency_length' : must be positive
Expand Down
216 changes: 216 additions & 0 deletions Test/baseResults/spv.qcom.multiple_wait_queues.comp.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
spv.qcom.multiple_wait_queues.comp
// Module Version 10300
// Generated by (magic number): 8000b
// Id's are bound by 115

Capability Shader
Capability VulkanMemoryModelKHR
Capability CooperativeMatrixKHR
Extension "SPV_KHR_cooperative_matrix"
Extension "SPV_KHR_vulkan_memory_model"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical VulkanKHR
EntryPoint GLCompute 4 "main"
ExecutionMode 4 LocalSize 64 2 2
Source GLSL 450
SourceExtension "GL_KHR_cooperative_matrix"
SourceExtension "GL_KHR_memory_scope_semantics"
SourceExtension "GL_QCOM_multiple_wait_queues"
Name 4 "main"
Name 11 "coop_matmul(u1;u1;"
Name 9 "row"
Name 10 "col"
Name 13 "step"
Name 21 "TOTAL_K"
Name 24 "subMatrixAStart"
Name 30 "subMatrixBStart"
Name 37 "TILE_M"
Name 41 "matA"
Name 43 "InputA"
MemberName 43(InputA) 0 "x"
Name 45 "inputA"
Name 52 "TILE_N"
Name 56 "matB"
Name 58 "InputB"
MemberName 58(InputB) 0 "x"
Name 60 "inputB"
Name 68 "matC"
Name 73 "TILE_K"
Name 83 "subMatrixAStart"
Name 88 "subMatrixBStart"
Name 105 "param"
Name 106 "param"
Name 109 "InputC"
MemberName 109(InputC) 0 "x"
Name 111 "inputC"
Decorate 21(TOTAL_K) SpecId 0
Decorate 37(TILE_M) SpecId 3
Decorate 42 ArrayStride 4
Decorate 43(InputA) Block
MemberDecorate 43(InputA) 0 NonWritable
MemberDecorate 43(InputA) 0 Offset 0
Decorate 45(inputA) NonWritable
Decorate 45(inputA) Binding 0
Decorate 45(inputA) DescriptorSet 0
Decorate 52(TILE_N) SpecId 4
Decorate 57 ArrayStride 4
Decorate 58(InputB) Block
MemberDecorate 58(InputB) 0 NonWritable
MemberDecorate 58(InputB) 0 Offset 0
Decorate 60(inputB) NonWritable
Decorate 60(inputB) Binding 1
Decorate 60(inputB) DescriptorSet 0
Decorate 73(TILE_K) SpecId 7
Decorate 108 ArrayStride 4
Decorate 109(InputC) Block
MemberDecorate 109(InputC) 0 NonWritable
MemberDecorate 109(InputC) 0 Offset 0
Decorate 111(inputC) NonWritable
Decorate 111(inputC) Binding 2
Decorate 111(inputC) DescriptorSet 0
Decorate 114 BuiltIn WorkgroupSize
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
7: TypePointer Function 6(int)
8: TypeFunction 2 7(ptr) 7(ptr)
14: 6(int) Constant 0
21(TOTAL_K): 6(int) SpecConstant 1
22: TypeBool
26: 6(int) Constant 16
35: TypeFloat 32
36: 6(int) Constant 3
37(TILE_M): 6(int) SpecConstant 1
38: 6(int) Constant 8
39: TypeCooperativeMatrixKHR 35(float) 36 37(TILE_M) 38 14
40: TypePointer Function 39
42: TypeRuntimeArray 35(float)
43(InputA): TypeStruct 42
44: TypePointer StorageBuffer 43(InputA)
45(inputA): 44(ptr) Variable StorageBuffer
46: TypeInt 32 1
47: 46(int) Constant 0
49: TypePointer StorageBuffer 35(float)
52(TILE_N): 6(int) SpecConstant 1
53: 6(int) Constant 1
54: TypeCooperativeMatrixKHR 35(float) 36 38 52(TILE_N) 53
55: TypePointer Function 54
57: TypeRuntimeArray 35(float)
58(InputB): TypeStruct 57
59: TypePointer StorageBuffer 58(InputB)
60(inputB): 59(ptr) Variable StorageBuffer
63: 46(int) Constant 1
65: 6(int) Constant 2
66: TypeCooperativeMatrixKHR 35(float) 36 37(TILE_M) 52(TILE_N) 65
67: TypePointer Function 66
73(TILE_K): 6(int) SpecConstant 1
108: TypeRuntimeArray 35(float)
109(InputC): TypeStruct 108
110: TypePointer StorageBuffer 109(InputC)
111(inputC): 110(ptr) Variable StorageBuffer
112: TypeVector 6(int) 3
113: 6(int) Constant 64
114: 112(ivec3) ConstantComposite 113 65 65
4(main): 2 Function None 3
5: Label
105(param): 7(ptr) Variable Function
106(param): 7(ptr) Variable Function
Store 105(param) 14
Store 106(param) 14
107: 2 FunctionCall 11(coop_matmul(u1;u1;) 105(param) 106(param)
Return
FunctionEnd
11(coop_matmul(u1;u1;): 2 Function None 8
9(row): 7(ptr) FunctionParameter
10(col): 7(ptr) FunctionParameter
12: Label
13(step): 7(ptr) Variable Function
24(subMatrixAStart): 7(ptr) Variable Function
30(subMatrixBStart): 7(ptr) Variable Function
41(matA): 40(ptr) Variable Function
56(matB): 55(ptr) Variable Function
68(matC): 67(ptr) Variable Function
83(subMatrixAStart): 7(ptr) Variable Function
88(subMatrixBStart): 7(ptr) Variable Function
Store 13(step) 14
Branch 15
15: Label
LoopMerge 17 18 0
Branch 19
19: Label
20: 6(int) Load 13(step)
23: 22(bool) ULessThan 20 21(TOTAL_K)
BranchConditional 23 16 17
16: Label
25: 6(int) Load 9(row)
27: 6(int) IMul 25 26
28: 6(int) Load 13(step)
29: 6(int) IAdd 27 28
Store 24(subMatrixAStart) 29
31: 6(int) Load 10(col)
32: 6(int) IMul 31 26
33: 6(int) Load 13(step)
34: 6(int) IAdd 32 33
Store 30(subMatrixBStart) 34
48: 6(int) Load 24(subMatrixAStart)
50: 49(ptr) AccessChain 45(inputA) 47 48
51: 39 CooperativeMatrixLoadKHR 50 47 26 None
Store 41(matA) 51
61: 6(int) Load 30(subMatrixBStart)
62: 49(ptr) AccessChain 60(inputB) 47 61
64: 54 CooperativeMatrixLoadKHR 62 63 26 None
Store 56(matB) 64
69: 39 Load 41(matA)
70: 54 Load 56(matB)
71: 66 Load 68(matC)
72: 66 CooperativeMatrixMulAddKHR 69 70 71
Store 68(matC) 72
Branch 18
18: Label
74: 6(int) Load 13(step)
75: 6(int) IAdd 74 73(TILE_K)
Store 13(step) 75
Branch 15
17: Label
Store 13(step) 14
Branch 76
76: Label
LoopMerge 78 79 2
Branch 80
80: Label
81: 6(int) Load 13(step)
82: 22(bool) ULessThan 81 21(TOTAL_K)
BranchConditional 82 77 78
77: Label
84: 6(int) Load 9(row)
85: 6(int) IMul 84 26
86: 6(int) Load 13(step)
87: 6(int) IAdd 85 86
Store 83(subMatrixAStart) 87
89: 6(int) Load 10(col)
90: 6(int) IMul 89 26
91: 6(int) Load 13(step)
92: 6(int) IAdd 90 91
Store 88(subMatrixBStart) 92
93: 6(int) Load 83(subMatrixAStart)
94: 49(ptr) AccessChain 45(inputA) 47 93
95: 39 CooperativeMatrixLoadKHR 94 47 26 None
Store 41(matA) 95
96: 6(int) Load 88(subMatrixBStart)
97: 49(ptr) AccessChain 60(inputB) 47 96
98: 54 CooperativeMatrixLoadKHR 97 63 26 None
Store 56(matB) 98
99: 39 Load 41(matA)
100: 54 Load 56(matB)
101: 66 Load 68(matC)
102: 66 CooperativeMatrixMulAddKHR 99 100 101
Store 68(matC) 102
Branch 79
79: Label
103: 6(int) Load 13(step)
104: 6(int) IAdd 103 73(TILE_K)
Store 13(step) 104
Branch 76
78: Label
Return
FunctionEnd
55 changes: 55 additions & 0 deletions Test/spv.qcom.multiple_wait_queues.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#version 450 core
#extension GL_KHR_memory_scope_semantics : enable

#extension GL_KHR_cooperative_matrix : enable
#extension GL_QCOM_multiple_wait_queues : enable

layout(constant_id = 0) const uint TOTAL_K = 1;

layout(constant_id = 3) const uint TILE_M = 1;
layout(constant_id = 4) const uint TILE_N = 1;
layout(constant_id = 7) const uint TILE_K = 1;

layout(set=0, binding=0) readonly buffer InputA { float x[]; } inputA;
layout(set=0, binding=1) readonly buffer InputB { float x[]; } inputB;
layout(set=0, binding=2) readonly buffer InputC { float x[]; } inputC;

layout(local_size_x = 64, local_size_y = 2, local_size_z = 2) in;

#define STRIDE_A 16
#define STRIDE_B 16

void coop_matmul(uint row, uint col)
{
coopmat<float, gl_ScopeSubgroup, TILE_M, 8, gl_MatrixUseA> matA;
coopmat<float, gl_ScopeSubgroup, 8, TILE_N, gl_MatrixUseB> matB;
coopmat<float, gl_ScopeSubgroup, TILE_M, TILE_N, gl_MatrixUseAccumulator> matC;
uint step;

[[multiple_wait_queuesQCOM]]
for (step = 0; step < TOTAL_K; step += TILE_K) {
uint subMatrixAStart = row * STRIDE_A + step;
uint subMatrixBStart = col * STRIDE_B + step;

coopMatLoad(matA, inputA.x, subMatrixAStart, STRIDE_A, gl_CooperativeMatrixLayoutRowMajor); // Global to CoopMat
coopMatLoad(matB, inputB.x, subMatrixBStart, STRIDE_B, gl_CooperativeMatrixLayoutColumnMajor); // Global to CoopMat

matC = coopMatMulAdd(matA, matB, matC);
}

[[multiple_wait_queuesQCOM(2)]]
for (step = 0; step < TOTAL_K; step += TILE_K) {
uint subMatrixAStart = row * STRIDE_A + step;
uint subMatrixBStart = col * STRIDE_B + step;

coopMatLoad(matA, inputA.x, subMatrixAStart, STRIDE_A, gl_CooperativeMatrixLayoutRowMajor); // Global to CoopMat
coopMatLoad(matB, inputB.x, subMatrixBStart, STRIDE_B, gl_CooperativeMatrixLayoutColumnMajor); // Global to CoopMat

matC = coopMatMulAdd(matA, matB, matC);
}
}

void main()
{
coop_matmul(0, 0);
}
10 changes: 9 additions & 1 deletion glslang/Include/intermediate.h
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,8 @@ class TIntermLoop : public TIntermNode {
maxIterations(iterationsInfinite),
iterationMultiple(1),
peelCount(0),
partialCount(0)
partialCount(0),
multipleWaitQueuesQCOM(noMultipleQaitQueues)
{ }

virtual TIntermLoop* getAsLoopNode() { return this; }
Expand Down Expand Up @@ -1275,6 +1276,12 @@ class TIntermLoop : public TIntermNode {
}
unsigned int getPartialCount() const { return partialCount; }

static const unsigned int noMultipleQaitQueues = 0xFFFFFFFF;
void setMultipleWaitQueuesQCOM(unsigned int numQ) {
multipleWaitQueuesQCOM = numQ;
}
unsigned int getMultipleWaitQueuesQCOM() const { return multipleWaitQueuesQCOM; }

protected:
TIntermNode* body; // code to loop over
TIntermNode* test; // exit condition associated with loop, could be 0 for 'for' loops
Expand All @@ -1288,6 +1295,7 @@ class TIntermLoop : public TIntermNode {
unsigned int iterationMultiple; // as per the SPIR-V specification
unsigned int peelCount; // as per the SPIR-V specification
unsigned int partialCount; // as per the SPIR-V specification
unsigned int multipleWaitQueuesQCOM;
};

//
Expand Down
3 changes: 3 additions & 0 deletions glslang/MachineIndependent/Versions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_QCOM_image_processing2] = EBhDisable;
extensionBehavior[E_GL_QCOM_tile_shading] = EBhDisable;
extensionBehavior[E_GL_QCOM_cooperative_matrix_conversion] = EBhDisable;
extensionBehavior[E_GL_QCOM_multiple_wait_queues] = EBhDisable;

// AEP
extensionBehavior[E_GL_ANDROID_extension_pack_es31a] = EBhDisable;
Expand Down Expand Up @@ -484,6 +485,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_QCOM_image_processing2 1\n"
"#define GL_QCOM_tile_shading 1\n"
"#define GL_QCOM_cooperative_matrix_conversion 1\n"
"#define GL_QCOM_multiple_wait_queues 1\n"
;

if (version >= 300) {
Expand Down Expand Up @@ -620,6 +622,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_QCOM_image_processing2 1\n"
"#define GL_QCOM_tile_shading 1\n"
"#define GL_QCOM_cooperative_matrix_conversion 1\n"
"#define GL_QCOM_multiple_wait_queues 1\n"

"#define GL_EXT_shader_explicit_arithmetic_types 1\n"
"#define GL_EXT_shader_explicit_arithmetic_types_int8 1\n"
Expand Down
1 change: 1 addition & 0 deletions glslang/MachineIndependent/Versions.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ const char* const E_GL_QCOM_image_processing = "GL_QCOM_image
const char* const E_GL_QCOM_image_processing2 = "GL_QCOM_image_processing2";
const char* const E_GL_QCOM_tile_shading = "GL_QCOM_tile_shading";
const char* const E_GL_QCOM_cooperative_matrix_conversion = "GL_QCOM_cooperative_matrix_conversion";
const char* const E_GL_QCOM_multiple_wait_queues = "GL_QCOM_multiple_wait_queues";

// AEP
const char* const E_GL_ANDROID_extension_pack_es31a = "GL_ANDROID_extension_pack_es31a";
Expand Down
Loading
Loading