[SM6.10][HLK] Add LinAlg execution test infrastructure with Load/Store/Splat tests#8285
[SM6.10][HLK] Add LinAlg execution test infrastructure with Load/Store/Splat tests#8285V-FEXrt wants to merge 12 commits intomicrosoft:mainfrom
Conversation
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>
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
| } | ||
|
|
||
| std::vector<float> ExpectedFloats(NumElements, FillValue); | ||
| std::vector<int32_t> ExpectedInts(NumElements, |
|
|
||
| auto Op = | ||
| createComputeOp(SplatStoreShader, "cs_6_10", "UAV(u0)", Args.c_str()); | ||
| addUAVBuffer(Op.get(), "Output", BufferSize, true); |
There was a problem hiding this comment.
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.
- 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>
- 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: |
There was a problem hiding this comment.
How about the 8-bit component types I8, U8, F8_E4M3 and F8_E5M2?
There was a problem hiding this comment.
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
| 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; | ||
| } |
There was a problem hiding this comment.
| #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"); |
There was a problem hiding this comment.
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");
| 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; | ||
| } |
There was a problem hiding this comment.
| 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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
Introduce
LinAlgTests.cppwith 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.cppfile.Tests will currently be skipped since no driver reports SM6.10 support
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com