diff --git a/README.adoc b/README.adoc index 2097bfa..3474d4c 100755 --- a/README.adoc +++ b/README.adoc @@ -114,3 +114,4 @@ that do not live in the Khronos registries for OpenGL or OpenGL ES. - link:{repo}/nv/GLSL_NV_explicit_typecast.txt[GL_NV_explicit_typecast] - link:{repo}/nv/GLSL_NV_cooperative_matrix_decode_vector.txt[GLSL_NV_cooperative_matrix_decode_vector] - link:{repo}/ext/GL_EXT_ocp_microscaling_types.txt[GL_EXT_ocp_microscaling_types] +- link:{repo}/ext/GLSL_EXT_cooperative_matrix_maintenance1.txt[GL_EXT_cooperative_matrix_maintenance1] diff --git a/extensions/ext/GLSL_EXT_cooperative_matrix_maintenance1.txt b/extensions/ext/GLSL_EXT_cooperative_matrix_maintenance1.txt new file mode 100644 index 0000000..fddef04 --- /dev/null +++ b/extensions/ext/GLSL_EXT_cooperative_matrix_maintenance1.txt @@ -0,0 +1,226 @@ +Name + + EXT_cooperative_matrix_maintenance1 + +Name Strings + + GL_EXT_cooperative_matrix_maintenance1 + +Contact + + Jeff Bolz, NVIDIA (jbolz 'at' nvidia.com) + +Contributors + + Karthik Vaidyanathan, NVIDIA + +Notice + + Copyright (c) 2025-2026 The Khronos Group Inc. Copyright terms at + http://www.khronos.org/registry/speccopyright.html + +Status + + Complete + +Version + + Last Modified: August 3, 2026 + Revision: 1 + +Dependencies + + This extension can be applied to OpenGL GLSL versions 4.50 + (#version 450) and higher. + This extension can be applied to OpenGL ES ESSL versions 3.20 + (#version 320) and higher. + + This extension depends on GL_KHR_cooperative_matrix. + +Overview + + This extension adds several new features building on the cooperative matrix + types added in GL_KHR_cooperative_matrix. The goal is to add and accelerate + features beyond just simple GEMM kernels, including adding support for type/use + conversions, reductions, per-element operations, and conversion of an element + index to a matrix coordinate. + + This extension is based on a subset of GL_NV_cooperative_matrix2, with the + addition of coopMatGetCoordinateEXT and support for some additional + conversions. + +Mapping to SPIR-V +----------------- + + For informational purposes (non-normative), the following is an + expected way for an implementation to map GLSL constructs to SPIR-V + constructs: + + coopMatReduceEXT -> OpCooperativeMatrixReduceEXT + coopmat constructor changing component type or Use -> Op*Convert or OpCooperativeMatrixConvertUseEXT + coopMatPerElementEXT -> OpCooperativeMatrixPerElementOpEXT + coopMatTransposeEXT -> Op*Convert or OpCooperativeMatrixConvertUseEXT with CooperativeMatrixTransposeEXT + coopMatGetCoordinateEXT -> OpCooperativeMatrixGetCoordinateEXT + + +Modifications to the OpenGL Shading Language Specification, Version 4.60 + + Including the following line in a shader can be used to control the + language features described in this extension: + + #extension GL_EXT_cooperative_matrix_maintenance1 : + + where is as specified in section 3.3. + + New preprocessor #defines are added to the OpenGL Shading Language: + + #define GL_EXT_cooperative_matrix_maintenance1 1 + + Update Section 5.4.X, Cooperative Matrix Type Constructors + + In addition to the cooperative matrix constructors defined by + GL_KHR_cooperative_matrix, cooperative matrices can be constructed from + another cooperative matrix type with the same scope, number of rows, and + number of columns, and where either the use of the source value is + gl_MatrixUseAccumulator and the use of the result type is gl_MatrixUseA or + gl_MatrixUseB, or the use of the result type is gl_MatrixUseAccumulator and + the use of the source value is gl_MatrixUseA or gl_MatrixUseB. This performs + a component-wise type conversion to initialize the new cooperative matrix. + +Modify Section 5.9, Expressions + + Conversions are allowed between cooperative matrix types with the same + scope, row size, and column size, and where either the uses are the same, + the use of the source is gl_MatrixUseAccumulator and the use of the result + type is gl_MatrixUseA or gl_MatrixUseB, or the use of the result type is + gl_MatrixUseAccumulator and the use of the source is gl_MatrixUseA or + gl_MatrixUseB. + +Modify Section 8.X, Cooperative Matrix Functions + + Elements of a matrix can have a reduction operation applied by calling: + + void coopMatReduceEXT(out coopmat result, coopmat m, int reduceMask, T combineOp); + + Description: Reduce the values in each row, column, 2x2, or entire matrix + by applying the combineOp function to combine values of the elements. The + result matrix has the reduced values in all the corresponding elements of + the matrix. + + _m_ and _result_ must have the same scope and component type, and must each + have use of gl_MatrixUseAccumulator. + + _reduceMask_ must be a constant expression whose value is one of the + gl_CooperativeMatrixReduce* constants defined below. + + If reduceMask includes gl_CooperativeMatrixReduce2x2EXT, it must not include + gl_CooperativeMatrixReduceRowEXT or gl_CooperativeMatrixReduceColumnEXT. + + If reduceMask includes gl_CooperativeMatrixReduce2x2EXT, the dimensions of + _result_ must be half the dimensions of _m_. + + If reduceMask equals gl_CooperativeMatrixReduceRowEXT, then elements of each + row are combined and the resulting value is assigned to all elements of the + corresponding row of the result, and _result_ must have the same number of + rows as _m_. + + If reduceMask equals gl_CooperativeMatrixReduceColumnEXT, then elements of each + column are combined and the resulting value is assigned to all elements of + the corresponding column of the result, and _result_ must have the same number + of columns as _m_. + + If reduceMask equals gl_CooperativeMatrixReduceRowAndColumnEXT, all elements + are combined and the resulting value is assigned to all elements of the result, + and _result_ can have any number of rows and columns. + + _combineOp_ must be the identifier of a user-defined function. Its return + type must match the component type of _m_. It must have two parameters, + each qualified as 'const in', with the same type as the component type of + _m_. It will be called on implementation-dependent elements of _m_ or + combinations thereof, to compute the combination of all elements in the + row, column, 2x2, or entire matrix. The function should be mathematically + commutative and associative, though floating-point operations may not be + exactly commutative or associative in practice. + + In the function used as the _combineOp_ parameter, and any function + called directly or indirectly by that function, tangled instructions + (as defined in the SPIR-V spec) are not allowed. + + gl_CooperativeMatrixReduce* are constant integer values which can be used for + the reduceMask parameter in coopMatReduceEXT. + + const int gl_CooperativeMatrixReduceRowEXT = 0x1; + const int gl_CooperativeMatrixReduceColumnEXT = 0x2; + const int gl_CooperativeMatrixReduceRowAndColumnEXT = 0x3; + const int gl_CooperativeMatrixReduce2x2EXT = 0x4; + + Note that sum-reductions can be efficiently performed on UseA and UseB + matrices by multiplying by a matrix filled with the value one. + + An operation can be performed on each element of a matrix by calling: + + void coopMatPerElementEXT(out coopmat result, coopmat m, T elemOp, ...); + + _elemOp_ must be the identifier of a user-defined function. All parameter + types must be qualified as 'const in'. The first two parameters of elemOp + must be uint32_t values which are passed the row and column number of the + element being operated on. The third parameter must have type matching the + component type of _m_, and is passed the value of the element being + operated on. The number of additional arguments must match the number of + parameters of _elemOp_ after the first three. For each additional argument + that is not a cooperative matrix, its type must match the corresponding + parameter type. Each additional cooperative matrix argument must have the + same type as _m_, and its component type must match the corresponding + parameter type. The corresponding element of each cooperative matrix + argument is passed to the function. _result_ must be the same type as _m_, + and the return type of _elemOp_ must match the component type of _result_. + + coopMatPerElementEXT treats the cooperative matrices as composite types, and + invokes _elemOp_ at least once per element of the composite, with the + return values of the function forming the corresponding elements of the + return value of coopMatPerElementEXT. The calls to _elemOp_ + are considered to be unordered against each other. + + In the function used as the _elemOp_ parameter, and any function + called directly or indirectly by that function, tangled instructions + (as defined in the SPIR-V spec) are not allowed. + + + A gl_MatrixUseAccumulator matrix can be transposed and converted to a + gl_MatrixUseA or gl_MatrixUseB matrix by calling: + + void coopMatTransposeEXT(out coopmat result, coopmat m); + + _m_ must have use of gl_MatrixUseAccumulator, and _result_ must have use of + gl_MatrixUseA or gl_MatrixUseB. _m_ and _result_ must have the same scope, + and the number of rows of _m_ must match the number of columns of _result_ + and the number of columns of _m_ must match the number of rows of _result_. + _result_ is filled with the transpose of _m_, with each component converted + to the component type of _result_. + + + The coordinates for an element of a cooperative matrix can be retrieved + by calling: + + uvec2 coopMatGetCoordinateEXT(coopmat m, uint index); + + _index_ must be in the range [0, m.length()), else the behavior is + undefined. The return value is a (row,column) coordinate for the element + in _m_ that corresponds to the array index _index_ when using array + subscripting syntax. + +Modify Section 9, Shading Language Grammar for Core Profile + +Add to tokens list: + + FUNCTION + +Add to type_specifier_nonarray: + + FUNCTION + +Revision History + +Revision 1 + +- Initial revision.