Skip to content

[CoopVec] Add pixel shader and multi-layer support to Mul and OuterProduct tests #7437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

jholewinski-nv
Copy link

@jholewinski-nv jholewinski-nv commented May 7, 2025

This change adds preliminary pixel shader support by wrapping the existing test code in a function, which is called by both compute and pixel shaders. The same test patterns are used for both, mapping threads to input/bias vectors and output buffer offsets. For pixel shaders, an atomic counter is used to implement a poor man's mapping of pixel shader threads to a range of thread IDs.

Multi-layer support is also added, currently limited to two layers. A square matrix is always used for the first layer in a multi-layer config for ease-of-implementation.

The input patterns are now slightly more interesting by generating random input with a generator seeded to a constant value. The range of values is limited to try to lower error that accumulates between the CoopVec GPU implementation and the CPU reference implementation.

@damyanp damyanp moved this to Active in HLSL Support May 7, 2025
@jholewinski-nv jholewinski-nv force-pushed the dev/jholewinski/coopvec-exectests-ps branch from 3c95c62 to d12ed52 Compare May 8, 2025 11:30
@jholewinski-nv jholewinski-nv force-pushed the dev/jholewinski/coopvec-exectests-ps branch from 041328e to e70a45f Compare May 9, 2025 19:47
Copy link
Contributor

github-actions bot commented May 12, 2025

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

@alsepkow
Copy link
Contributor

return L"<UNKNOWN>";

For test code I think its better to fail out at this point.

default:
VERIFY_FAIL(WEX::Common::String().Format(L"Unrecognized D3D12_LINEAR_ALGEBRA_DATATYPE: %d", DataType));
return L""


Refers to: tools/clang/unittests/HLSLExec/CoopVec.h:176 in f77d76f. [](commit_id = f77d76f, deletion_comment = False)

@alsepkow
Copy link
Contributor

WEX::Logging::Log::Error(L"Unsupported bias type");

Probably better to use VERIFY_FAIL to stop test execution at this point? I'm assuming its not valuable to continue running further. Log::Error will continue execution of the test case, but mark the test as failed.

Or was that the intention?


Refers to: tools/clang/unittests/HLSLExec/CoopVec.h:139 in f77d76f. [](commit_id = f77d76f, deletion_comment = False)

@alsepkow
Copy link
Contributor

alsepkow commented May 13, 2025

  WEX::Logging::Log::Error(L"Unsupported input type");

Should this abort the test by using a VERIFY_* macro?
Or do you want execution to continue?

Same pattern in some of these other helpers as well.


Refers to: tools/clang/unittests/HLSLExec/CoopVec.h:82 in f77d76f. [](commit_id = f77d76f, deletion_comment = False)

@alsepkow
Copy link
Contributor

alsepkow commented May 13, 2025

WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped);

Similar comment here as above. Make this a failure when _HLK_CONF is defined. Otherwise skip is ok.


Refers to: tools/clang/unittests/HLSLExec/ExecutionTest.cpp:12022 in f77d76f. [](commit_id = f77d76f, deletion_comment = False)

@alsepkow
Copy link
Contributor

alsepkow commented May 13, 2025

struct LinAlgHeaderIncludeHandler : public IDxcIncludeHandler {

this should be a class
#Resolved


Refers to: tools/clang/unittests/HLSLExec/CoopVec.h:16 in f77d76f. [](commit_id = f77d76f, deletion_comment = False)

float Elt = 0.0f;

if (IsIntegralDataType(MatrixInterpretation))
Elt = static_cast<float>(Rnd() & 0x7) - 3.0f;
Copy link
Contributor

@alsepkow alsepkow May 13, 2025

Choose a reason for hiding this comment

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

3.0f

nit: Magic numbers. What is the significance of 3.0f and the other literals in this function? Would they make more sense as named constants or are they arbitrary?

Copy link
Author

Choose a reason for hiding this comment

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

They're for getting a specific range of random numbers. I added comments.

T *Vec = getVector<T>(I);
for (size_t J = 0; J < VectorSize; ++J)
if constexpr (std::is_same_v<T, DirectX::PackedVector::HALF>) {
float Elt = (static_cast<float>(Rnd() & 0x3) - 1.0f) / 2.0f;
Copy link
Contributor

Choose a reason for hiding this comment

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

2.0f

nit: Magic numbers.

Copy link
Author

Choose a reason for hiding this comment

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

Added comment.


if (MatrixLayout == D3D12_LINEAR_ALGEBRA_MATRIX_LAYOUT_ROW_MAJOR) {
ConvertInfo.DestInfo.DestStride =
(static_cast<UINT>(getVectorSize()) * DestEltSize + 15) & ~15;
Copy link
Contributor

Choose a reason for hiding this comment

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

15

nit: magic numbers

Copy link
Author

Choose a reason for hiding this comment

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

This is for alignment. Added comments.

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.

LGTM

@damyanp damyanp merged commit 30f4740 into microsoft:staging-sm6.9 May 13, 2025
12 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in HLSL Roadmap May 13, 2025
@github-project-automation github-project-automation bot moved this from Active to Closed in HLSL Support May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants