Skip to content

[SM6.10][HLK] Add LinAlg execution test infrastructure with Load/Store/Splat tests#8285

Open
V-FEXrt wants to merge 8 commits intomicrosoft:mainfrom
V-FEXrt:linalg-basic-hlk
Open

[SM6.10][HLK] Add LinAlg execution test infrastructure with Load/Store/Splat tests#8285
V-FEXrt wants to merge 8 commits intomicrosoft:mainfrom
V-FEXrt:linalg-basic-hlk

Conversation

@V-FEXrt
Copy link
Collaborator

@V-FEXrt V-FEXrt commented Mar 20, 2026

Introduce LinAlgTests.cpp with a new pattern for execution tests where ShaderOp objects are built programmatically in C++ no ShaderOpArith.xml entries required. Shader source, resources, and root signatures are all defined in the .cpp file.

Tests will currently be skipped since no driver reports SM6.10 support

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Introduce LinAlgTests.cpp with a new pattern for execution tests where
ShaderOp objects are built programmatically in C++  no ShaderOpArith.xml
entries required. Shader source, resources, and root signatures are all
defined in the .cpp file.

Each test compiles its shader via IDxcCompiler3 to validate the HLSL,
then skips GPU dispatch if no SM 6.10 device is available. This ensures
shader authoring correctness is always verified.

Tests added:
- LoadStoreRoundtrip_Wave_F32/I32: MatrixLoadFromDescriptor + MatrixStoreToDescriptor
- SplatStore_Wave_F32/I32: FillMatrix + MatrixStoreToDescriptor

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 20, 2026

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Contributor

@alsepkow alsepkow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding some comments

Comment on lines +565 to +570
if (!Device) {
hlsl_test::LogCommentFmt(
L"Shader compiled OK; skipping execution (no SM 6.10 device)");
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped);
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!Device) {
hlsl_test::LogCommentFmt(
L"Shader compiled OK; skipping execution (no SM 6.10 device)");
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped);
return;
}

If we end up in here with no device something went wrong. We definitely don't want to skip. In the HLK this will effectively be a pass. Better to fail out when something tries to use it.

Generally, no skipping in HLK. And skipping in a TAEF test is usually reserved for "Does this system support my test? If not, skip"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want this test to fail when we run it outside of the HLK though, so we still need the skip in there. We could ifdef it for the HLK.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we should handle that before we ever enter the test case? That is, skip in test class setup.

}

std::vector<float> ExpectedFloats(NumElements, FillValue);
std::vector<int32_t> ExpectedInts(NumElements,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this cast could UB


auto Op =
createComputeOp(SplatStoreShader, "cs_6_10", "UAV(u0)", Args.c_str());
addUAVBuffer(Op.get(), "Output", BufferSize, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We may want to consider adding addUAVBuffer and others to HLSLExecTestUtils.
And there may be potential to update the ShaderOpTest.cpp code to use those helpers.

For this PR I think just putting these generic helpers in HLSLExecTestUtils would be a good first step. They're likely to be useful for future tests looking to follow the same patterns in these tests.

L"FailIfRequirementsNotMet is set.");
return false;
}
// No device — tests will compile shaders and skip execution.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// No device — tests will compile shaders and skip execution.

