Skip to content

Update LongVector Execution tests to now use XML #7393

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
5936fc1
Update long vec execution tests to use xml and some other general
alsepkow Apr 24, 2025
2e40ac4
Forgot clang format
alsepkow Apr 28, 2025
eb852de
revert submodule changes
alsepkow Apr 29, 2025
2f71657
Code review
alsepkow Apr 29, 2025
5bd9151
Clang-format
alsepkow Apr 29, 2025
ff48aec
const args
alsepkow Apr 29, 2025
f7eb133
WIP on trig. Accuracy issue and need some cleanup
alsepkow May 1, 2025
71b7359
Swapping
alsepkow May 2, 2025
19bef44
Remove doubles, not supported for trig functions
alsepkow May 3, 2025
35ec9db
Wip, swap to look at coop vec stuff
alsepkow May 13, 2025
09bc268
Trig tests passing
alsepkow May 14, 2025
dc97508
Bug fixes and remove mod float64 as it is not supported
alsepkow May 14, 2025
c8c3be8
A few bug fixes. Comparing 0 and -0
alsepkow May 14, 2025
6e173d7
Clang-format
alsepkow May 14, 2025
f26c904
LLVM ifdef include guards
alsepkow May 14, 2025
f7dedb4
A little code review. Const, fix the unneeded 0 comparison, new line
alsepkow May 19, 2025
3ded6e1
Update template arg names. Need a better name than OpTypeT though
alsepkow May 20, 2025
fecb370
More code review changes. Fix CompareHalfULP. Template arg names. Etc
alsepkow May 20, 2025
0391bc5
Clang-format
alsepkow May 20, 2025
8c1c366
Move RunShaderOp* functions to ShaderOpTest files
alsepkow May 21, 2025
f51c55c
Factor out TableParameterHandler
alsepkow May 21, 2025
0226b26
Forgot clang format, again again
alsepkow May 21, 2025
5201efc
Refactored all long vector tests into their own files. Still needs a …
alsepkow May 22, 2025
8cdaa29
Clang-format
alsepkow May 22, 2025
2087c2b
fix includes
alsepkow May 22, 2025
4ea7b55
Add a tpp
alsepkow May 22, 2025
c8f8965
naming
alsepkow May 22, 2025
053f774
Formatting
alsepkow May 22, 2025
f33f1b0
clean up comment
alsepkow May 22, 2025
18aa44d
Comment 2
alsepkow May 22, 2025
62253a7
Fix ComputeExpectedValues bugs I introduced during refactor
alsepkow May 22, 2025
d81fdd7
Keep formatter happy
alsepkow May 22, 2025
4b7fc28
Change comment
alsepkow May 22, 2025
b64ad0b
Code review. Update CompareHalfULP logic for nan values
alsepkow May 27, 2025
4b3924c
Fix bug in DoValuesMatch
alsepkow Jun 2, 2025
5fa09f6
restore latest-release.json, again
alsepkow Jun 3, 2025
574dbf0
Remove comments in LongVector::BinaryOpType enum
alsepkow Jun 4, 2025
972483b
Restore line endings in ShaderOpArithTable.xml
alsepkow Jun 4, 2025
b5fdc60
Some fix-up post re-base to resolve merge conflicts related to coop vec
alsepkow Jun 4, 2025
ac32ec2
Fix (revert) latest-release.json
alsepkow Jun 4, 2025
8413116
Restore submodule changes from bad merge resolution during rebase
alsepkow Jun 4, 2025
1326915
Fix for the 'redefinition' of D3D_SHADER_MODELS enum we do in the Exe…
alsepkow Jun 4, 2025
e892e95
I can never remember Clang Format. I think I need to update my workfl…
alsepkow Jun 4, 2025
6b20c7d
Clang format for latest-release.json
alsepkow Jun 4, 2025
e9d7c6f
A couple more fixes for D3D_SHADER_MODEL 'redefinitions'
alsepkow Jun 5, 2025
09ca907
restore latest-release.json
alsepkow Jun 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 48 additions & 5 deletions include/dxc/Test/HlslTestUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
///////////////////////////////////////////////////////////////////////////////

// *** THIS FILE CANNOT TAKE ANY LLVM DEPENDENCIES *** //
#ifndef HLSLTESTUTILS_H
#define HLSLTESTUTILS_H

