yum-mirror/glslang
git clone https://git.yummers.dev/yum-mirror/glslang
4610b2dc
vulkan-sdk-1.4.357.0
1#version 450 core 2#extension GL_KHR_memory_scope_semantics : enable 3#extension GL_KHR_cooperative_matrix : enable 4#extension GL_EXT_shader_explicit_arithmetic_types : enable 5#extension GL_EXT_buffer_reference : enable 6 7layout ( local_size_x = 64 , local_size_y = 1 , local_size_z = 1 ) in ; 8 9const int X = 8 ; 10layout ( constant_id = 0 ) const int Y = 2 ; 11const int Z = X * Y ; 12 13coopmat < float16_t , gl_ScopeSubgroup , Z , 8 , gl_MatrixUseAccumulator > mC ; 14coopmat < float16_t , gl_ScopeSubgroup , Z , 8 , gl_MatrixUseAccumulator > mC2 [ 3 ] ; 15 16layout ( constant_id = 1 ) const float F = 3.0 ; 17 18const coopmat < float , gl_ScopeSubgroup , Z , 8 , gl_MatrixUseAccumulator > mD = coopmat < float , gl_ScopeSubgroup , Z , 8 , gl_MatrixUseAccumulator > ( 0.0 ) ; 19const coopmat < float16_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > mD2 = coopmat < float16_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > ( 1 ) ; 20 21struct S { int a ; int b ; int c ; } ; 22 23const S s = S ( 12 , 23 , 34 ) ; 24 25layout ( set = 0 , binding = 0 , buffer_reference ) coherent buffer Block { 26float y [ 1024 * 1024 ] ; 27float x [] ; 28} block ; 29 30layout ( set = 0 , binding = 0 ) coherent buffer Block16 { 31float16_t y [ 1024 * 1024 ] ; 32float16_t x [] ; 33 34Block b ; 35} block16 ; 36 37coopmat < float16_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > f16 ( coopmat < float16_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > m ) { return - m ; } 38coopmat < float , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > f32 ( coopmat < float , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > m ) { return - m ; } 39 40layout ( constant_id = 2 ) const int SC = 1 ; 41coopmat < float16_t , gl_ScopeSubgroup , SC , SC , gl_MatrixUseAccumulator > scm [ SC ][ SC ] ; 42 43// sized for coopmat<float16_t, gl_ScopeSubgroup, 16, 16, gl_MatrixUseAccumulator> 44shared uvec4 shmatrix [ 16 * 16 * 2 / 16 ] ; 45 46void main () 47{ 48coopmat < float , gl_ScopeSubgroup , 16 , ( 2 > 1 ? 8 : 4 ) , gl_MatrixUseAccumulator > m = coopmat < float , gl_ScopeSubgroup , 16 , ( 2 > 1 ? 8 : 4 ) , gl_MatrixUseAccumulator > ( 0.0 ) ; 49 50m = m + m ; 51m = m - m ; 52m = - m ; 53m = 2.0 * m ; 54m = m * 2.0 ; 55 56coopmat < float16_t , gl_ScopeSubgroup , 16 , 8 , gl_MatrixUseAccumulator > m2 = coopmat < float16_t , gl_ScopeSubgroup , 16 , 8 , gl_MatrixUseAccumulator > ( m ) ; 57 58float x = m [ 1 ] ; 59m [ 0 ] = x ; 60 61coopMatLoad ( m , block . x , 16 , 1 , gl_CooperativeMatrixLayoutRowBlockedInterleavedARM ) ; 62coopMatStore ( m , block . x , 16 , 1 , gl_CooperativeMatrixLayoutRowBlockedInterleavedARM ) ; 63coopMatLoad ( m2 , block16 . x , 16 , 1 , gl_CooperativeMatrixLayoutRowBlockedInterleavedARM ) ; 64coopMatStore ( m2 , block16 . x , 16 , 1 , gl_CooperativeMatrixLayoutRowBlockedInterleavedARM ) ; 65coopMatLoad ( m , block16 . b . x , 16 , 1 , gl_CooperativeMatrixLayoutRowBlockedInterleavedARM ) ; 66coopMatStore ( m , block16 . b . x , 16 , 1 , gl_CooperativeMatrixLayoutRowBlockedInterleavedARM ) ; 67 68coopmat < float16_t , gl_ScopeSubgroup , 16 , 8 , gl_MatrixUseA > A ; 69coopmat < float16_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseB > B ; 70coopmat < float , gl_ScopeSubgroup , 16 , 8 , gl_MatrixUseAccumulator > C ; 71coopmat < float , gl_ScopeSubgroup , 16 , 8 , gl_MatrixUseAccumulator > D ; 72D = coopMatMulAdd ( A , B , C ) ; 73 74int l = D . length () ; 75 76coopmat < float16_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > E ; 77 78coopmat < float16_t , gl_ScopeSubgroup , Z , Z , gl_MatrixUseAccumulator > F = coopmat < float16_t , gl_ScopeSubgroup , Z , Z , gl_MatrixUseAccumulator > ( 0.0 ) ; 79 80coopmat < float , gl_ScopeSubgroup , 16 , ( 2 > 1 ? 8 : 4 ) , gl_MatrixUseAccumulator > a [ 5 ] ; 81a [ 3 ][ 0 ] = 1.0 ; 82 83float md1 = mD [ 1 ] ; 84 85md1 += ( m += m )[ 1234 ] ; 86 87mC2 [ 1 ] = mC2 [ 2 ] ; 88 89coopMatLoad ( m , block . y , 16 , 1 , gl_CooperativeMatrixLayoutRowBlockedInterleavedARM ) ; 90coopMatStore ( m , block . y , 16 , 1 , gl_CooperativeMatrixLayoutRowBlockedInterleavedARM ) ; 91coopMatLoad ( m2 , block16 . y , 16 , 1 , gl_CooperativeMatrixLayoutRowBlockedInterleavedARM ) ; 92coopMatStore ( m2 , block16 . y , 16 , 1 , gl_CooperativeMatrixLayoutRowBlockedInterleavedARM ) ; 93 94coopmat < float16_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > p1 ; 95coopmat < float , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > p2 ; 96 97p1 = f16 ( p1 ) ; 98p2 = f32 ( p2 ) ; 99 100p1 = coopmat < float16_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > ( 0.0 ) ; 101p2 = coopmat < float , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > ( 0.0 ) ; 102 103p1 /= p1 ; 104 105p1 *= float16_t ( 2.0 ) ; 106p2 *= 4.0 ; 107 108coopmat < float16_t , gl_ScopeSubgroup , 16 , 16 , gl_MatrixUseAccumulator > ms ; 109coopMatLoad ( ms , shmatrix , 1 , 2 , gl_CooperativeMatrixLayoutRowBlockedInterleavedARM ) ; 110coopMatStore ( ms , shmatrix , 1 , 2 , gl_CooperativeMatrixLayoutRowBlockedInterleavedARM ) ; 111 112coopmat < int8_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseA > ms8A ; 113coopmat < int8_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseB > ms8B ; 114coopmat < int8_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > ms8C ; 115coopMatMulAdd ( ms8A , ms8B , ms8C ) ; 116coopMatMulAdd ( ms8A , ms8B , ms8C , 0 ) ; 117coopMatMulAdd ( ms8A , ms8B , ms8C , gl_MatrixOperandsSaturatingAccumulation ) ; 118 119coopmat < int16_t , gl_ScopeSubgroup , 8 , 16 , gl_MatrixUseA > m16 ; 120coopMatStore ( m16 , shmatrix , 1 , 2 , gl_CooperativeMatrixLayoutRowBlockedInterleavedARM ) ; 121}