Skip to content

[SM6.10][Exec] Implement Remaining Smoke Tests#8366

Draft
V-FEXrt wants to merge 11 commits intomicrosoft:mainfrom
V-FEXrt:linalg-ops-smoke-test
Draft

[SM6.10][Exec] Implement Remaining Smoke Tests#8366
V-FEXrt wants to merge 11 commits intomicrosoft:mainfrom
V-FEXrt:linalg-ops-smoke-test

Conversation

@V-FEXrt
Copy link
Copy Markdown
Collaborator

@V-FEXrt V-FEXrt commented Apr 10, 2026

WIP

Implements smoke tests for the remaining operations

  • __builtin_LinAlg_FillMatrix
  • __builtin_LinAlg_CopyConvertMatrix
  • __builtin_LinAlg_MatrixLoadFromDescriptor
  • __builtin_LinAlg_MatrixLoadFromMemory
  • __builtin_LinAlg_MatrixLength
  • __builtin_LinAlg_MatrixGetCoordinate
  • __builtin_LinAlg_MatrixGetElement
  • __builtin_LinAlg_MatrixSetElement
  • __builtin_LinAlg_MatrixStoreToDescriptor
  • __builtin_LinAlg_MatrixStoreToMemory
  • __builtin_LinAlg_MatrixQueryAccumulatorLayout
  • __builtin_LinAlg_MatrixMatrixMultiply
  • __builtin_LinAlg_MatrixMatrixMultiplyAccumulate
  • __builtin_LinAlg_MatrixAccumulate
  • __builtin_LinAlg_MatrixVectorMultiply
  • __builtin_LinAlg_MatrixVectorMultiplyAdd
  • __builtin_LinAlg_MatrixAccumulateToDescriptor
  • __builtin_LinAlg_MatrixAccumulateToMemory
  • __builtin_LinAlg_MatrixOuterProduct
  • __builtin_LinAlg_Convert

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 10, 2026

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 5f8d05f9b760ae2be0242cad8ed719d10058b98c 7ce1fe28360f009e1bbbef6aebf5ec7aef6750ee -- tools/clang/unittests/HLSLExec/HlslExecTestUtils.cpp tools/clang/unittests/HLSLExec/LinAlgTests.cpp
View the diff from clang-format here.
diff --git a/tools/clang/unittests/HLSLExec/LinAlgTests.cpp b/tools/clang/unittests/HLSLExec/LinAlgTests.cpp
index b276d823..159d94d5 100644
--- a/tools/clang/unittests/HLSLExec/LinAlgTests.cpp
+++ b/tools/clang/unittests/HLSLExec/LinAlgTests.cpp
@@ -238,9 +238,9 @@ static bool fillInputBuffer(LPCSTR Name, std::vector<BYTE> &Data,
 }
 
 static VariantCompType makeExpectedMat(ComponentType CompType, MatrixDim M,
-                                    MatrixDim N, float StartingVal,
-                                    bool Increment = true,
-                                    bool Transpose = false) {
+                                       MatrixDim N, float StartingVal,
+                                       bool Increment = true,
+                                       bool Transpose = false) {
   const size_t NumElements = M * N;
   std::vector<float> Floats(NumElements);
   std::vector<int32_t> Ints(NumElements);
@@ -291,10 +291,11 @@ static VariantCompType makeExpectedMat(ComponentType CompType, MatrixDim M,
   }
 }
 
