Skip to content

Commit 0a93e8e

Browse files
JoeCitizenJack Elliott
andauthored
[HLSL] Add non-square LinAlg CopyConvert coverage (#8620)
Add non-square SM6.10 Linear Algebra CopyConvert execution coverage. - Adds `CopyConvert_Wave_4x8_F32_Transpose` using independently derived expected values. - Parameterizes source and destination dimensions and row strides for CopyConvert. - Corrects CPU-reference indexing that was previously masked by square-only matrices. - Preserves the existing 16x16 F16 CopyConvert behaviour. ## Validation - Built `ExecHLSLTests.dll`, `dxcompiler.dll` and `dxc.exe` successfully. - The new test passed end-to-end on Microsoft Basic Render Driver using WARP `1.65535.20-preview` and D3D12 Agility SDK `1.721.2-preview`. - Both existing 16x16 F16 CopyConvert tests passed on the same runtime. - Full LinAlg class: 20 total, 19 passed, 0 failed and 1 pre-existing OuterProduct skip because the released SDK headers do not expose `DIRECT3D_LINEAR_ALGEBRA`. - No physical GPU or HLK lab execution is claimed. ## AI assistance and human review **Human owner:** @JoeCitizen **Review completed:** 21 July 2026 The human owner reviewed the changed source and validation evidence, understands the non-square transpose, expected 8x4 matrix, and source/destination stride changes, and explicitly approved promotion from draft to maintainer review. The human owner adopts the rationale above and remains responsible for the contribution. Substantial AI assistance is disclosed below. Assisted-by: GitHub Copilot Refs #8546 Co-authored-by: Jack Elliott <jackell@ntdev.microsoft.com>
1 parent 5955df0 commit 0a93e8e

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

tools/clang/unittests/HLSLExec/LinAlgTests.cpp

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ static VariantCompType makeExpectedMat(ComponentType CompType, MatrixDim M,
255255

256256
for (size_t I = 0; I < M; ++I) {
257257
for (size_t J = 0; J < N; ++J) {
258-
size_t Value = I * M + J;
259-
size_t Idx = Transpose ? J * N + I : Value;
258+
size_t Value = I * N + J;
259+
size_t Idx = Transpose ? J * M + I : Value;
260260
switch (CompType) {
261261
case ComponentType::F32:
262262
Floats[Idx] = StartingVal + static_cast<float>(Increment ? Value : 0);
@@ -340,6 +340,7 @@ class DxilConf_SM610_LinAlg {
340340
// Cast/Convert
341341
TEST_METHOD(CopyConvert_Wave_16x16_F16);
342342
TEST_METHOD(CopyConvert_Wave_16x16_F16_Transpose);
343+
TEST_METHOD(CopyConvert_Wave_4x8_F32_Transpose);
343344

344345
// Matrix Matrix Arithmetic
345346
TEST_METHOD(MatMatMul_Wave_16x16x16_F16);
@@ -819,14 +820,14 @@ static const char CopyConvertShader[] = R"(
819820
[[__LinAlgMatrix_Attributes(COMP_TYPE, M_DIM, N_DIM, USE, SCOPE)]]
820821
Src;
821822
__builtin_LinAlgMatrix
822-
[[__LinAlgMatrix_Attributes(COMP_TYPE, N_DIM, M_DIM, USE, SCOPE)]]
823+
[[__LinAlgMatrix_Attributes(COMP_TYPE, DST_M_DIM, DST_N_DIM, USE, SCOPE)]]
823824
Dst;
824825
825826
__builtin_LinAlg_MatrixLoadFromDescriptor(
826-
Src, Input, 0, STRIDE, LAYOUT, 128);
827+
Src, Input, 0, SRC_STRIDE, LAYOUT, 128);
827828
__builtin_LinAlg_CopyConvertMatrix(Dst, Src, TRANSPOSE);
828829
__builtin_LinAlg_MatrixStoreToDescriptor(
829-
Dst, Output, 0, STRIDE, LAYOUT, 128);
830+
Dst, Output, 0, DST_STRIDE, LAYOUT, 128);
830831
}
831832
)";
832833

@@ -836,9 +837,18 @@ static void runCopyConvert(ID3D12Device *Device,
836837
bool Transpose) {
837838
const size_t NumElements = Params.totalElements();
838839
const size_t BufferSize = Params.totalBytes();
840+
MatrixParams DstParams = Params;
841+
if (Transpose) {
842+
DstParams.M = Params.N;
843+
DstParams.N = Params.M;
844+
}
839845

840846
std::stringstream ExtraDefs;
841847
ExtraDefs << " -DTRANSPOSE=" << Transpose;
848+
ExtraDefs << " -DDST_M_DIM=" << DstParams.M;
849+
ExtraDefs << " -DDST_N_DIM=" << DstParams.N;
850+
ExtraDefs << " -DSRC_STRIDE=" << Params.strideBytes();
851+
ExtraDefs << " -DDST_STRIDE=" << DstParams.strideBytes();
842852

843853
std::string Args = buildCompilerArgs(Params, ExtraDefs.str().c_str());
844854

@@ -899,6 +909,21 @@ void DxilConf_SM610_LinAlg::CopyConvert_Wave_16x16_F16_Transpose() {
899909
/*Transpose=*/true);
900910
}
901911

912+
void DxilConf_SM610_LinAlg::CopyConvert_Wave_4x8_F32_Transpose() {
913+
MatrixParams Params = {};
914+
Params.CompType = ComponentType::F32;
915+
Params.M = 4;
916+
Params.N = 8;
917+
Params.Use = MatrixUse::A;
918+
Params.Scope = MatrixScope::Wave;
919+
Params.Layout = LinalgMatrixLayout::RowMajor;
920+
Params.NumThreads = 64;
921+
Params.Enable16Bit = false;
922+
// Non-square dimensions make the destination shape and row stride observable.
923+
runCopyConvert(D3DDevice, DxcSupport, Params, VerboseLogging,
924+
/*Transpose=*/true);
925+
}
926+
902927
static const char MatMatMulShader[] = R"(
903928
#define USE_A 0
904929
#define USE_B 1

0 commit comments

Comments
 (0)