From da71d2e442ce0f80ebdaba96f47ac5a294bb3552 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Fri, 14 Nov 2025 15:45:23 -0600 Subject: [PATCH 1/2] [0035] Clarify `Length` for packed types This PR clarifies that `Length` returns the count of HLSL native elements rather than the number of matrix elements such that `Length` for packed types will be 1/4th the actual thread-accessible members. --- proposals/0035-linalg-matrix.md | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/proposals/0035-linalg-matrix.md b/proposals/0035-linalg-matrix.md index 10d69215..27d485b4 100644 --- a/proposals/0035-linalg-matrix.md +++ b/proposals/0035-linalg-matrix.md @@ -695,15 +695,18 @@ uint Matrix::Length(); Requires `Wave` or `ThreadGroup` scope matrix. -Returns the number of matrix components accessible to the current thread. The -mapping and distribution of threads to matrix elements is opaque and -implementation-specific. The value returned by `Length` may be different -for each thread. The sum of the values returned by `Length` across all -threads must be greater than or equal to the total number of matrix elements. -Some implementations may map multiple threads to the same matrix element. -Therefore, developers should take this into consideration when programming -side-effects, such as atomic operations and/or UAV writes, within user-defined -matrix operations. +Returns the number of matrix components accessible to the current thread. If the +matrix's elements are stored in a packed type `Length` will return the number of +packed elements (e.g. if a thread has 8 accessible elements of `int8` type which +are packed into 2 `int8_t4_packed`, `Length` will return 2). The mapping and +distribution of threads to matrix elements is opaque and +implementation-specific. The value returned by `Length` may be different for +each thread. The sum of the values returned by `Length` across all threads must +be greater than or equal to the total number of matrix elements. Some +implementations may map multiple threads to the same matrix element. Therefore, +developers should take this into consideration when programming side-effects, +such as atomic operations and/or UAV writes, within user-defined matrix +operations. May be called from non-uniform control flow. However, given the above rules, calling `Length` from divergent threads may result in unpredictable behavior. From 587391001bc5ab19ed40af5570451ade96077bdc Mon Sep 17 00:00:00 2001 From: Chris B Date: Wed, 19 Nov 2025 09:31:10 -0600 Subject: [PATCH 2/2] Update proposals/0035-linalg-matrix.md Co-authored-by: Helena Kotas --- proposals/0035-linalg-matrix.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proposals/0035-linalg-matrix.md b/proposals/0035-linalg-matrix.md index 27d485b4..46e7c61b 100644 --- a/proposals/0035-linalg-matrix.md +++ b/proposals/0035-linalg-matrix.md @@ -696,9 +696,9 @@ uint Matrix::Length(); Requires `Wave` or `ThreadGroup` scope matrix. Returns the number of matrix components accessible to the current thread. If the -matrix's elements are stored in a packed type `Length` will return the number of -packed elements (e.g. if a thread has 8 accessible elements of `int8` type which -are packed into 2 `int8_t4_packed`, `Length` will return 2). The mapping and +matrix's elements are stored in a packed type, `Length` will return the number of +packed elements (e.g. if a thread has 8 accessible elements of `int8` type +packed into 2 `int8_t4_packed`, `Length` will return 2). The mapping and distribution of threads to matrix elements is opaque and implementation-specific. The value returned by `Length` may be different for each thread. The sum of the values returned by `Length` across all threads must