#version 460
#if defined(GL_AMD_gpu_shader_half_float)
#extension GL_AMD_gpu_shader_half_float : require
#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16)
#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require
#else
#error No extension available for FP16.
#endif
#extension GL_EXT_shader_16bit_storage : require
#extension GL_EXT_shader_explicit_arithmetic_types_int8 : require
#extension GL_EXT_shader_8bit_storage : require
#extension GL_KHR_cooperative_matrix : require
#extension GL_KHR_memory_scope_semantics : require
#extension GL_KHR_shader_subgroup_basic : require
layout(local_size_x = 32, local_size_y = 1, local_size_z = 1) in;

layout(set = 0, binding = 0, std430) restrict readonly buffer SSBO
{
    uint8_t _m0[];
} _20;

layout(set = 0, binding = 0, std430) writeonly buffer _22_24
{
    uint8_t _m0[];
} _24;

shared uint _28[512];

void main()
{
    coopmat<float16_t, gl_ScopeSubgroup, 16u, 16u, gl_MatrixUseA> _33;
    coopMatLoad(_33, _20._m0, 0u, 32u, gl_CooperativeMatrixLayoutRowMajor);
    coopMatStore(_33, _28, 0u, 32u, gl_CooperativeMatrixLayoutRowMajor);
    barrier();
    subgroupMemoryBarrierShared();
    subgroupBarrier();
    coopmat<float16_t, gl_ScopeSubgroup, 16u, 16u, gl_MatrixUseA> _38;
    coopMatLoad(_38, _28, 0u, 32u, gl_CooperativeMatrixLayoutColumnMajor);
    subgroupMemoryBarrierShared();
    subgroupBarrier();
    subgroupMemoryBarrierShared();
    subgroupBarrier();
    coopmat<float16_t, gl_ScopeSubgroup, 16u, 16u, gl_MatrixUseB> _40;
    coopMatLoad(_40, _28, 0u, 32u, gl_CooperativeMatrixLayoutRowMajor);
    subgroupMemoryBarrierShared();
    subgroupBarrier();
    coopMatStore(coopMatMulAdd(_38, _40, coopmat<float, gl_ScopeSubgroup, 16u, 16u, gl_MatrixUseAccumulator>(0.0), 0), _24._m0, 0u, 64u, gl_CooperativeMatrixLayoutRowMajor);
}


#if 0
// SPIR-V disassembly
// WaveSize(32)
; SPIR-V
; Version: 1.6
; Generator: Unknown(30017); 21022
; Bound: 48
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability Int8
OpCapability StorageBuffer8BitAccess
OpCapability DenormPreserve
OpCapability VulkanMemoryModel
OpCapability CooperativeMatrixKHR
OpExtension "SPV_KHR_8bit_storage"
OpExtension "SPV_KHR_cooperative_matrix"
OpExtension "SPV_KHR_float_controls"
OpMemoryModel Logical Vulkan
OpEntryPoint GLCompute %14 "main" %20 %24 %28
OpExecutionMode %14 LocalSize 32 1 1
OpExecutionMode %14 DenormPreserve 16
OpName %14 "main"
OpName %18 "SSBO"
OpName %22 "SSBO"
OpDecorate %17 ArrayStride 1
OpMemberDecorate %18 0 Offset 0
OpDecorate %18 Block
OpDecorate %20 DescriptorSet 0
OpDecorate %20 Binding 0
OpDecorate %20 NonWritable
OpDecorate %20 Restrict
OpDecorate %21 ArrayStride 1
OpMemberDecorate %22 0 Offset 0
OpDecorate %22 Block
OpDecorate %24 DescriptorSet 0
OpDecorate %24 Binding 0
OpDecorate %24 NonReadable
%1 = OpTypeFloat 16
%2 = OpTypeInt 32 0
%3 = OpConstant %2 0
%4 = OpConstant %2 16
%6 = OpConstant %2 3
%5 = OpTypeCooperativeMatrixKHR %1 %6 %4 %4 %3
%7 = OpConstant %2 1
%8 = OpTypeCooperativeMatrixKHR %1 %6 %4 %4 %7
%9 = OpTypeFloat 32
%10 = OpConstant %2 2
%11 = OpTypeCooperativeMatrixKHR %9 %6 %4 %4 %10
%12 = OpTypeVoid
%13 = OpTypeFunction %12
%16 = OpTypeInt 8 0
%17 = OpTypeRuntimeArray %16
%18 = OpTypeStruct %17
%19 = OpTypePointer StorageBuffer %18
%20 = OpVariable %19 StorageBuffer
%21 = OpTypeRuntimeArray %16
%22 = OpTypeStruct %21
%23 = OpTypePointer StorageBuffer %22
%24 = OpVariable %23 StorageBuffer
%25 = OpConstant %2 512
%26 = OpTypeArray %2 %25
%27 = OpTypePointer Workgroup %26
%28 = OpVariable %27 Workgroup
%30 = OpTypePointer StorageBuffer %16
%32 = OpConstant %2 32
%34 = OpTypePointer Workgroup %2
%36 = OpConstant %2 24840
%41 = OpConstant %9 0
%42 = OpConstantComposite %11 %41
%45 = OpConstant %2 64
%14 = OpFunction %12 None %13
%15 = OpLabel
OpBranch %46
%46 = OpLabel
%31 = OpAccessChain %30 %20 %3 %3
%33 = OpCooperativeMatrixLoadKHR %5 %31 %3 %32 NonPrivatePointer
%35 = OpAccessChain %34 %28 %3
OpCooperativeMatrixStoreKHR %35 %33 %3 %32 NonPrivatePointer
OpControlBarrier %10 %10 %36
%37 = OpAccessChain %34 %28 %3
OpControlBarrier %6 %6 %36
%38 = OpCooperativeMatrixLoadKHR %5 %37 %7 %32 NonPrivatePointer
OpControlBarrier %6 %6 %36
%39 = OpAccessChain %34 %28 %3
OpControlBarrier %6 %6 %36
%40 = OpCooperativeMatrixLoadKHR %8 %39 %3 %32 NonPrivatePointer
OpControlBarrier %6 %6 %36
%43 = OpCooperativeMatrixMulAddKHR %11 %38 %40 %42
%44 = OpAccessChain %30 %24 %3 %3
OpCooperativeMatrixStoreKHR %44 %43 %3 %45 NonPrivatePointer
OpReturn
OpFunctionEnd
#endif