Comment on lines +384 to +394
// Try to create a device. In HLK mode, fail if unavailable.
// In dev mode, D3DDevice stays null and tests will compile shaders
// then skip GPU execution.
if (!D3D12SDK->createDevice(&D3DDevice, D3D_SHADER_MODEL_6_10,
/*SkipUnsupported=*/false)) {
if (FailIfRequirementsNotMet) {
hlsl_test::LogErrorFmt(
L"Device creation failed for SM 6.10, and "
L"FailIfRequirementsNotMet is set.");
return false;
}
Copy link
Contributor

@alsepkow alsepkow Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Try to create a device. In HLK mode, fail if unavailable.
// In dev mode, D3DDevice stays null and tests will compile shaders
// then skip GPU execution.
if (!D3D12SDK->createDevice(&D3DDevice, D3D_SHADER_MODEL_6_10,
/*SkipUnsupported=*/false)) {
if (FailIfRequirementsNotMet) {
hlsl_test::LogErrorFmt(
L"Device creation failed for SM 6.10, and "
L"FailIfRequirementsNotMet is set.");
return false;
}
bool FailIfRequirementsNotMet = false;
#ifdef _HLK_CONF
FailIfRequirementsNotMet = true;
#endif
WEX::TestExecution::RuntimeParameters::TryGetValue(
L"FailIfRequirementsNotMet", FailIfRequirementsNotMet);
const bool SkipUnsupported = !FailIfRequirementsNotMet;
if (!D3D12SDK->createDevice(&D3DDevice, D3D_SHADER_MODEL_6_10,
SkipUnsupported)) {
if (FailIfRequirementsNotMet)
hlsl_test::LogErrorFmt(
L"Device Creation failed, resulting in test failure, since "
L"FailIfRequirementsNotMet is set. The expectation is that this "
L"test will only be executed if something has previously "
L"determined that the system meets the requirements of this "
L"test.");
return false;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 392 of this should be SM 6_10, right?

Comment on lines +403 to +404
// Re-create device if it was lost. If we never had one, that's fine —
// tests compile shaders and skip GPU execution.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Re-create device if it was lost. If we never had one, that's fine —
// tests compile shaders and skip GPU execution.

// Verification helpers
// ===========================================================================

static bool verifyFloatBuffer(const void *Actual, const float *Expected,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might be a case of diminishing returns - the int one doesn't have a tolerance, and they use different format strings for logging them.

Comment on lines +384 to +394
// Try to create a device. In HLK mode, fail if unavailable.
// In dev mode, D3DDevice stays null and tests will compile shaders
// then skip GPU execution.
if (!D3D12SDK->createDevice(&D3DDevice, D3D_SHADER_MODEL_6_10,
/*SkipUnsupported=*/false)) {
if (FailIfRequirementsNotMet) {
hlsl_test::LogErrorFmt(
L"Device creation failed for SM 6.10, and "
L"FailIfRequirementsNotMet is set.");
return false;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 392 of this should be SM 6_10, right?

damyanp and others added 2 commits March 23, 2026 10:35
- Remove NOMINMAX block (not needed without std::min/max + windows.h)
- Remove 'Unlike older execution tests...' paragraph from file header
- Convert block comments to /// doc comment style
- Remove unhelpful 'Always initialize DXC compiler' comment
- Apply clang-format fixes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace custom ComponentType/MatrixUse/MatrixScope/MatrixLayout enums
  with hlsl::DXIL types from DxilConstants.h
- Add elemSize() helper to eliminate duplicated element size logic
  in strideBytes() and totalBytes()
- Make buildCompilerArgs take const MatrixParams& instead of individual params
- Use switch statements for CompType dispatch instead of if-else chains

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
int ES = elemSize(CompType);
if (Layout == LinalgMatrixLayout::RowMajor)
return N * ES;
else
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else after a return is unnecessary

damyanp and others added 2 commits March 23, 2026 14:51
- Update setupClass with SkipUnsupported variable and more informative
  error message following existing HLK test patterns
- Update setupMethod with robust device-loss detection and recreation
  that fails hard (VERIFY) since a working device existed previously
- Fix potential UB in runSplatStore by only constructing the expected
  int vector when CompType is I32 (avoids unconditional float-to-int cast)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
/// Return the byte size of a single element for the given component type.
static int elemSize(ComponentType CT) {
switch (CT) {
case ComponentType::F16:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about the 8-bit component types I8, U8, F8_E4M3 and F8_E5M2?

Comment on lines +303 to +311

VERIFY_SUCCEEDED(
DxcSupport.InitializeForDll(dxc::kDxCompilerLib, "DxcCreateInstance"));

D3D12SDK = D3D12SDKSelector();

WEX::TestExecution::RuntimeParameters::TryGetValue(L"VerboseLogging",
VerboseLogging);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - lots of empty lines ;)

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.

4 participants