yum-mirror/glslang
git clone https://git.yummers.dev/yum-mirror/glslang
24ae85ba
main
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_NV_cooperative_matrix2 : enable 6#extension GL_EXT_buffer_reference : enable 7 8layout ( local_size_x = 64 , local_size_y = 1 , local_size_z = 1 ) in ; 9 10buffer BufType { 11float16_t x [] ; 12} Buf ; 13 14layout ( buffer_reference , std430 , buffer_reference_align = 2 ) buffer fp16Buf { 15float16_t f ; 16} ; 17 18 19float16_t decode0 ( const in fp16Buf b , const in uint32_t blockCoords [ 2 ] , const in uint32_t coordInBlock [ 2 ]) { return b . f ; } 20float16_t decode1 ( const fp16Buf b , const in uint32_t blockCoords [ 2 ] , const in uint32_t coordInBlock [ 2 ]) { return b . f ; } 21float16_t decode2 ( in fp16Buf b , const in uint32_t blockCoords [ 2 ] , const in uint32_t coordInBlock [ 2 ]) { return b . f ; } 22float16_t decode3 ( fp16Buf b , const in uint32_t blockCoords [ 2 ] , const in uint32_t coordInBlock [ 2 ]) { return b . f ; } 23float16_t decode4 ( const in fp16Buf b , const uint32_t blockCoords [ 2 ] , const in uint32_t coordInBlock [ 2 ]) { return b . f ; } 24float16_t decode5 ( const in fp16Buf b , in uint32_t blockCoords [ 2 ] , const in uint32_t coordInBlock [ 2 ]) { return b . f ; } 25float16_t decode6 ( const in fp16Buf b , uint32_t blockCoords [ 2 ] , const in uint32_t coordInBlock [ 2 ]) { return b . f ; } 26float16_t decode7 ( const in fp16Buf b , const in uint32_t blockCoords [ 2 ] , const uint32_t coordInBlock [ 2 ]) { return b . f ; } 27float16_t decode8 ( const in fp16Buf b , const in uint32_t blockCoords [ 2 ] , in uint32_t coordInBlock [ 2 ]) { return b . f ; } 28float16_t decode9 ( const in fp16Buf b , const in uint32_t blockCoords [ 2 ] , uint32_t coordInBlock [ 2 ]) { return b . f ; } 29float16_t decode10 ( const in uint32_t b , const in uint16_t blockCoords [ 2 ] , const in uint16_t coordInBlock [ 2 ]) { return float16_t ( 0 ) ; } 30float16_t decode11 ( const in fp16Buf b , const in uint32_t blockCoords , const in uint32_t coordInBlock ) { return float16_t ( 0 ) ; } 31 32struct S { 33f16vec2 x ; 34} ; 35 36float16_t combineSum ( const in float16_t a , const in float16_t b ) { return a + b ; } 37float16_t combineSum2 ( float16_t a , float16_t b ) { return a + b ; } 38 39layout ( constant_id = 0 ) const uint32_t Clamp = gl_CooperativeMatrixClampModeConstantNV ; 40 41float16_t relu ( const in uint32_t row , const in uint32_t col , const in float16_t x ) { return max ( x , float16_t ( 0 )) ; } 42float16_t add ( const in uint32_t row , const in uint32_t col , const in float16_t x , const in float16_t y ) { return x + y ; } 43float32_t perelemf32 ( const in uint32_t row , const in uint32_t col , const in float16_t x ) { return float32_t ( x ) ; } 44 45void main () 46{ 47coopmat < float16_t , gl_ScopeWorkgroup , 64 , 32 , gl_MatrixUseAccumulator > A ; 48 49tensorLayoutNV < 2 > t = createTensorLayoutNV ( 2 ) ; 50 51coopMatLoadTensorNV ( A , Buf . x , 0 , t , decode0 ) ; 52coopMatLoadTensorNV ( A , Buf . x , 0 , t , decode1 ) ; 53coopMatLoadTensorNV ( A , Buf . x , 0 , t , decode2 ) ; 54coopMatLoadTensorNV ( A , Buf . x , 0 , t , decode3 ) ; 55coopMatLoadTensorNV ( A , Buf . x , 0 , t , decode4 ) ; 56coopMatLoadTensorNV ( A , Buf . x , 0 , t , decode5 ) ; 57coopMatLoadTensorNV ( A , Buf . x , 0 , t , decode6 ) ; 58coopMatLoadTensorNV ( A , Buf . x , 0 , t , decode7 ) ; 59coopMatLoadTensorNV ( A , Buf . x , 0 , t , decode8 ) ; 60coopMatLoadTensorNV ( A , Buf . x , 0 , t , decode9 ) ; 61coopMatLoadTensorNV ( A , Buf . x , 0 , t , decode10 ) ; 62coopMatLoadTensorNV ( A , Buf . x , 0 , t , decode11 ) ; 63 64coopmat < float32_t , gl_ScopeWorkgroup , 64 , 32 , gl_MatrixUseAccumulator > Af32 ; 65 66coopMatReduceNV ( A , A , gl_CooperativeMatrixReduceRowNV , combineSum ) ; 67coopMatReduceNV ( A , A , gl_CooperativeMatrixReduceRowNV , combineSum2 ) ; 68coopMatReduceNV ( Af32 , Af32 , gl_CooperativeMatrixReduceRowNV , combineSum ) ; 69 70coopMatPerElementNV ( A , A , relu ) ; 71coopMatPerElementNV ( A , A , add , float16_t ( 1.0 )) ; 72coopMatPerElementNV ( A , A , add , coopmat < float16_t , gl_ScopeWorkgroup , 64 , 32 , gl_MatrixUseAccumulator > ( 1.0 )) ; 73coopMatPerElementNV ( A , A , add , float32_t ( 1.0 )) ; 74coopMatPerElementNV ( A , A , add , coopmat < float32_t , gl_ScopeWorkgroup , 64 , 32 , gl_MatrixUseAccumulator > ( 1.0 )) ; 75coopMatPerElementNV ( A , A , add ) ; 76coopMatPerElementNV ( A , A , add , float16_t ( 1.0 ) , float16_t ( 1.0 )) ; 77coopMatPerElementNV ( Af32 , A , perelemf32 ) ; 78coopMatPerElementNV ( Af32 , A , relu ) ; 79 80float16_t larr [ 16 ] ; 81coopMatLoadTensorNV ( A , larr , 0 , t ) ; 82coopMatStoreTensorNV ( A , larr , 0 , t ) ; 83 84coopmat < float16_t , gl_ScopeWorkgroup , 64 , 32 , gl_MatrixUseB > Bf16 ; 85coopmat < float16_t , gl_ScopeWorkgroup , 64 , 32 , gl_MatrixUseAccumulator > Accf16 ; 86coopMatTransposeNV ( Bf16 , Accf16 ) ; 87}