-static VariantCompType makeExpectedVec(ComponentType CompType, MatrixDim NumElements,
-                                    float StartingVal,
-                                    bool Increment = true) {
-  return makeExpectedMat(CompType, 1, NumElements, StartingVal, Increment, false);
+static VariantCompType makeExpectedVec(ComponentType CompType,
+                                       MatrixDim NumElements, float StartingVal,
+                                       bool Increment = true) {
+  return makeExpectedMat(CompType, 1, NumElements, StartingVal, Increment,
+                         false);
 }
 
 class DxilConf_SM610_LinAlg {
@@ -548,9 +549,9 @@ static const char AccumulateDescriptorShader[] = R"(
 )";
 
 static void runAccumulateDescriptor(ID3D12Device *Device,
-                          dxc::SpecificDllLoader &DxcSupport,
-                          const MatrixParams &Params, float FillValue,
-                          bool Verbose) {
+                                    dxc::SpecificDllLoader &DxcSupport,
+                                    const MatrixParams &Params, float FillValue,
+                                    bool Verbose) {
   const size_t NumElements = Params.totalElements();
   const size_t BufferSize = Params.totalBytes();
 
@@ -559,13 +560,14 @@ static void runAccumulateDescriptor(ID3D12Device *Device,
 
   std::string Args = buildCompilerArgs(Params, ExtraDefs.str().c_str());
 
-  compileShader(DxcSupport, AccumulateDescriptorShader, "cs_6_10", Args, Verbose);
+  compileShader(DxcSupport, AccumulateDescriptorShader, "cs_6_10", Args,
+                Verbose);
 
   auto Expected =
       makeExpectedMat(Params.CompType, Params.M, Params.N, FillValue, false);
 
-  auto Op =
-      createComputeOp(AccumulateDescriptorShader, "cs_6_10", "UAV(u0)", Args.c_str());
+  auto Op = createComputeOp(AccumulateDescriptorShader, "cs_6_10", "UAV(u0)",
+                            Args.c_str());
   addUAVBuffer(Op.get(), "Output", BufferSize, true);
   addRootUAV(Op.get(), 0, "Output");
 
@@ -827,7 +829,7 @@ static void runCopyConvert(ID3D12Device *Device,
   compileShader(DxcSupport, CopyConvertShader, "cs_6_10", Args, Verbose);
 
   auto Expected = makeExpectedMat(Params.CompType, Params.M, Params.N, 1,
-                               /*Increment=*/true, Transpose);
+                                  /*Increment=*/true, Transpose);
 
   // Construct the ShaderOp: two UAV buffers, load from one, store to other.
   auto Op = createComputeOp(CopyConvertShader, "cs_6_10", "UAV(u0), UAV(u1)",
@@ -931,7 +933,7 @@ static void runMatMatMul(ID3D12Device *Device,
   compileShader(DxcSupport, MatMatMulShader, "cs_6_10", Args, Verbose);
 
   auto Expected = makeExpectedMat(Params.CompType, Params.M, Params.N,
-                               AFill * BFill * K, /*Increment=*/false);
+                                  AFill * BFill * K, /*Increment=*/false);
 
   auto Op =
       createComputeOp(MatMatMulShader, "cs_6_10", "UAV(u0)", Args.c_str());
@@ -1013,8 +1015,9 @@ static void runMatMatMulAccum(ID3D12Device *Device,
 
   compileShader(DxcSupport, MatMatMulAccumShader, "cs_6_10", Args, Verbose);
 
-  auto Expected = makeExpectedMat(Params.CompType, Params.M, Params.N,
-                               AFill * BFill * K + CFill, /*Increment=*/false);
+  auto Expected =
+      makeExpectedMat(Params.CompType, Params.M, Params.N,
+                      AFill * BFill * K + CFill, /*Increment=*/false);
 
   auto Op =
       createComputeOp(MatMatMulAccumShader, "cs_6_10", "UAV(u0)", Args.c_str());
@@ -1088,7 +1091,7 @@ static void runMatAccum(ID3D12Device *Device,
   compileShader(DxcSupport, MatAccumShader, "cs_6_10", Args, Verbose);
 
   auto Expected = makeExpectedMat(Params.CompType, Params.M, Params.N,
-                               LHSFill + RHSFill, /*Increment=*/false);
+                                  LHSFill + RHSFill, /*Increment=*/false);
 
   auto Op = createComputeOp(MatAccumShader, "cs_6_10", "UAV(u0)", Args.c_str());
   addUAVBuffer(Op.get(), "Output", BufferSize, true);
@@ -1163,7 +1166,7 @@ static void runMatVecMul(ID3D12Device *Device,
   compileShader(DxcSupport, MatVecMulShader, "cs_6_10", Args, Verbose);
 
   auto Expected = makeExpectedVec(Params.CompType, Params.M, MatFill * Params.N,
-                               /*Increment=*/false);
+                                  /*Increment=*/false);
 
   auto Op = createComputeOp(MatVecMulShader, "cs_6_10", "UAV(u0), UAV(u1)",
                             Args.c_str());
@@ -1256,7 +1259,7 @@ static void runMatVecMulAdd(ID3D12Device *Device,
   compileShader(DxcSupport, MatVecMulAddShader, "cs_6_10", Args, Verbose);
 
   auto Expected = makeExpectedVec(Params.CompType, Params.M,
-                               MatFill * Params.N + 1, /*Increment=*/false);
+                                  MatFill * Params.N + 1, /*Increment=*/false);
 
   auto Op = createComputeOp(MatVecMulAddShader, "cs_6_10", "UAV(u0), UAV(u1)",
                             Args.c_str());
@@ -1338,8 +1341,8 @@ static void runOuterProduct(ID3D12Device *Device,
 
   compileShader(DxcSupport, OuterProductShader, "cs_6_10", Args, Verbose);
 
-  auto Expected = makeExpectedMat(Params.CompType, Params.M, Params.N,
-                               4, /*Increment=*/false);
+  auto Expected = makeExpectedMat(Params.CompType, Params.M, Params.N, 4,
+                                  /*Increment=*/false);
 
   auto Op = createComputeOp(OuterProductShader, "cs_6_10", "UAV(u0), UAV(u1)",
                             Args.c_str());
@@ -1351,8 +1354,9 @@ static void runOuterProduct(ID3D12Device *Device,
   auto Result = runShaderOp(
       Device, DxcSupport, std::move(Op),
       [NumVecElements, Params](LPCSTR Name, std::vector<BYTE> &Data,
-                            st::ShaderOp *) {
-        VERIFY_IS_TRUE(fillInputBuffer(Name, Data, Params.CompType, NumVecElements,
+                               st::ShaderOp *) {
+        VERIFY_IS_TRUE(fillInputBuffer(Name, Data, Params.CompType,
+                                       NumVecElements,
                                        /*StartingVal=*/2, /*Increment=*/false),
                        "Saw unsupported component type");
       });
@@ -1387,15 +1391,15 @@ static const char QueryAccumLayoutShader[] = R"(
 )";
 
 static void runQueryAccumLayout(ID3D12Device *Device,
-                            dxc::SpecificDllLoader &DxcSupport,
-                            bool Verbose) {
+                                dxc::SpecificDllLoader &DxcSupport,
+                                bool Verbose) {
   std::string Args = "-HV 202x";
   size_t BufferSize = elementSize(ComponentType::I32);
 
   compileShader(DxcSupport, QueryAccumLayoutShader, "cs_6_10", Args, Verbose);
 
-  auto Op =
-      createComputeOp(QueryAccumLayoutShader, "cs_6_10", "UAV(u0)", Args.c_str());
+  auto Op = createComputeOp(QueryAccumLayoutShader, "cs_6_10", "UAV(u0)",
+                            Args.c_str());
   addUAVBuffer(Op.get(), "Output", BufferSize, true);
   addRootUAV(Op.get(), 0, "Output");
 
@@ -1406,7 +1410,8 @@ static void runQueryAccumLayout(ID3D12Device *Device,
   const uint32_t *Out = static_cast<const uint32_t *>(OutData.data());
 
   // Accum Layout must be A or B
-  VERIFY_IS_TRUE(Out[0] == static_cast<uint32_t>(MatrixUse::A) || Out[0] == static_cast<uint32_t>(MatrixUse::B));
+  VERIFY_IS_TRUE(Out[0] == static_cast<uint32_t>(MatrixUse::A) ||
+                 Out[0] == static_cast<uint32_t>(MatrixUse::B));
   if (Verbose)
     hlsl_test::LogCommentFmt(L"AccumulatorLayout = %u", Out[0]);
 }
  • Check this box to apply formatting changes to this branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

1 participant