yum-mirror/glslang
git clone https://git.yummers.dev/yum-mirror/glslang
8e12361e
vulkan-sdk-1.4.363.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 arr [ 256 ][ 256 ] ; 32float16_t y [ 1024 * 1024 ] ; 33float16_t x [] ; 34 35Block b ; 36} block16 ; 37 38coopmat < float16_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > f16 ( coopmat < float16_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > m ) { return - m ; } 39coopmat < float , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > f32 ( coopmat < float , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > m ) { return - m ; } 40 41layout ( constant_id = 2 ) const int SC = 1 ; 42coopmat < float16_t , gl_ScopeSubgroup , SC , SC , gl_MatrixUseAccumulator > scm [ SC ][ SC ] ; 43 44// sized for coopmat<float16_t, gl_ScopeSubgroup, 16, 16, gl_MatrixUseAccumulator> 45shared uvec4 shmatrix [ 16 * 16 * 2 / 16 ] ; 46 47void main () 48{ 49coopmat < float , gl_ScopeSubgroup , 16 , ( 2 > 1 ? 8 : 4 ) , gl_MatrixUseAccumulator > m = coopmat < float , gl_ScopeSubgroup , 16 , ( 2 > 1 ? 8 : 4 ) , gl_MatrixUseAccumulator > ( 0.0 ) ; 50 51m = m + m ; 52m = m - m ; 53m = - m ; 54m = 2.0 * m ; 55m = m * 2.0 ; 56 57coopmat < float16_t , gl_ScopeSubgroup , 16 , 8 , gl_MatrixUseAccumulator > m2 = coopmat < float16_t , gl_ScopeSubgroup , 16 , 8 , gl_MatrixUseAccumulator > ( m ) ; 58 59float x = m [ 1 ] ; 60m [ 0 ] = x ; 61 62coopMatLoad ( m , block . x , 16 , 128 , gl_CooperativeMatrixLayoutRowMajor ) ; 63coopMatStore ( m , block . x , 16 , 128 , gl_CooperativeMatrixLayoutRowMajor ) ; 64coopMatLoad ( m2 , block16 . x , 16 , 128 , gl_CooperativeMatrixLayoutRowMajor ) ; 65coopMatStore ( m2 , block16 . x , 16 , 128 , gl_CooperativeMatrixLayoutRowMajor ) ; 66coopMatLoad ( m , block16 . b . x , 16 , 128 , gl_CooperativeMatrixLayoutRowMajor ) ; 67coopMatStore ( m , block16 . b . x , 16 , 128 , gl_CooperativeMatrixLayoutRowMajor ) ; 68 69coopmat < float16_t , gl_ScopeSubgroup , 16 , 8 , gl_MatrixUseA > A ; 70coopmat < float16_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseB > B ; 71coopmat < float , gl_ScopeSubgroup , 16 , 8 , gl_MatrixUseAccumulator > C ; 72coopmat < float , gl_ScopeSubgroup , 16 , 8 , gl_MatrixUseAccumulator > D ; 73D = coopMatMulAdd ( A , B , C ) ; 74 75int l = D . length () ; 76 77coopmat < float16_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > E ; 78 79coopmat < float16_t , gl_ScopeSubgroup , Z , Z , gl_MatrixUseAccumulator > F = coopmat < float16_t , gl_ScopeSubgroup , Z , Z , gl_MatrixUseAccumulator > ( 0.0 ) ; 80 81coopmat < float , gl_ScopeSubgroup , 16 , ( 2 > 1 ? 8 : 4 ) , gl_MatrixUseAccumulator > a [ 5 ] ; 82a [ 3 ][ 0 ] = 1.0 ; 83 84float md1 = mD [ 1 ] ; 85 86md1 += ( m += m )[ 1234 ] ; 87 88mC2 [ 1 ] = mC2 [ 2 ] ; 89 90coopMatLoad ( m , block . y , 16 , 128 , gl_CooperativeMatrixLayoutRowMajor ) ; 91coopMatStore ( m , block . y , 16 , 128 , gl_CooperativeMatrixLayoutRowMajor ) ; 92coopMatLoad ( m2 , block16 . y , 16 , 128 , gl_CooperativeMatrixLayoutRowMajor ) ; 93coopMatStore ( m2 , block16 . y , 16 , 128 , gl_CooperativeMatrixLayoutRowMajor ) ; 94 95coopmat < float16_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > p1 ; 96coopmat < float , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > p2 ; 97 98p1 = f16 ( p1 ) ; 99p2 = f32 ( p2 ) ; 100 101p1 = coopmat < float16_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > ( 0.0 ) ; 102p2 = coopmat < float , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > ( 0.0 ) ; 103 104p1 /= p1 ; 105 106p1 *= float16_t ( 2.0 ) ; 107p2 *= 4.0 ; 108 109coopmat < float16_t , gl_ScopeSubgroup , 16 , 8 , gl_MatrixUseAccumulator > ms ; 110coopMatLoad ( ms , shmatrix , 1 , 2 , gl_CooperativeMatrixLayoutRowMajor ) ; 111coopMatStore ( ms , shmatrix , 1 , 2 , gl_CooperativeMatrixLayoutRowMajor ) ; 112 113coopMatLoad ( ms , block16 . arr [ 8 ] , 1 , 2 , gl_CooperativeMatrixLayoutRowMajor ) ; 114coopMatStore ( ms , block16 . arr [ 16 ] , 1 , 2 , gl_CooperativeMatrixLayoutRowMajor ) ; 115 116coopmat < int8_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseA > ms8A ; 117coopmat < int8_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseB > ms8B ; 118coopmat < int8_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseAccumulator > ms8C ; 119coopMatMulAdd ( ms8A , ms8B , ms8C ) ; 120coopMatMulAdd ( ms8A , ms8B , ms8C , 0 ) ; 121coopMatMulAdd ( ms8A , ms8B , ms8C , gl_MatrixOperandsSaturatingAccumulation ) ; 122 123coopmat < int16_t , gl_ScopeSubgroup , 8 , 8 , gl_MatrixUseA > m16 ; 124coopMatStore ( m16 , shmatrix , 1 , 2 , gl_CooperativeMatrixLayoutRowMajor ) ; 125}