Skip to content

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

Open
V-FEXrt wants to merge 12 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 12 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

}

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.

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>
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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are just the first pass of tests, not the final ones! Planning on adding a lot more detailed tests after getting the basic tests/test framework in

Comment on lines 385 to 390
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
#ifndef _HLK_CONF
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;
}
#endif

NumElements, Verbose));
break;
default:
DXASSERT(false, "Saw unsupported component type");
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: It would be convenient to instead use a TAEF macro here. Then you'll see a more informative runtime failure if you hit this condition while developing. With the assert it will just crash, and you'll probably need to run under a debugger to figure out what's crashing. Just what I prefer.

VERIFY_IS_TRUE(false, "Saw unsupported comoponent type");

Comment on lines +501 to +506
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;
}
#ifndef _HLK_CONF
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;
}
#endif

Copy link
Contributor

Choose a reason for hiding this comment

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

We'll still want this change so this logic isn't included in an HLK build.


/// Compiles an HLSL shader using the DXC API to verify it is well-formed.
/// This runs without a D3D12 device, so it works even when no SM 6.10
/// hardware is available. Fails the test (via VERIFY) on compile error.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: The note that this runs without a D3D12 device is weird. It wouldn't ever need a device, right?
We could instead move that comment to the calling location as a note if we wanted.

I also suspect that we're going to eventually remove that logic anyways as its only really helpful during development. So maybe we don't need the comment?

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.

5 participants