#include <algorithm>
#include <atomic>
Expand Down Expand Up @@ -258,17 +260,29 @@ inline void LogErrorFmt(const wchar_t *fmt, ...) {
WEX::Logging::Log::Error(buf.data());
}

inline void LogErrorFmtThrow(const wchar_t *fmt, ...) {
inline void LogErrorFmtThrow(const char *fileName, int line, const wchar_t *fmt,
...) {
va_list args;
va_start(args, fmt);
std::wstring buf(vFormatToWString(fmt, args));
va_end(args);
WEX::Logging::Log::Error(buf.data());

std::wstringstream wss;
wss << L"Error in file: " << fileName << L" at line: " << line << L"\n"
<< buf.data() << L"\n"
<< buf;

WEX::Logging::Log::Error(wss.str().c_str());

// Throws an exception to abort the test.
VERIFY_FAIL(L"Test error");
}

// Macro to pass the file name and line number. Otherwise TAEF prints this file
// and line number.
#define LOG_ERROR_FMT_THROW(fmt, ...) \
hlsl_test::LogErrorFmtThrow(__FILE__, __LINE__, fmt, __VA_ARGS__)

inline std::wstring
GetPathToHlslDataFile(const wchar_t *relative,
LPCWSTR paramName = HLSLDATAFILEPARAM,
Expand Down Expand Up @@ -553,6 +567,19 @@ inline bool CompareDoubleULP(
return AbsoluteDiff <= (uint64_t)ULPTolerance;
}

inline bool CompareDoubleEpsilon(const double &Src, const double &Ref,
float Epsilon) {
if (Src == Ref) {
return true;
}
if (std::isnan(Src)) {
return std::isnan(Ref);
}
// For FTZ or Preserve mode, we should get the expected number within
// epsilon for any operations.
return fabs(Src - Ref) < Epsilon;
}

inline bool CompareFloatULP(
const float &fsrc, const float &fref, int ULPTolerance,
hlsl::DXIL::Float32DenormMode mode = hlsl::DXIL::Float32DenormMode::Any) {
Expand Down Expand Up @@ -604,12 +631,26 @@ inline bool CompareFloatRelativeEpsilon(

inline bool CompareHalfULP(const uint16_t &fsrc, const uint16_t &fref,
float ULPTolerance) {
// Treat +0 and -0 as equal
if ((fsrc & ~FLOAT16_BIT_SIGN) == 0 && (fref & ~FLOAT16_BIT_SIGN) == 0)
return true;
if (fsrc == fref)
return true;
if (isnanFloat16(fsrc))
return isnanFloat16(fref);

const bool nanRef = isnanFloat16(fref);
const bool nanSrc = isnanFloat16(fsrc);
if (nanRef || nanSrc)
return nanRef && nanSrc;

// Map to monotonic ordering for correct ULP diff
auto toOrdered = [](uint16_t h) -> int {
return (h & FLOAT16_BIT_SIGN) ? (~h & 0xFFFF) : (h | 0x8000);
};

// 16-bit floating point numbers must preserve denorms
int diff = fsrc - fref;
int i_fsrc = toOrdered(fsrc);
int i_fref = toOrdered(fref);
int diff = i_fsrc - i_fref;
unsigned int uDiff = diff < 0 ? -diff : diff;
return uDiff <= (unsigned int)ULPTolerance;
}
Expand Down Expand Up @@ -773,3 +814,5 @@ inline UINT GetByteSizeForFormat(DXGI_FORMAT value) {
}
}
#endif

#endif // HLSLTESTUTILS_H
4 changes: 4 additions & 0 deletions tools/clang/unittests/HLSLExec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
find_package(TAEF REQUIRED)
find_package(D3D12 REQUIRED) # Used for ExecutionTest.cpp.

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")

add_clang_library(ExecHLSLTests SHARED
ExecutionTest.cpp
ShaderOpTest.cpp
TableParameterHandler.cpp
LongVectors.cpp
ExecHLSLTests.rc
)

Expand Down
3 changes: 2 additions & 1 deletion tools/clang/unittests/HLSLExec/ExecHLSLTests.rc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <windows.h>

ShaderOpArithTable.xml DATASOURCE_XML "ShaderOpArithTable.xml"
ShaderOpArithTable.xml DATASOURCE_XML "ShaderOpArithTable.xml"
LongVectorOpTable.xml DATASOURCE_XML "LongVectorOpTable.xml"
Loading