From ca04c2a16ac19ab7034193ecb7a5adc809418a8e Mon Sep 17 00:00:00 2001 From: Jeff Bolz Date: Mon, 30 Sep 2024 12:53:27 -0500 Subject: [PATCH] Fix nonsemantic debuginfo line attribution for cooperative matrix * Generate debuginfo for coopmat types, treating them as an opaque composite. Restore the debug source location after calling convertGlslangToSpvType, fixes the line info in this unit test * Add a cooperative matrix test case, based on the shader from https://github.com/jeffbolznv/vk_cooperative_matrix_perf/blob/master/shaders/shmem.comp --- SPIRV/GlslangToSpv.cpp | 13 +- SPIRV/SpvBuilder.cpp | 37 ++ SPIRV/SpvBuilder.h | 1 + SPIRV/spirv.hpp | 14 + SPIRV/spvIR.h | 9 + .../spv.debuginfo.coopmatKHR.comp.out | 623 ++++++++++++++++++ Test/baseResults/spv.debuginfo.hlsl.vert.out | 30 +- Test/spv.debuginfo.coopmatKHR.comp | 87 +++ gtests/Spv.FromFile.cpp | 1 + 9 files changed, 797 insertions(+), 18 deletions(-) create mode 100644 Test/baseResults/spv.debuginfo.coopmatKHR.comp.out create mode 100644 Test/spv.debuginfo.coopmatKHR.comp diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 50851889ec..00dbabbab4 100644 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -2858,9 +2858,16 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt // SPIR-V, for an out parameter std::vector temporaryLvalues; // temporaries to pass, as proxies for complexLValues - auto resultType = [&invertedType, &node, this](){ return invertedType != spv::NoType ? - invertedType : - convertGlslangToSpvType(node->getType()); }; + auto resultType = [&invertedType, &node, this](){ + if (invertedType != spv::NoType) { + return invertedType; + } else { + auto ret = convertGlslangToSpvType(node->getType()); + // convertGlslangToSpvType may clobber the debug location, reset it + builder.setDebugSourceLocation(node->getLoc().line, node->getLoc().getFilename()); + return ret; + } + }; // try texturing result = createImageTextureFunctionCall(node); diff --git a/SPIRV/SpvBuilder.cpp b/SPIRV/SpvBuilder.cpp index 41a6b3db02..e4d81f95f4 100644 --- a/SPIRV/SpvBuilder.cpp +++ b/SPIRV/SpvBuilder.cpp @@ -439,6 +439,43 @@ Id Builder::makeCooperativeMatrixTypeKHR(Id component, Id scope, Id rows, Id col constantsTypesGlobals.push_back(std::unique_ptr(type)); module.mapInstruction(type); + if (emitNonSemanticShaderDebugInfo) + { + // Find a name for one of the parameters. It can either come from debuginfo for another + // type, or an OpName from a constant. + auto const findName = [&](Id id) { + Id id2 = debugId[id]; + for (auto &t : groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic]) { + if (t->getResultId() == id2) { + for (auto &s : strings) { + if (s->getResultId() == t->getIdOperand(2)) { + return s->getNameString(); + } + } + } + } + for (auto &t : names) { + if (t->getIdOperand(0) == id) { + return t->getNameString(); + } + } + return "unknown"; + }; + std::string debugName = "coopmat<"; + debugName += std::string(findName(component)) + ", "; + if (isConstantScalar(scope)) { + debugName += std::string("gl_Scope") + std::string(spv::ScopeToString((spv::Scope)getConstantScalar(scope))) + ", "; + } else { + debugName += std::string(findName(scope)) + ", "; + } + debugName += std::string(findName(rows)) + ", "; + debugName += std::string(findName(cols)) + ">"; + // There's no nonsemantic debug info instruction for cooperative matrix types, + // use opaque composite instead. + auto const debugResultId = makeCompositeDebugType({}, debugName.c_str(), NonSemanticShaderDebugInfo100Structure, true); + debugId[type->getResultId()] = debugResultId; + } + return type->getResultId(); } diff --git a/SPIRV/SpvBuilder.h b/SPIRV/SpvBuilder.h index 61b6aa57eb..2fd9dd8045 100644 --- a/SPIRV/SpvBuilder.h +++ b/SPIRV/SpvBuilder.h @@ -48,6 +48,7 @@ #define SpvBuilder_H #include "Logger.h" +#define SPV_ENABLE_UTILITY_CODE #include "spirv.hpp" #include "spvIR.h" namespace spv { diff --git a/SPIRV/spirv.hpp b/SPIRV/spirv.hpp index b09d99bee4..157fee194a 100644 --- a/SPIRV/spirv.hpp +++ b/SPIRV/spirv.hpp @@ -2772,6 +2772,20 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpGroupLogicalXorKHR: *hasResult = true; *hasResultType = true; break; } } + +inline const char* ScopeToString(Scope value) { + switch (value) { + case ScopeCrossDevice: return "CrossDevice"; + case ScopeDevice: return "Device"; + case ScopeWorkgroup: return "Workgroup"; + case ScopeSubgroup: return "Subgroup"; + case ScopeInvocation: return "Invocation"; + case ScopeQueueFamily: return "QueueFamily"; + case ScopeShaderCallKHR: return "ShaderCallKHR"; + default: return "Unknown"; + } +} + #endif /* SPV_ENABLE_UTILITY_CODE */ // Overload bitwise operators for mask bit combining diff --git a/SPIRV/spvIR.h b/SPIRV/spvIR.h index bd639d8f72..e723f0e1e3 100644 --- a/SPIRV/spvIR.h +++ b/SPIRV/spvIR.h @@ -189,6 +189,15 @@ class Instruction { out.push_back(operands[op]); } + const char *getNameString() const { + if (opCode == OpString) { + return (const char *)&operands[0]; + } else { + assert(opCode == OpName); + return (const char *)&operands[1]; + } + } + protected: Instruction(const Instruction&); Id resultId; diff --git a/Test/baseResults/spv.debuginfo.coopmatKHR.comp.out b/Test/baseResults/spv.debuginfo.coopmatKHR.comp.out new file mode 100644 index 0000000000..bc527594b8 --- /dev/null +++ b/Test/baseResults/spv.debuginfo.coopmatKHR.comp.out @@ -0,0 +1,623 @@ +spv.debuginfo.coopmatKHR.comp +// Module Version 10000 +// Generated by (magic number): 8000b +// Id's are bound by 380 + + Capability Shader + Capability Float16 + Capability StorageUniformBufferBlock16 + Capability VulkanMemoryModelKHR + Capability CooperativeMatrixKHR + Extension "SPV_KHR_16bit_storage" + Extension "SPV_KHR_cooperative_matrix" + Extension "SPV_KHR_non_semantic_info" + Extension "SPV_KHR_storage_buffer_storage_class" + Extension "SPV_KHR_vulkan_memory_model" + 1: ExtInstImport "NonSemantic.Shader.DebugInfo.100" + 3: ExtInstImport "GLSL.std.450" + MemoryModel Logical VulkanKHR + EntryPoint GLCompute 14 "main" + ExecutionMode 14 LocalSize 1 1 1 + 2: String "spv.debuginfo.coopmatKHR.comp" + 8: String "uint" + 16: String "main" + 19: String "// OpModuleProcessed auto-map-locations +// OpModuleProcessed auto-map-bindings +// OpModuleProcessed client vulkan100 +// OpModuleProcessed target-env vulkan1.0 +// OpModuleProcessed keep-uncalled +// OpModuleProcessed entry-point main +// OpModuleProcessed use-vulkan-memory-model +// OpModuleProcessed use-vulkan-memory-model +// OpModuleProcessed use-vulkan-memory-model +// OpModuleProcessed use-vulkan-memory-model +#line 1 +/* + * Copyright (c) 2019-2024, NVIDIA CORPORATION. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#version 450 core +#pragma use_vulkan_memory_model +#extension GL_EXT_scalar_block_layout : enable +#extension GL_KHR_memory_scope_semantics : enable +#extension GL_KHR_cooperative_matrix : enable +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : enable +#extension GL_EXT_shader_explicit_arithmetic_types_int8 : enable +#extension GL_EXT_shader_explicit_arithmetic_types_int32 : enable +#extension GL_EXT_buffer_reference : enable +#extension GL_EXT_control_flow_attributes : enable + +layout(constant_id = 0) const uint lM = 1; +layout(constant_id = 1) const uint lN = 1; +layout(constant_id = 2) const uint lK = 1; +layout(constant_id = 3) const uint TILE_M = 1; +layout(constant_id = 4) const uint TILE_N = 1; +layout(constant_id = 5) const uint TILE_K = 1; +layout(constant_id = 6) const uint K = 1; + +#define A_BITS 16 +#define A_TYPE float16_t +#define C_BITS 16 +#define C_TYPE float16_t + +buffer Output { C_TYPE x[]; } outputO; + +shared uvec4 Ash[128]; +shared uvec4 Bsh[128]; + +const uint C_ROWS = 2; +const uint C_COLS = 2; +coopmat result[C_ROWS][C_COLS]; + +void main() +{ + [[unroll]] for (uint i = 0; i < C_ROWS; ++i) { + [[unroll]] for (uint j = 0; j < C_COLS; ++j) { + result[i][j] = coopmat(0.0); + } + } + + for (uint chunkK = 0; chunkK < K; chunkK += TILE_K) { + [[unroll]] for (uint k = 0; k < TILE_K / lK; ++k) + { + coopmat matA[C_ROWS]; + [[unroll]] for (uint i = 0; i < C_ROWS; ++i) { + coopMatLoad(matA[i], Ash, 0, 0, gl_CooperativeMatrixLayoutRowMajor); + } + + coopmat matB; + [[unroll]] for (uint j = 0; j < C_COLS; ++j) { + coopMatLoad(matB, Bsh, 0, 0, gl_CooperativeMatrixLayoutRowMajor); + + [[unroll]] for (uint i = 0; i < C_ROWS; ++i) { + result[i][j] = coopMatMulAdd(matA[i], matB, result[i][j]); + } + } + } + } + + [[unroll]] for (uint i = 0; i < C_ROWS; ++i) { + [[unroll]] for (uint j = 0; j < C_COLS; ++j) { + coopMatStore(result[i][j], outputO.x, 0, 0, gl_CooperativeMatrixLayoutRowMajor); + } + } +} +" + 33: String "i" + 49: String "bool" + 54: String "j" + 71: String "float16_t" + 78: String "coopmat" + 80: String "@coopmat" + 90: String "result" + 106: String "int" + 116: String "chunkK" + 135: String "k" + 173: String "coopmat" + 175: String "@coopmat" + 180: String "tempArg" + 193: String "Ash" + 207: String "matA" + 237: String "coopmat" + 239: String "@coopmat" + 249: String "Bsh" + 256: String "matB" + 353: String "x" + 357: String "Output" + 363: String "outputO" + SourceExtension "GL_EXT_buffer_reference" + SourceExtension "GL_EXT_control_flow_attributes" + SourceExtension "GL_EXT_scalar_block_layout" + SourceExtension "GL_EXT_shader_explicit_arithmetic_types_float16" + SourceExtension "GL_EXT_shader_explicit_arithmetic_types_int32" + SourceExtension "GL_EXT_shader_explicit_arithmetic_types_int8" + SourceExtension "GL_KHR_cooperative_matrix" + SourceExtension "GL_KHR_memory_scope_semantics" + Name 14 "main" + Name 31 "i" + Name 52 "j" + Name 74 "lM" + Name 75 "lN" + Name 88 "result" + Name 114 "chunkK" + Name 131 "K" + Name 133 "k" + Name 150 "TILE_K" + Name 151 "lK" + Name 154 "i" + Name 178 "tempArg" + Name 191 "Ash" + Name 205 "matA" + Name 218 "j" + Name 242 "tempArg" + Name 247 "Bsh" + Name 254 "matB" + Name 261 "i" + Name 308 "i" + Name 325 "j" + Name 351 "Output" + MemberName 351(Output) 0 "x" + Name 361 "outputO" + Name 378 "TILE_M" + Name 379 "TILE_N" + Decorate 74(lM) SpecId 0 + Decorate 75(lN) SpecId 1 + Decorate 131(K) SpecId 6 + Decorate 150(TILE_K) SpecId 5 + Decorate 151(lK) SpecId 2 + Decorate 349 ArrayStride 2 + Decorate 351(Output) Block + MemberDecorate 351(Output) 0 Offset 0 + Decorate 361(outputO) Binding 0 + Decorate 361(outputO) DescriptorSet 0 + Decorate 378(TILE_M) SpecId 3 + Decorate 379(TILE_N) SpecId 4 + 4: TypeVoid + 5: TypeFunction 4 + 7: TypeInt 32 0 + 10: 7(int) Constant 32 + 11: 7(int) Constant 6 + 12: 7(int) Constant 0 + 9: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 8 10 11 12 + 13: 7(int) Constant 3 + 6: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 8(DebugTypeFunction) 13 4 + 18: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 35(DebugSource) 2 19 + 20: 7(int) Constant 55 + 22: 7(int) Constant 1 + 23: 7(int) Constant 4 + 24: 7(int) Constant 2 + 21: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 1(DebugCompilationUnit) 22 23 18 24 + 17: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 20(DebugFunction) 16 6 18 20 12 21 16 13 20 + 28: TypePointer Function 7(int) + 29: 7(int) Constant 7 + 30: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 9 29 12 + 34: 7(int) Constant 57 + 32: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 33 9 18 34 12 17 23 + 36: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 31(DebugExpression) + 48: TypeBool + 50: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 49 10 24 12 + 55: 7(int) Constant 58 + 53: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 54 9 18 55 12 17 23 + 70: TypeFloat 16 + 73: 7(int) Constant 16 + 72: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 71 73 13 12 + 74(lM): 7(int) SpecConstant 1 + 75(lN): 7(int) SpecConstant 1 + 76: TypeCooperativeMatrixKHR 70(float16_t) 13 74(lM) 75(lN) 24 + 79: 7(int) Constant 53 + 81: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 0(DebugInfoNone) + 77: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 78 22 18 79 12 21 80 81 13 + 82: TypeArray 76 24 + 83: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 5(DebugTypeArray) 77 24 + 84: TypeArray 82 24 + 85: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 5(DebugTypeArray) 83 24 + 86: TypePointer Private 84 + 87: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 85 11 12 + 88(result): 86(ptr) Variable Private + 91: 7(int) Constant 8 + 89: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 90 85 18 79 12 21 90 88(result) 91 + 95: 7(int) Constant 59 + 97:70(float16_t) Constant 0 + 98: 76 ConstantComposite 97 + 99: TypePointer Private 76 + 100: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 77 11 12 + 105: TypeInt 32 1 + 107: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 106 10 23 12 + 108: 105(int) Constant 1 + 117: 7(int) Constant 63 + 115: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 116 9 18 117 12 17 23 + 131(K): 7(int) SpecConstant 1 + 136: 7(int) Constant 64 + 134: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 135 9 18 136 12 17 23 + 150(TILE_K): 7(int) SpecConstant 1 + 151(lK): 7(int) SpecConstant 1 + 152: 7(int) SpecConstantOp 134 150(TILE_K) 151(lK) + 156: 7(int) Constant 67 + 155: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 33 9 18 156 12 17 23 + 171: TypeCooperativeMatrixKHR 70(float16_t) 13 74(lM) 151(lK) 12 + 174: 7(int) Constant 66 + 172: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 173 22 18 174 12 21 175 81 13 + 176: TypePointer Function 171 + 177: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 172 29 12 + 179: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 180 172 18 174 12 17 23 + 184: TypeVector 7(int) 4 + 185: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 6(DebugTypeVector) 9 23 + 186: 7(int) Constant 128 + 187: TypeArray 184(ivec4) 186 + 188: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 5(DebugTypeArray) 185 186 + 189: TypePointer Workgroup 187 + 190: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 188 23 12 + 191(Ash): 189(ptr) Variable Workgroup + 194: 7(int) Constant 68 + 192: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 193 188 18 194 12 21 193 191(Ash) 91 + 195: TypePointer Workgroup 184(ivec4) + 196: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 185 23 12 + 199: 105(int) Constant 0 + 201: TypeArray 171 24 + 202: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 5(DebugTypeArray) 172 24 + 203: TypePointer Function 201 + 204: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 202 29 12 + 206: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 207 202 18 174 12 17 23 + 220: 7(int) Constant 72 + 219: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 54 9 18 220 12 17 23 + 235: TypeCooperativeMatrixKHR 70(float16_t) 13 151(lK) 75(lN) 22 + 238: 7(int) Constant 71 + 236: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 237 22 18 238 12 21 239 81 13 + 240: TypePointer Function 235 + 241: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 236 29 12 + 243: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 180 236 18 238 12 17 23 + 247(Bsh): 189(ptr) Variable Workgroup + 250: 7(int) Constant 73 + 248: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 249 188 18 250 12 21 249 247(Bsh) 91 + 255: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 256 236 18 238 12 17 23 + 263: 7(int) Constant 75 + 262: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 33 9 18 263 12 17 23 + 280: 7(int) Constant 76 + 310: 7(int) Constant 82 + 309: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 33 9 18 310 12 17 23 + 327: 7(int) Constant 83 + 326: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 54 9 18 327 12 17 23 + 345: 7(int) Constant 84 + 349: TypeRuntimeArray 70(float16_t) + 350: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 5(DebugTypeArray) 72 12 + 351(Output): TypeStruct 349 + 354: 7(int) Constant 46 + 355: 7(int) Constant 24 + 352: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 11(DebugTypeMember) 353 350 18 354 355 12 12 13 + 356: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 357 22 18 345 12 21 357 12 13 352 + 358: TypePointer StorageBuffer 351(Output) + 359: 7(int) Constant 12 + 360: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 356 359 12 + 361(outputO): 358(ptr) Variable StorageBuffer + 362: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 363 356 18 345 12 21 363 361(outputO) 91 + 364: TypePointer StorageBuffer 70(float16_t) + 365: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 72 359 12 + 377: 7(int) Constant 87 + 378(TILE_M): 7(int) SpecConstant 1 + 379(TILE_N): 7(int) SpecConstant 1 + 14(main): 4 Function None 5 + 15: Label + 31(i): 28(ptr) Variable Function + 52(j): 28(ptr) Variable Function + 114(chunkK): 28(ptr) Variable Function + 133(k): 28(ptr) Variable Function + 154(i): 28(ptr) Variable Function + 178(tempArg): 176(ptr) Variable Function + 205(matA): 203(ptr) Variable Function + 218(j): 28(ptr) Variable Function + 242(tempArg): 240(ptr) Variable Function + 254(matB): 240(ptr) Variable Function + 261(i): 28(ptr) Variable Function + 308(i): 28(ptr) Variable Function + 325(j): 28(ptr) Variable Function + 26: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 27: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 20 20 12 12 + 25: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 101(DebugFunctionDefinition) 17 14(main) + 37: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 34 34 12 12 + 35: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 32 31(i) 36 + Store 31(i) 12 + Branch 38 + 38: Label + 42: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 43: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 34 34 12 12 + LoopMerge 40 41 Unroll + Branch 44 + 44: Label + 46: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 47: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 34 34 12 12 + 45: 7(int) Load 31(i) + 51: 48(bool) ULessThan 45 24 + BranchConditional 51 39 40 + 39: Label + 57: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 58: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 55 55 12 12 + 56: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 53 52(j) 36 + Store 52(j) 12 + Branch 59 + 59: Label + 63: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 64: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 55 55 12 12 + LoopMerge 61 62 Unroll + Branch 65 + 65: Label + 67: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 68: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 55 55 12 12 + 66: 7(int) Load 52(j) + 69: 48(bool) ULessThan 66 24 + BranchConditional 69 60 61 + 60: Label + 93: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 94: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 95 95 12 12 + 92: 7(int) Load 31(i) + 96: 7(int) Load 52(j) + 101: 99(ptr) AccessChain 88(result) 92 96 + Store 101 98 + Branch 62 + 62: Label + 103: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 104: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 55 55 12 12 + 102: 7(int) Load 52(j) + 109: 7(int) IAdd 102 108 + Store 52(j) 109 + Branch 59 + 61: Label + Branch 41 + 41: Label + 111: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 112: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 34 34 12 12 + 110: 7(int) Load 31(i) + 113: 7(int) IAdd 110 108 + Store 31(i) 113 + Branch 38 + 40: Label + 119: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 120: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 117 117 12 12 + 118: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 115 114(chunkK) 36 + Store 114(chunkK) 12 + Branch 121 + 121: Label + 125: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 126: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 117 117 12 12 + LoopMerge 123 124 None + Branch 127 + 127: Label + 129: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 130: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 117 117 12 12 + 128: 7(int) Load 114(chunkK) + 132: 48(bool) ULessThan 128 131(K) + BranchConditional 132 122 123 + 122: Label + 138: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 139: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 136 136 12 12 + 137: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 134 133(k) 36 + Store 133(k) 12 + Branch 140 + 140: Label + 144: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 145: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 136 136 12 12 + LoopMerge 142 143 Unroll + Branch 146 + 146: Label + 148: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 149: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 136 136 12 12 + 147: 7(int) Load 133(k) + 153: 48(bool) ULessThan 147 152 + BranchConditional 153 141 142 + 141: Label + 158: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 159: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 156 156 12 12 + 157: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 155 154(i) 36 + Store 154(i) 12 + Branch 160 + 160: Label + 164: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 165: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 156 156 12 12 + LoopMerge 162 163 Unroll + Branch 166 + 166: Label + 168: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 169: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 156 156 12 12 + 167: 7(int) Load 154(i) + 170: 48(bool) ULessThan 167 24 + BranchConditional 170 161 162 + 161: Label + 182: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 183: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 174 174 12 12 + 181: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 179 178(tempArg) 36 + 198: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 194 194 12 12 + 197: 195(ptr) AccessChain 191(Ash) 12 + 200: 171 CooperativeMatrixLoadKHR 197 199 12 MakePointerVisibleKHR NonPrivatePointerKHR 24 + Store 178(tempArg) 200 + 209: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 174 174 12 12 + 208: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 206 205(matA) 36 + 211: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 194 194 12 12 + 210: 7(int) Load 154(i) + 212: 171 Load 178(tempArg) + 213: 176(ptr) AccessChain 205(matA) 210 + Store 213 212 + Branch 163 + 163: Label + 215: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 216: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 156 156 12 12 + 214: 7(int) Load 154(i) + 217: 7(int) IAdd 214 108 + Store 154(i) 217 + Branch 160 + 162: Label + 222: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 223: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 220 220 12 12 + 221: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 219 218(j) 36 + Store 218(j) 12 + Branch 224 + 224: Label + 228: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 229: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 220 220 12 12 + LoopMerge 226 227 Unroll + Branch 230 + 230: Label + 232: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 233: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 220 220 12 12 + 231: 7(int) Load 218(j) + 234: 48(bool) ULessThan 231 24 + BranchConditional 234 225 226 + 225: Label + 245: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 246: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 238 238 12 12 + 244: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 243 242(tempArg) 36 + 252: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 250 250 12 12 + 251: 195(ptr) AccessChain 247(Bsh) 12 + 253: 235 CooperativeMatrixLoadKHR 251 199 12 MakePointerVisibleKHR NonPrivatePointerKHR 24 + Store 242(tempArg) 253 + 258: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 238 238 12 12 + 257: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 255 254(matB) 36 + 260: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 250 250 12 12 + 259: 235 Load 242(tempArg) + Store 254(matB) 259 + 265: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 263 263 12 12 + 264: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 262 261(i) 36 + Store 261(i) 12 + Branch 266 + 266: Label + 270: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 271: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 263 263 12 12 + LoopMerge 268 269 Unroll + Branch 272 + 272: Label + 274: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 275: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 263 263 12 12 + 273: 7(int) Load 261(i) + 276: 48(bool) ULessThan 273 24 + BranchConditional 276 267 268 + 267: Label + 278: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 279: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 280 280 12 12 + 277: 7(int) Load 261(i) + 281: 7(int) Load 218(j) + 282: 7(int) Load 261(i) + 283: 176(ptr) AccessChain 205(matA) 282 + 284: 171 Load 283 + 285: 235 Load 254(matB) + 286: 7(int) Load 261(i) + 287: 7(int) Load 218(j) + 288: 99(ptr) AccessChain 88(result) 286 287 + 289: 76 Load 288 + 290: 76 CooperativeMatrixMulAddKHR 284 285 289 + 291: 99(ptr) AccessChain 88(result) 277 281 + Store 291 290 + Branch 269 + 269: Label + 293: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 294: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 263 263 12 12 + 292: 7(int) Load 261(i) + 295: 7(int) IAdd 292 108 + Store 261(i) 295 + Branch 266 + 268: Label + Branch 227 + 227: Label + 297: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 298: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 220 220 12 12 + 296: 7(int) Load 218(j) + 299: 7(int) IAdd 296 108 + Store 218(j) 299 + Branch 224 + 226: Label + Branch 143 + 143: Label + 301: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 302: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 136 136 12 12 + 300: 7(int) Load 133(k) + 303: 7(int) IAdd 300 108 + Store 133(k) 303 + Branch 140 + 142: Label + Branch 124 + 124: Label + 305: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 306: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 117 117 12 12 + 304: 7(int) Load 114(chunkK) + 307: 7(int) IAdd 304 150(TILE_K) + Store 114(chunkK) 307 + Branch 121 + 123: Label + 312: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 313: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 310 310 12 12 + 311: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 309 308(i) 36 + Store 308(i) 12 + Branch 314 + 314: Label + 318: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 319: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 310 310 12 12 + LoopMerge 316 317 Unroll + Branch 320 + 320: Label + 322: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 323: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 310 310 12 12 + 321: 7(int) Load 308(i) + 324: 48(bool) ULessThan 321 24 + BranchConditional 324 315 316 + 315: Label + 329: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 330: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 327 327 12 12 + 328: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 326 325(j) 36 + Store 325(j) 12 + Branch 331 + 331: Label + 335: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 336: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 327 327 12 12 + LoopMerge 333 334 Unroll + Branch 337 + 337: Label + 339: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 340: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 327 327 12 12 + 338: 7(int) Load 325(j) + 341: 48(bool) ULessThan 338 24 + BranchConditional 341 332 333 + 332: Label + 343: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 344: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 345 345 12 12 + 342: 7(int) Load 308(i) + 346: 7(int) Load 325(j) + 347: 99(ptr) AccessChain 88(result) 342 346 + 348: 76 Load 347 + 366: 364(ptr) AccessChain 361(outputO) 199 12 + CooperativeMatrixStoreKHR 366 348 199 12 None + Branch 334 + 334: Label + 368: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 369: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 327 327 12 12 + 367: 7(int) Load 325(j) + 370: 7(int) IAdd 367 108 + Store 325(j) 370 + Branch 331 + 333: Label + Branch 317 + 317: Label + 372: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 373: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 310 310 12 12 + 371: 7(int) Load 308(i) + 374: 7(int) IAdd 371 108 + Store 308(i) 374 + Branch 314 + 316: Label + 375: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 + 376: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 377 377 12 12 + Return + FunctionEnd diff --git a/Test/baseResults/spv.debuginfo.hlsl.vert.out b/Test/baseResults/spv.debuginfo.hlsl.vert.out index d26021cf7f..094173a5a1 100644 --- a/Test/baseResults/spv.debuginfo.hlsl.vert.out +++ b/Test/baseResults/spv.debuginfo.hlsl.vert.out @@ -438,12 +438,12 @@ spv.debuginfo.hlsl.vert 202: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 30 203 203 16 16 201: 8(float) Load 128(s) 204: 8(float) Load 176(c) + 207: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 30 195 195 16 16 206: 18(fvec3) CompositeConstruct 198 200 97 - 207: 18(fvec3) CompositeConstruct 201 204 97 - 208: 18(fvec3) CompositeConstruct 97 97 205 - 209: 188 CompositeConstruct 206 207 208 - 210: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 30 195 195 16 16 - Store 192(mx) 209 + 208: 18(fvec3) CompositeConstruct 201 204 97 + 209: 18(fvec3) CompositeConstruct 97 97 205 + 210: 188 CompositeConstruct 206 208 209 + Store 192(mx) 210 212: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 30 213 213 16 16 211: 126(ptr) AccessChain 77(input) 134 52 214: 8(float) Load 211 @@ -468,12 +468,12 @@ spv.debuginfo.hlsl.vert 237: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 30 238 238 16 16 236: 8(float) Load 128(s) 239: 8(float) Load 176(c) + 241: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 30 230 230 16 16 240: 18(fvec3) CompositeConstruct 233 97 235 - 241: 18(fvec3) CompositeConstruct 97 205 97 - 242: 18(fvec3) CompositeConstruct 236 97 239 - 243: 188 CompositeConstruct 240 241 242 - 244: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 30 230 230 16 16 - Store 227(my) 243 + 242: 18(fvec3) CompositeConstruct 97 205 97 + 243: 18(fvec3) CompositeConstruct 236 97 239 + 244: 188 CompositeConstruct 240 242 243 + Store 227(my) 244 246: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 30 247 247 16 16 245: 126(ptr) AccessChain 77(input) 134 21 248: 8(float) Load 245 @@ -499,12 +499,12 @@ spv.debuginfo.hlsl.vert 273: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 30 274 274 16 16 272: 8(float) Load 128(s) 275: 8(float) Load 176(c) + 277: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 30 264 264 16 16 276: 18(fvec3) CompositeConstruct 205 97 97 - 277: 18(fvec3) CompositeConstruct 97 267 271 - 278: 18(fvec3) CompositeConstruct 97 272 275 - 279: 188 CompositeConstruct 276 277 278 - 280: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 30 264 264 16 16 - Store 261(mz) 279 + 278: 18(fvec3) CompositeConstruct 97 267 271 + 279: 18(fvec3) CompositeConstruct 97 272 275 + 280: 188 CompositeConstruct 276 278 279 + Store 261(mz) 280 286: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 30 284 284 16 16 285: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 282 281(rotMat) 85 287: 188 Load 192(mx) diff --git a/Test/spv.debuginfo.coopmatKHR.comp b/Test/spv.debuginfo.coopmatKHR.comp new file mode 100644 index 0000000000..dceffcea5e --- /dev/null +++ b/Test/spv.debuginfo.coopmatKHR.comp @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2019-2024, NVIDIA CORPORATION. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#version 450 core +#pragma use_vulkan_memory_model +#extension GL_EXT_scalar_block_layout : enable +#extension GL_KHR_memory_scope_semantics : enable +#extension GL_KHR_cooperative_matrix : enable +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : enable +#extension GL_EXT_shader_explicit_arithmetic_types_int8 : enable +#extension GL_EXT_shader_explicit_arithmetic_types_int32 : enable +#extension GL_EXT_buffer_reference : enable +#extension GL_EXT_control_flow_attributes : enable + +layout(constant_id = 0) const uint lM = 1; +layout(constant_id = 1) const uint lN = 1; +layout(constant_id = 2) const uint lK = 1; +layout(constant_id = 3) const uint TILE_M = 1; +layout(constant_id = 4) const uint TILE_N = 1; +layout(constant_id = 5) const uint TILE_K = 1; +layout(constant_id = 6) const uint K = 1; + +#define A_BITS 16 +#define A_TYPE float16_t +#define C_BITS 16 +#define C_TYPE float16_t + +buffer Output { C_TYPE x[]; } outputO; + +shared uvec4 Ash[128]; +shared uvec4 Bsh[128]; + +const uint C_ROWS = 2; +const uint C_COLS = 2; +coopmat result[C_ROWS][C_COLS]; + +void main() +{ + [[unroll]] for (uint i = 0; i < C_ROWS; ++i) { + [[unroll]] for (uint j = 0; j < C_COLS; ++j) { + result[i][j] = coopmat(0.0); + } + } + + for (uint chunkK = 0; chunkK < K; chunkK += TILE_K) { + [[unroll]] for (uint k = 0; k < TILE_K / lK; ++k) + { + coopmat matA[C_ROWS]; + [[unroll]] for (uint i = 0; i < C_ROWS; ++i) { + coopMatLoad(matA[i], Ash, 0, 0, gl_CooperativeMatrixLayoutRowMajor); + } + + coopmat matB; + [[unroll]] for (uint j = 0; j < C_COLS; ++j) { + coopMatLoad(matB, Bsh, 0, 0, gl_CooperativeMatrixLayoutRowMajor); + + [[unroll]] for (uint i = 0; i < C_ROWS; ++i) { + result[i][j] = coopMatMulAdd(matA[i], matB, result[i][j]); + } + } + } + } + + [[unroll]] for (uint i = 0; i < C_ROWS; ++i) { + [[unroll]] for (uint j = 0; j < C_COLS; ++j) { + coopMatStore(result[i][j], outputO.x, 0, 0, gl_CooperativeMatrixLayoutRowMajor); + } + } +} diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index 2267181654..bd2ee4ddec 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -959,6 +959,7 @@ INSTANTIATE_TEST_SUITE_P( "spv.debuginfo.include.glsl.frag", "spv.debuginfo.multiline.glsl.frag", "spv.debuginfo.implicit_br.glsl.frag", + "spv.debuginfo.coopmatKHR.comp", })), FileNameAsCustomTestSuffix );