From 796dd2ec2045a9dd9edc8ce47508d955b90feadf Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Thu, 17 Jul 2025 15:36:29 -0700 Subject: [PATCH 01/19] add comparison rule, tolerance if applicable, and hex64 view to test failure text output --- include/Support/Pipeline.h | 2 ++ lib/Support/Check.cpp | 10 +++++++++- lib/Support/Pipeline.cpp | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/Support/Pipeline.h b/include/Support/Pipeline.h index d7d3d8b9..05b5ff9c 100644 --- a/include/Support/Pipeline.h +++ b/include/Support/Pipeline.h @@ -77,7 +77,9 @@ struct Buffer { int Channels; int Stride; std::unique_ptr Data; + std::unique_ptr HexData; size_t Size; + size_t HexSize; OutputProperties OutputProps; uint32_t Counter; diff --git a/lib/Support/Check.cpp b/lib/Support/Check.cpp index 058dbc30..6cd75c69 100644 --- a/lib/Support/Check.cpp +++ b/lib/Support/Check.cpp @@ -268,26 +268,34 @@ static bool testBufferFloatULP(offloadtest::Buffer *B1, offloadtest::Buffer *B2, } llvm::Error verifyResult(offloadtest::Result R) { + llvm::SmallString<256> TestRuleStr; + llvm::raw_svector_ostream TestRuleOStr(TestRuleStr); switch (R.ComparisonRule) { case offloadtest::Rule::BufferExact: { if (testBufferExact(R.ActualPtr, R.ExpectedPtr)) return llvm::Error::success(); + TestRuleOStr << "Comparison Rule: BufferExact\n"; break; } case offloadtest::Rule::BufferFloatULP: { if (testBufferFloatULP(R.ActualPtr, R.ExpectedPtr, R.ULPT, R.DM)) return llvm::Error::success(); + TestRuleOStr << "Comparison Rule: BufferFloatULP\nULP: " << R.ULPT << "\n"; break; } case offloadtest::Rule::BufferFloatEpsilon: { if (testBufferFloatEpsilon(R.ActualPtr, R.ExpectedPtr, R.Epsilon, R.DM)) return llvm::Error::success(); + TestRuleOStr << "Comparison Rule: BufferFloatEpsilon\nEpsilon: " + << R.Epsilon << "\n"; break; } } llvm::SmallString<256> Str; llvm::raw_svector_ostream OS(Str); - OS << "Test failed: " << R.Name << "\nExpected:\n"; + OS << "Test failed: " << R.Name << "\n"; + OS << TestRuleStr; + OS << "Expected:\n"; llvm::yaml::Output YAMLOS(OS); YAMLOS << *R.ExpectedPtr; OS << "Got:\n"; diff --git a/lib/Support/Pipeline.cpp b/lib/Support/Pipeline.cpp index 2baca300..8e2828a6 100644 --- a/lib/Support/Pipeline.cpp +++ b/lib/Support/Pipeline.cpp @@ -108,7 +108,13 @@ void MappingTraits::mapping(IO &I, if (I.outputting()) { \ llvm::MutableArrayRef Arr(reinterpret_cast(B.Data.get()), \ B.Size / sizeof(Type)); \ + std::vector HexVec; \ + HexVec.reserve(Arr.size()); \ + for (const auto &val : Arr) \ + HexVec.emplace_back(static_cast(val)); \ + llvm::MutableArrayRef HexArr(HexVec); \ I.mapRequired("Data", Arr); \ + I.mapRequired("HexData", HexArr); \ } else { \ int64_t ZeroInitSize; \ I.mapOptional("ZeroInitSize", ZeroInitSize, 0); \ From d2f03d125cdbb460b06ad2efc1752fc88e57e0ac Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Thu, 17 Jul 2025 17:13:49 -0700 Subject: [PATCH 02/19] make sure hex representation is correct --- lib/Support/Pipeline.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Support/Pipeline.cpp b/lib/Support/Pipeline.cpp index 8e2828a6..69be6eee 100644 --- a/lib/Support/Pipeline.cpp +++ b/lib/Support/Pipeline.cpp @@ -93,6 +93,13 @@ void MappingTraits::mapping( I.mapRequired("Resources", D.Resources); } +template uint64_t bitPatternAsHex64(const T &val) { + static_assert(sizeof(T) <= sizeof(uint64_t), "Type too large for Hex64"); + uint64_t raw = 0; + memcpy(&raw, &val, sizeof(T)); + return raw; +} + void MappingTraits::mapping(IO &I, offloadtest::Buffer &B) { I.mapRequired("Name", B.Name); @@ -111,7 +118,7 @@ void MappingTraits::mapping(IO &I, std::vector HexVec; \ HexVec.reserve(Arr.size()); \ for (const auto &val : Arr) \ - HexVec.emplace_back(static_cast(val)); \ + HexVec.emplace_back(bitPatternAsHex64(val)); \ llvm::MutableArrayRef HexArr(HexVec); \ I.mapRequired("Data", Arr); \ I.mapRequired("HexData", HexArr); \ From 1dccd9cbac571441a8c37a1fcc75c2f834dd7d6d Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Thu, 17 Jul 2025 22:25:24 -0700 Subject: [PATCH 03/19] address build errors --- lib/Support/Pipeline.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Support/Pipeline.cpp b/lib/Support/Pipeline.cpp index 69be6eee..8ffe1382 100644 --- a/lib/Support/Pipeline.cpp +++ b/lib/Support/Pipeline.cpp @@ -93,11 +93,11 @@ void MappingTraits::mapping( I.mapRequired("Resources", D.Resources); } -template uint64_t bitPatternAsHex64(const T &val) { +static template uint64_t bitPatternAsHex64(const T &Val) { static_assert(sizeof(T) <= sizeof(uint64_t), "Type too large for Hex64"); - uint64_t raw = 0; - memcpy(&raw, &val, sizeof(T)); - return raw; + uint64_t Raw = 0; + memcpy(&Raw, &Val, sizeof(T)); + return Raw; } void MappingTraits::mapping(IO &I, From 21c5b1e686b7f707d702ddf11801dfe2f75ef6db Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Fri, 18 Jul 2025 10:04:29 -0700 Subject: [PATCH 04/19] fix typo --- lib/Support/Pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Support/Pipeline.cpp b/lib/Support/Pipeline.cpp index 8ffe1382..0820ca2b 100644 --- a/lib/Support/Pipeline.cpp +++ b/lib/Support/Pipeline.cpp @@ -93,7 +93,7 @@ void MappingTraits::mapping( I.mapRequired("Resources", D.Resources); } -static template uint64_t bitPatternAsHex64(const T &Val) { +template static uint64_t bitPatternAsHex64(const T &Val) { static_assert(sizeof(T) <= sizeof(uint64_t), "Type too large for Hex64"); uint64_t Raw = 0; memcpy(&Raw, &Val, sizeof(T)); From 78467e72fe885d0c222a4c8f88ae884ee4a010aa Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Mon, 21 Jul 2025 13:56:51 -0700 Subject: [PATCH 05/19] print as strings, use standard hex float format for C++ --- lib/Support/Pipeline.cpp | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/lib/Support/Pipeline.cpp b/lib/Support/Pipeline.cpp index 0820ca2b..608e2fc1 100644 --- a/lib/Support/Pipeline.cpp +++ b/lib/Support/Pipeline.cpp @@ -10,6 +10,8 @@ //===----------------------------------------------------------------------===// #include "Support/Pipeline.h" +#include // for std::hexfloat +#include using namespace offloadtest; @@ -93,11 +95,28 @@ void MappingTraits::mapping( I.mapRequired("Resources", D.Resources); } -template static uint64_t bitPatternAsHex64(const T &Val) { +// override yaml printer so that hex strings aren't printed like scalars, +// but are printed inline as if they were elements of a vector +template <> +struct SequenceTraits> { + static size_t size(IO &io, llvm::MutableArrayRef &seq) { + return seq.size(); + } + + static std::string &element(IO &io, llvm::MutableArrayRef &seq, size_t index) { + return seq[index]; + } + + static const bool flow = true; +}; + +template +static std::string bitPatternAsHex64(const T &Val) { static_assert(sizeof(T) <= sizeof(uint64_t), "Type too large for Hex64"); - uint64_t Raw = 0; - memcpy(&Raw, &Val, sizeof(T)); - return Raw; + + std::ostringstream Oss; + Oss << std::hexfloat << Val; + return Oss.str(); } void MappingTraits::mapping(IO &I, @@ -115,11 +134,11 @@ void MappingTraits::mapping(IO &I, if (I.outputting()) { \ llvm::MutableArrayRef Arr(reinterpret_cast(B.Data.get()), \ B.Size / sizeof(Type)); \ - std::vector HexVec; \ + std::vector HexVec; \ HexVec.reserve(Arr.size()); \ for (const auto &val : Arr) \ HexVec.emplace_back(bitPatternAsHex64(val)); \ - llvm::MutableArrayRef HexArr(HexVec); \ + llvm::MutableArrayRef HexArr(HexVec); \ I.mapRequired("Data", Arr); \ I.mapRequired("HexData", HexArr); \ } else { \ From d9ee686fa1ef566c6319f110c22106daaabdca7a Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Mon, 21 Jul 2025 14:17:59 -0700 Subject: [PATCH 06/19] try applying clangformat --- include/Support/Pipeline.h | 2 +- lib/Support/Pipeline.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Support/Pipeline.h b/include/Support/Pipeline.h index 05b5ff9c..af1e5a03 100644 --- a/include/Support/Pipeline.h +++ b/include/Support/Pipeline.h @@ -77,7 +77,7 @@ struct Buffer { int Channels; int Stride; std::unique_ptr Data; - std::unique_ptr HexData; + std::unique_ptr HexData; size_t Size; size_t HexSize; OutputProperties OutputProps; diff --git a/lib/Support/Pipeline.cpp b/lib/Support/Pipeline.cpp index 608e2fc1..15b7d8ea 100644 --- a/lib/Support/Pipeline.cpp +++ b/lib/Support/Pipeline.cpp @@ -95,7 +95,7 @@ void MappingTraits::mapping( I.mapRequired("Resources", D.Resources); } -// override yaml printer so that hex strings aren't printed like scalars, +// Override yaml printer so that hex strings aren't printed like scalars, // but are printed inline as if they were elements of a vector template <> struct SequenceTraits> { From db2f5eac3daffa59dac25e06184dde5b0ecb4fa5 Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Mon, 21 Jul 2025 14:21:31 -0700 Subject: [PATCH 07/19] clang format --- lib/Support/Pipeline.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/Support/Pipeline.cpp b/lib/Support/Pipeline.cpp index 15b7d8ea..87209a5b 100644 --- a/lib/Support/Pipeline.cpp +++ b/lib/Support/Pipeline.cpp @@ -97,21 +97,20 @@ void MappingTraits::mapping( // Override yaml printer so that hex strings aren't printed like scalars, // but are printed inline as if they were elements of a vector -template <> -struct SequenceTraits> { +template <> struct SequenceTraits> { static size_t size(IO &io, llvm::MutableArrayRef &seq) { return seq.size(); } - static std::string &element(IO &io, llvm::MutableArrayRef &seq, size_t index) { + static std::string &element(IO &io, llvm::MutableArrayRef &seq, + size_t index) { return seq[index]; } static const bool flow = true; }; -template -static std::string bitPatternAsHex64(const T &Val) { +template static std::string bitPatternAsHex64(const T &Val) { static_assert(sizeof(T) <= sizeof(uint64_t), "Type too large for Hex64"); std::ostringstream Oss; From cde6feed5b76cb34c92743f9ce4084eb5bf87ff4 Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Tue, 22 Jul 2025 10:10:26 -0700 Subject: [PATCH 08/19] add hex data text after the yaml --- include/Support/Pipeline.h | 2 -- lib/Support/Check.cpp | 55 ++++++++++++++++++++++++++++++++++++++ lib/Support/Pipeline.cpp | 31 --------------------- 3 files changed, 55 insertions(+), 33 deletions(-) diff --git a/include/Support/Pipeline.h b/include/Support/Pipeline.h index af1e5a03..d7d3d8b9 100644 --- a/include/Support/Pipeline.h +++ b/include/Support/Pipeline.h @@ -77,9 +77,7 @@ struct Buffer { int Channels; int Stride; std::unique_ptr Data; - std::unique_ptr HexData; size_t Size; - size_t HexSize; OutputProperties OutputProps; uint32_t Counter; diff --git a/lib/Support/Check.cpp b/lib/Support/Check.cpp index 6cd75c69..8fd56dd2 100644 --- a/lib/Support/Check.cpp +++ b/lib/Support/Check.cpp @@ -14,7 +14,9 @@ #include "llvm/ADT/APInt.h" #include "llvm/Support/Error.h" #include "llvm/Support/raw_ostream.h" +#include "Support/Pipeline.h" #include +#include constexpr uint16_t Float16BitSign = 0x8000; constexpr uint16_t Float16BitExp = 0x7c00; @@ -267,6 +269,49 @@ static bool testBufferFloatULP(offloadtest::Buffer *B1, offloadtest::Buffer *B2, return false; } +template static std::string bitPatternAsHex64(const T &Val) { + static_assert(sizeof(T) <= sizeof(uint64_t), "Type too large for Hex64"); + + std::ostringstream Oss; + Oss << std::hexfloat << Val; + return Oss.str(); +} + +std::string getBufferStr(offloadtest::Buffer *B){ + std::string ret = ""; + switch (B->Format) { +#define DATA_CASE(Enum, Type) \ + case offloadtest::DataFormat::Enum: { \ + llvm::MutableArrayRef Arr(reinterpret_cast(B->Data.get()), \ + B->Size / sizeof(Type)); \ + if (Arr.size() == 0) \ + return ""; \ + else if (Arr.size() == 1) \ + return "[ " + bitPatternAsHex64(Arr[0]) + " ]"; \ + ret += " [ " + bitPatternAsHex64(Arr[0]); \ + for (unsigned int i = 1; i < Arr.size(); i++){ \ + ret += ", " + bitPatternAsHex64(Arr[i]); \ + } \ + break; \ + } + DATA_CASE(Hex8, llvm::yaml::Hex8) + DATA_CASE(Hex16, llvm::yaml::Hex16) + DATA_CASE(Hex32, llvm::yaml::Hex32) + DATA_CASE(Hex64, llvm::yaml::Hex64) + DATA_CASE(UInt16, uint16_t) + DATA_CASE(UInt32, uint32_t) + DATA_CASE(UInt64, uint64_t) + DATA_CASE(Int16, int16_t) + DATA_CASE(Int32, int32_t) + DATA_CASE(Int64, int64_t) + DATA_CASE(Float16, llvm::yaml::Hex16) + DATA_CASE(Float32, float) + DATA_CASE(Float64, double) + DATA_CASE(Bool, uint32_t) // Because sizeof(bool) is 1 but HLSL represents a bool using 4 bytes. + } + return ret; +} + llvm::Error verifyResult(offloadtest::Result R) { llvm::SmallString<256> TestRuleStr; llvm::raw_svector_ostream TestRuleOStr(TestRuleStr); @@ -300,5 +345,15 @@ llvm::Error verifyResult(offloadtest::Result R) { YAMLOS << *R.ExpectedPtr; OS << "Got:\n"; YAMLOS << *R.ActualPtr; + + // Now print exact hex64 representations of each element of the + // actual and expected buffers. + + std::string ExpectedBufferStr = getBufferStr(R.ExpectedPtr); + std::string ActualBufferStr = getBufferStr(R.ActualPtr); + + OS << "Full Hex 64bit representation of Expected Buffer Values:\n" << ExpectedBufferStr << "\n"; + OS << "Full Hex 64bit representation of Actual Buffer Values:\n" << ActualBufferStr << "\n"; + return llvm::createStringError(Str.c_str()); } diff --git a/lib/Support/Pipeline.cpp b/lib/Support/Pipeline.cpp index 87209a5b..2baca300 100644 --- a/lib/Support/Pipeline.cpp +++ b/lib/Support/Pipeline.cpp @@ -10,8 +10,6 @@ //===----------------------------------------------------------------------===// #include "Support/Pipeline.h" -#include // for std::hexfloat -#include using namespace offloadtest; @@ -95,29 +93,6 @@ void MappingTraits::mapping( I.mapRequired("Resources", D.Resources); } -// Override yaml printer so that hex strings aren't printed like scalars, -// but are printed inline as if they were elements of a vector -template <> struct SequenceTraits> { - static size_t size(IO &io, llvm::MutableArrayRef &seq) { - return seq.size(); - } - - static std::string &element(IO &io, llvm::MutableArrayRef &seq, - size_t index) { - return seq[index]; - } - - static const bool flow = true; -}; - -template static std::string bitPatternAsHex64(const T &Val) { - static_assert(sizeof(T) <= sizeof(uint64_t), "Type too large for Hex64"); - - std::ostringstream Oss; - Oss << std::hexfloat << Val; - return Oss.str(); -} - void MappingTraits::mapping(IO &I, offloadtest::Buffer &B) { I.mapRequired("Name", B.Name); @@ -133,13 +108,7 @@ void MappingTraits::mapping(IO &I, if (I.outputting()) { \ llvm::MutableArrayRef Arr(reinterpret_cast(B.Data.get()), \ B.Size / sizeof(Type)); \ - std::vector HexVec; \ - HexVec.reserve(Arr.size()); \ - for (const auto &val : Arr) \ - HexVec.emplace_back(bitPatternAsHex64(val)); \ - llvm::MutableArrayRef HexArr(HexVec); \ I.mapRequired("Data", Arr); \ - I.mapRequired("HexData", HexArr); \ } else { \ int64_t ZeroInitSize; \ I.mapOptional("ZeroInitSize", ZeroInitSize, 0); \ From f8fd606ad52a3cefd044e4c0b4d51432a0e82336 Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Tue, 22 Jul 2025 10:28:11 -0700 Subject: [PATCH 09/19] try clang-format --- lib/Support/Check.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/Support/Check.cpp b/lib/Support/Check.cpp index 8fd56dd2..35a90e4c 100644 --- a/lib/Support/Check.cpp +++ b/lib/Support/Check.cpp @@ -10,11 +10,11 @@ //===----------------------------------------------------------------------===// #include "Support/Check.h" +#include "Support/Pipeline.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APInt.h" #include "llvm/Support/Error.h" #include "llvm/Support/raw_ostream.h" -#include "Support/Pipeline.h" #include #include @@ -277,21 +277,20 @@ template static std::string bitPatternAsHex64(const T &Val) { return Oss.str(); } -std::string getBufferStr(offloadtest::Buffer *B){ +std::string getBufferStr(offloadtest::Buffer *B) { std::string ret = ""; switch (B->Format) { #define DATA_CASE(Enum, Type) \ case offloadtest::DataFormat::Enum: { \ - llvm::MutableArrayRef Arr(reinterpret_cast(B->Data.get()), \ - B->Size / sizeof(Type)); \ + llvm::MutableArrayRef Arr(reinterpret_cast(B->Data.get()), \ + B->Size / sizeof(Type)); \ if (Arr.size() == 0) \ return ""; \ else if (Arr.size() == 1) \ return "[ " + bitPatternAsHex64(Arr[0]) + " ]"; \ ret += " [ " + bitPatternAsHex64(Arr[0]); \ - for (unsigned int i = 1; i < Arr.size(); i++){ \ - ret += ", " + bitPatternAsHex64(Arr[i]); \ - } \ + for (unsigned int i = 1; i < Arr.size(); i++) \ + ret += ", " + bitPatternAsHex64(Arr[i]); \ break; \ } DATA_CASE(Hex8, llvm::yaml::Hex8) @@ -307,7 +306,8 @@ std::string getBufferStr(offloadtest::Buffer *B){ DATA_CASE(Float16, llvm::yaml::Hex16) DATA_CASE(Float32, float) DATA_CASE(Float64, double) - DATA_CASE(Bool, uint32_t) // Because sizeof(bool) is 1 but HLSL represents a bool using 4 bytes. + DATA_CASE(Bool, uint32_t) // Because sizeof(bool) is 1 but HLSL represents a + // bool using 4 bytes. } return ret; } @@ -352,8 +352,10 @@ llvm::Error verifyResult(offloadtest::Result R) { std::string ExpectedBufferStr = getBufferStr(R.ExpectedPtr); std::string ActualBufferStr = getBufferStr(R.ActualPtr); - OS << "Full Hex 64bit representation of Expected Buffer Values:\n" << ExpectedBufferStr << "\n"; - OS << "Full Hex 64bit representation of Actual Buffer Values:\n" << ActualBufferStr << "\n"; + OS << "Full Hex 64bit representation of Expected Buffer Values:\n" + << ExpectedBufferStr << "\n"; + OS << "Full Hex 64bit representation of Actual Buffer Values:\n" + << ActualBufferStr << "\n"; return llvm::createStringError(Str.c_str()); } From 7a7634a0063b80d11f468a1e313a833c290f3f33 Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Tue, 22 Jul 2025 11:02:09 -0700 Subject: [PATCH 10/19] address build errors --- lib/Support/Check.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Support/Check.cpp b/lib/Support/Check.cpp index 35a90e4c..769b3c36 100644 --- a/lib/Support/Check.cpp +++ b/lib/Support/Check.cpp @@ -277,16 +277,16 @@ template static std::string bitPatternAsHex64(const T &Val) { return Oss.str(); } -std::string getBufferStr(offloadtest::Buffer *B) { +static const std::string getBufferStr(offloadtest::Buffer *B) { std::string ret = ""; switch (B->Format) { #define DATA_CASE(Enum, Type) \ case offloadtest::DataFormat::Enum: { \ - llvm::MutableArrayRef Arr(reinterpret_cast(B->Data.get()), \ - B->Size / sizeof(Type)); \ + const llvm::MutableArrayRef Arr( \ + reinterpret_cast(B->Data.get()), B->Size / sizeof(Type)); \ if (Arr.size() == 0) \ return ""; \ - else if (Arr.size() == 1) \ + if (Arr.size() == 1) \ return "[ " + bitPatternAsHex64(Arr[0]) + " ]"; \ ret += " [ " + bitPatternAsHex64(Arr[0]); \ for (unsigned int i = 1; i < Arr.size(); i++) \ @@ -349,8 +349,8 @@ llvm::Error verifyResult(offloadtest::Result R) { // Now print exact hex64 representations of each element of the // actual and expected buffers. - std::string ExpectedBufferStr = getBufferStr(R.ExpectedPtr); - std::string ActualBufferStr = getBufferStr(R.ActualPtr); + const std::string ExpectedBufferStr = getBufferStr(R.ExpectedPtr); + const std::string ActualBufferStr = getBufferStr(R.ActualPtr); OS << "Full Hex 64bit representation of Expected Buffer Values:\n" << ExpectedBufferStr << "\n"; From edb7c3054e7f1a308ae3452b478cd80c96a76dbc Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Tue, 22 Jul 2025 16:18:41 -0700 Subject: [PATCH 11/19] use std::hex for exact tests --- lib/Support/Check.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/Support/Check.cpp b/lib/Support/Check.cpp index 769b3c36..6b643098 100644 --- a/lib/Support/Check.cpp +++ b/lib/Support/Check.cpp @@ -269,15 +269,21 @@ static bool testBufferFloatULP(offloadtest::Buffer *B1, offloadtest::Buffer *B2, return false; } -template static std::string bitPatternAsHex64(const T &Val) { +template +static std::string bitPatternAsHex64(const T &Val, + offloadtest::Rule ComparisonRule) { static_assert(sizeof(T) <= sizeof(uint64_t), "Type too large for Hex64"); std::ostringstream Oss; - Oss << std::hexfloat << Val; + if (ComparisonRule == offloadtest::Rule::BufferExact) + Oss << std::hex << Val; + else + Oss << std::hexfloat << Val; return Oss.str(); } -static const std::string getBufferStr(offloadtest::Buffer *B) { +static const std::string getBufferStr(offloadtest::Buffer *B, + offloadtest::Rule ComparisonRule) { std::string ret = ""; switch (B->Format) { #define DATA_CASE(Enum, Type) \ @@ -287,10 +293,10 @@ static const std::string getBufferStr(offloadtest::Buffer *B) { if (Arr.size() == 0) \ return ""; \ if (Arr.size() == 1) \ - return "[ " + bitPatternAsHex64(Arr[0]) + " ]"; \ - ret += " [ " + bitPatternAsHex64(Arr[0]); \ + return "[ " + bitPatternAsHex64(Arr[0], ComparisonRule) + " ]"; \ + ret += " [ " + bitPatternAsHex64(Arr[0], ComparisonRule); \ for (unsigned int i = 1; i < Arr.size(); i++) \ - ret += ", " + bitPatternAsHex64(Arr[i]); \ + ret += ", " + bitPatternAsHex64(Arr[i], ComparisonRule); \ break; \ } DATA_CASE(Hex8, llvm::yaml::Hex8) @@ -349,8 +355,10 @@ llvm::Error verifyResult(offloadtest::Result R) { // Now print exact hex64 representations of each element of the // actual and expected buffers. - const std::string ExpectedBufferStr = getBufferStr(R.ExpectedPtr); - const std::string ActualBufferStr = getBufferStr(R.ActualPtr); + const std::string ExpectedBufferStr = + getBufferStr(R.ExpectedPtr, R.ComparisonRule); + const std::string ActualBufferStr = + getBufferStr(R.ActualPtr, R.ComparisonRule); OS << "Full Hex 64bit representation of Expected Buffer Values:\n" << ExpectedBufferStr << "\n"; From bb0b3843bb4b5f9e3ef22478f35aa739e41401b9 Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Wed, 23 Jul 2025 11:39:57 -0700 Subject: [PATCH 12/19] address Alex --- lib/Support/Check.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/Support/Check.cpp b/lib/Support/Check.cpp index 6b643098..2ad8e9be 100644 --- a/lib/Support/Check.cpp +++ b/lib/Support/Check.cpp @@ -297,6 +297,7 @@ static const std::string getBufferStr(offloadtest::Buffer *B, ret += " [ " + bitPatternAsHex64(Arr[0], ComparisonRule); \ for (unsigned int i = 1; i < Arr.size(); i++) \ ret += ", " + bitPatternAsHex64(Arr[i], ComparisonRule); \ + ret += " ]"; \ break; \ } DATA_CASE(Hex8, llvm::yaml::Hex8) @@ -319,33 +320,31 @@ static const std::string getBufferStr(offloadtest::Buffer *B, } llvm::Error verifyResult(offloadtest::Result R) { - llvm::SmallString<256> TestRuleStr; - llvm::raw_svector_ostream TestRuleOStr(TestRuleStr); + llvm::SmallString<256> Str; + llvm::raw_svector_ostream OS(Str); + OS << "Test failed: " << R.Name << "\n"; + switch (R.ComparisonRule) { case offloadtest::Rule::BufferExact: { if (testBufferExact(R.ActualPtr, R.ExpectedPtr)) return llvm::Error::success(); - TestRuleOStr << "Comparison Rule: BufferExact\n"; + OS << "Comparison Rule: BufferExact\n"; break; } case offloadtest::Rule::BufferFloatULP: { if (testBufferFloatULP(R.ActualPtr, R.ExpectedPtr, R.ULPT, R.DM)) return llvm::Error::success(); - TestRuleOStr << "Comparison Rule: BufferFloatULP\nULP: " << R.ULPT << "\n"; + OS << "Comparison Rule: BufferFloatULP\nULP: " << R.ULPT << "\n"; break; } case offloadtest::Rule::BufferFloatEpsilon: { if (testBufferFloatEpsilon(R.ActualPtr, R.ExpectedPtr, R.Epsilon, R.DM)) return llvm::Error::success(); - TestRuleOStr << "Comparison Rule: BufferFloatEpsilon\nEpsilon: " - << R.Epsilon << "\n"; + OS << "Comparison Rule: BufferFloatEpsilon\nEpsilon: " << R.Epsilon << "\n"; break; } } - llvm::SmallString<256> Str; - llvm::raw_svector_ostream OS(Str); - OS << "Test failed: " << R.Name << "\n"; - OS << TestRuleStr; + OS << "Expected:\n"; llvm::yaml::Output YAMLOS(OS); YAMLOS << *R.ExpectedPtr; From 0d167ebcf091c31663319124e14f046814e38ea3 Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Thu, 24 Jul 2025 18:13:56 -0700 Subject: [PATCH 13/19] address Alex + Finn --- lib/Support/Check.cpp | 84 ++++++++++------- lib/Support/Pipeline.cpp | 91 +++++++++++-------- test/Tools/Offloader/BufferExact-error.test | 5 + .../Offloader/BufferFloat-error-64bit.test | 48 ++++++++++ 4 files changed, 158 insertions(+), 70 deletions(-) diff --git a/lib/Support/Check.cpp b/lib/Support/Check.cpp index 2ad8e9be..a853c566 100644 --- a/lib/Support/Check.cpp +++ b/lib/Support/Check.cpp @@ -282,41 +282,56 @@ static std::string bitPatternAsHex64(const T &Val, return Oss.str(); } +template +std::string formatBuffer(offloadtest::Buffer *B, offloadtest::Rule rule) { + llvm::MutableArrayRef arr(reinterpret_cast(B->Data.get()), + B->Size / sizeof(T)); + if (arr.empty()) + return ""; + + std::string result = "[ " + bitPatternAsHex64(arr[0], rule); + for (size_t i = 1; i < arr.size(); ++i) + result += ", " + bitPatternAsHex64(arr[i], rule); + result += " ]"; + return result; +} + static const std::string getBufferStr(offloadtest::Buffer *B, - offloadtest::Rule ComparisonRule) { - std::string ret = ""; + offloadtest::Rule rule) { + using DF = offloadtest::DataFormat; switch (B->Format) { -#define DATA_CASE(Enum, Type) \ - case offloadtest::DataFormat::Enum: { \ - const llvm::MutableArrayRef Arr( \ - reinterpret_cast(B->Data.get()), B->Size / sizeof(Type)); \ - if (Arr.size() == 0) \ - return ""; \ - if (Arr.size() == 1) \ - return "[ " + bitPatternAsHex64(Arr[0], ComparisonRule) + " ]"; \ - ret += " [ " + bitPatternAsHex64(Arr[0], ComparisonRule); \ - for (unsigned int i = 1; i < Arr.size(); i++) \ - ret += ", " + bitPatternAsHex64(Arr[i], ComparisonRule); \ - ret += " ]"; \ - break; \ + case DF::Hex8: + return formatBuffer(B, rule); + case DF::Hex16: + return formatBuffer(B, rule); + case DF::Hex32: + return formatBuffer(B, rule); + case DF::Hex64: + return formatBuffer(B, rule); + case DF::UInt16: + return formatBuffer(B, rule); + case DF::UInt32: + return formatBuffer(B, rule); + case DF::UInt64: + return formatBuffer(B, rule); + case DF::Int16: + return formatBuffer(B, rule); + case DF::Int32: + return formatBuffer(B, rule); + case DF::Int64: + return formatBuffer(B, rule); + case DF::Float16: + return formatBuffer(B, + rule); // assuming no native float16 + case DF::Float32: + return formatBuffer(B, rule); + case DF::Float64: + return formatBuffer(B, rule); + case DF::Bool: + return formatBuffer(B, + rule); // Because sizeof(bool) is 1 but HLSL + // represents a bool using 4 bytes. } - DATA_CASE(Hex8, llvm::yaml::Hex8) - DATA_CASE(Hex16, llvm::yaml::Hex16) - DATA_CASE(Hex32, llvm::yaml::Hex32) - DATA_CASE(Hex64, llvm::yaml::Hex64) - DATA_CASE(UInt16, uint16_t) - DATA_CASE(UInt32, uint32_t) - DATA_CASE(UInt64, uint64_t) - DATA_CASE(Int16, int16_t) - DATA_CASE(Int32, int32_t) - DATA_CASE(Int64, int64_t) - DATA_CASE(Float16, llvm::yaml::Hex16) - DATA_CASE(Float32, float) - DATA_CASE(Float64, double) - DATA_CASE(Bool, uint32_t) // Because sizeof(bool) is 1 but HLSL represents a - // bool using 4 bytes. - } - return ret; } llvm::Error verifyResult(offloadtest::Result R) { @@ -340,7 +355,10 @@ llvm::Error verifyResult(offloadtest::Result R) { case offloadtest::Rule::BufferFloatEpsilon: { if (testBufferFloatEpsilon(R.ActualPtr, R.ExpectedPtr, R.Epsilon, R.DM)) return llvm::Error::success(); - OS << "Comparison Rule: BufferFloatEpsilon\nEpsilon: " << R.Epsilon << "\n"; + + std::ostringstream Oss; + Oss << std::defaultfloat << R.Epsilon; + OS << "Comparison Rule: BufferFloatEpsilon\nEpsilon: " << Oss.str() << "\n"; break; } } diff --git a/lib/Support/Pipeline.cpp b/lib/Support/Pipeline.cpp index 2baca300..6af0ef74 100644 --- a/lib/Support/Pipeline.cpp +++ b/lib/Support/Pipeline.cpp @@ -93,6 +93,30 @@ void MappingTraits::mapping( I.mapRequired("Resources", D.Resources); } +template static void setData(IO &I, offloadtest::Buffer &B) { + if (I.outputting()) { + llvm::MutableArrayRef Arr(reinterpret_cast(B.Data.get()), + B.Size / sizeof(Type)); + I.mapRequired("Data", Arr); + } else { + int64_t ZeroInitSize; + I.mapOptional("ZeroInitSize", ZeroInitSize, 0); + if (ZeroInitSize > 0) { + B.Size = ZeroInitSize; + B.Data.reset(new char[B.Size]); + memset(B.Data.get(), 0, B.Size); + return; + } + llvm::SmallVector Arr; + I.mapRequired("Data", Arr); + B.Size = Arr.size() * sizeof(Type); + B.Data.reset(new char[B.Size]); + memcpy(B.Data.get(), Arr.data(), B.Size); + } + + I.mapOptional("OutputProps", B.OutputProps); +} + void MappingTraits::mapping(IO &I, offloadtest::Buffer &B) { I.mapRequired("Name", B.Name); @@ -102,44 +126,37 @@ void MappingTraits::mapping(IO &I, I.mapOptional("Counter", B.Counter, 0); if (!I.outputting() && B.Stride != 0 && B.Channels != 1) I.setError("Cannot set a structure stride and more than one channel."); + using DF = offloadtest::DataFormat; switch (B.Format) { -#define DATA_CASE(Enum, Type) \ - case DataFormat::Enum: { \ - if (I.outputting()) { \ - llvm::MutableArrayRef Arr(reinterpret_cast(B.Data.get()), \ - B.Size / sizeof(Type)); \ - I.mapRequired("Data", Arr); \ - } else { \ - int64_t ZeroInitSize; \ - I.mapOptional("ZeroInitSize", ZeroInitSize, 0); \ - if (ZeroInitSize > 0) { \ - B.Size = ZeroInitSize; \ - B.Data.reset(new char[B.Size]); \ - memset(B.Data.get(), 0, B.Size); \ - break; \ - } \ - llvm::SmallVector Arr; \ - I.mapRequired("Data", Arr); \ - B.Size = Arr.size() * sizeof(Type); \ - B.Data.reset(new char[B.Size]); \ - memcpy(B.Data.get(), Arr.data(), B.Size); \ - } \ - break; \ - } - DATA_CASE(Hex8, llvm::yaml::Hex8) - DATA_CASE(Hex16, llvm::yaml::Hex16) - DATA_CASE(Hex32, llvm::yaml::Hex32) - DATA_CASE(Hex64, llvm::yaml::Hex64) - DATA_CASE(UInt16, uint16_t) - DATA_CASE(UInt32, uint32_t) - DATA_CASE(UInt64, uint64_t) - DATA_CASE(Int16, int16_t) - DATA_CASE(Int32, int32_t) - DATA_CASE(Int64, int64_t) - DATA_CASE(Float16, llvm::yaml::Hex16) - DATA_CASE(Float32, float) - DATA_CASE(Float64, double) - DATA_CASE(Bool, uint32_t) // Because sizeof(bool) is 1 but HLSL represents a bool using 4 bytes. + case DF::Hex8: + return setData(I, B); + case DF::Hex16: + return setData(I, B); + case DF::Hex32: + return setData(I, B); + case DF::Hex64: + return setData(I, B); + case DF::UInt16: + return setData(I, B); + case DF::UInt32: + return setData(I, B); + case DF::UInt64: + return setData(I, B); + case DF::Int16: + return setData(I, B); + case DF::Int32: + return setData(I, B); + case DF::Int64: + return setData(I, B); + case DF::Float16: + return setData(I, B); // assuming no native float16 + case DF::Float32: + return setData(I, B); + case DF::Float64: + return setData(I, B); + case DF::Bool: + return setData(I, B); // Because sizeof(bool) is 1 but HLSL + // represents a bool using 4 bytes. } I.mapOptional("OutputProps", B.OutputProps); diff --git a/test/Tools/Offloader/BufferExact-error.test b/test/Tools/Offloader/BufferExact-error.test index fac4f8a0..cc5c5d46 100644 --- a/test/Tools/Offloader/BufferExact-error.test +++ b/test/Tools/Offloader/BufferExact-error.test @@ -48,6 +48,7 @@ DescriptorSets: # RUN: not %offloader %t/pipeline.yaml %t.o 2>&1 | FileCheck %s # CHECK: Test failed: Test1 +# CHECK: Comparison Rule: BufferExact # CHECK: Expected: # CHECK: --- # CHECK: Name: Expected1 @@ -69,3 +70,7 @@ DescriptorSets: # CHECK: Height: 0 # CHECK: Width: 0 # CHECK: Depth: 0 +# CHECK: Full Hex 64bit representation of Expected Buffer Values: +# CHECK: [ 1, 2, 3, 4 ] +# CHECK: Full Hex 64bit representation of Actual Buffer Values: +# CHECK: [ 14, 1e, 28, 32 ] diff --git a/test/Tools/Offloader/BufferFloat-error-64bit.test b/test/Tools/Offloader/BufferFloat-error-64bit.test index 6a66316f..98296f70 100644 --- a/test/Tools/Offloader/BufferFloat-error-64bit.test +++ b/test/Tools/Offloader/BufferFloat-error-64bit.test @@ -110,6 +110,8 @@ DescriptorSets: # RUN: not %offloader %t/pipeline.yaml %t.o 2>&1 | FileCheck %s # CHECK: Test failed: Test1 +# CHECK: Comparison Rule: BufferFloatULP +# CHECK: ULP: 1 # CHECK: Expected: # CHECK: --- # CHECK: Name: Expected1 @@ -131,8 +133,18 @@ DescriptorSets: # CHECK: Height: 0 # CHECK: Width: 0 # CHECK: Depth: 0 +# CHECK: ... +# CHECK-NEXT: Full Hex 64bit representation of Expected Buffer Values: +# CHECK-NEXT: [ 0x1.8000000000000p+0, 0x1.4000000000000p+1 ] +# CHECK-NEXT: Full Hex 64bit representation of Actual Buffer Values: +# CHECK-NEXT: [ 0x1.44cccc +# The rest is #ccccccdp+4, 0x1.4000000000000p+2 ], but some implementations +# the remaining hex64 data. So, we resume checking from p+4 +# CHECK: p+4, 0x1.4000000000000p+2 ] # CHECK: Test failed: Test2 +# CHECK: Comparison Rule: BufferFloatULP +# CHECK: ULP: 1 # CHECK: Expected: # CHECK: --- # CHECK: Name: Expected2 @@ -154,8 +166,15 @@ DescriptorSets: # CHECK: Height: 0 # CHECK: Width: 0 # CHECK: Depth: 0 +# CHECK: ... +# CHECK-NEXT: Full Hex 64bit representation of Expected Buffer Values: +# CHECK-NEXT: [ 0x0.fffffffffffffp-1022 ] +# CHECK-NEXT: Full Hex 64bit representation of Actual Buffer Values: +# CHECK-NEXT: [ 0x0.0000000000000p+0 ] # CHECK: Test failed: Test3 +# CHECK: Comparison Rule: BufferFloatULP +# CHECK: ULP: 0 # CHECK: Expected: # CHECK: --- # CHECK: Name: Expected3 @@ -177,8 +196,15 @@ DescriptorSets: # CHECK: Height: 0 # CHECK: Width: 0 # CHECK: Depth: 0 +# CHECK: ... +# CHECK-NEXT: Full Hex 64bit representation of Expected Buffer Values: +# CHECK-NEXT: [ 0x0.0000000000000p+0 ] +# CHECK-NEXT: Full Hex 64bit representation of Actual Buffer Values: +# CHECK-NEXT: [ nan ] # CHECK: Test failed: Test4 +# CHECK: Comparison Rule: BufferFloatEpsilon +# CHECK: Epsilon: 0.1 # CHECK: Expected: # CHECK: --- # CHECK: Name: Expected1 @@ -200,8 +226,18 @@ DescriptorSets: # CHECK: Height: 0 # CHECK: Width: 0 # CHECK: Depth: 0 +# CHECK: ... +# CHECK-NEXT: Full Hex 64bit representation of Expected Buffer Values: +# CHECK-NEXT: [ 0x1.8000000000000p+0, 0x1.4000000000000p+1 ] +# CHECK-NEXT: Full Hex 64bit representation of Actual Buffer Values: +# CHECK-NEXT: [ 0x1.44cccc +# The rest is #ccccccdp+4, 0x1.4000000000000p+2 ], but some implementations +# the remaining hex64 data. So, we resume checking from p+4 +# CHECK: p+4, 0x1.4000000000000p+2 ] # CHECK: Test failed: Test5 +# CHECK: Comparison Rule: BufferFloatEpsilon +# CHECK: Epsilon: 0 # CHECK: Expected: # CHECK: --- # CHECK: Name: Expected2 @@ -223,8 +259,15 @@ DescriptorSets: # CHECK: Height: 0 # CHECK: Width: 0 # CHECK: Depth: 0 +# CHECK: ... +# CHECK-NEXT: Full Hex 64bit representation of Expected Buffer Values: +# CHECK-NEXT: [ 0x0.fffffffffffffp-1022 ] +# CHECK-NEXT: Full Hex 64bit representation of Actual Buffer Values: +# CHECK-NEXT: [ 0x0.0000000000000p+0 ] # CHECK: Test failed: Test6 +# CHECK: Comparison Rule: BufferFloatEpsilon +# CHECK: Epsilon: 0 # CHECK: Expected: # CHECK: --- # CHECK: Name: Expected3 @@ -246,3 +289,8 @@ DescriptorSets: # CHECK: Height: 0 # CHECK: Width: 0 # CHECK: Depth: 0 +# CHECK: ... +# CHECK-NEXT: Full Hex 64bit representation of Expected Buffer Values: +# CHECK-NEXT: [ 0x0.0000000000000p+0 ] +# CHECK-NEXT: Full Hex 64bit representation of Actual Buffer Values: +# CHECK-NEXT: [ nan ] From 4bc8e299cf6afcdff79ffdc527d7063cadc5af55 Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Thu, 24 Jul 2025 18:22:02 -0700 Subject: [PATCH 14/19] fix missing output props bug --- lib/Support/Pipeline.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Support/Pipeline.cpp b/lib/Support/Pipeline.cpp index 6af0ef74..3cfa167f 100644 --- a/lib/Support/Pipeline.cpp +++ b/lib/Support/Pipeline.cpp @@ -105,6 +105,7 @@ template static void setData(IO &I, offloadtest::Buffer &B) { B.Size = ZeroInitSize; B.Data.reset(new char[B.Size]); memset(B.Data.get(), 0, B.Size); + I.mapOptional("OutputProps", B.OutputProps); return; } llvm::SmallVector Arr; From 72bd6d8f92d9748df4c71c017e9688770778ced6 Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Thu, 24 Jul 2025 18:57:14 -0700 Subject: [PATCH 15/19] use appropriate variable naming rules --- lib/Support/Check.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/Support/Check.cpp b/lib/Support/Check.cpp index a853c566..5c5a0b3b 100644 --- a/lib/Support/Check.cpp +++ b/lib/Support/Check.cpp @@ -297,39 +297,39 @@ std::string formatBuffer(offloadtest::Buffer *B, offloadtest::Rule rule) { } static const std::string getBufferStr(offloadtest::Buffer *B, - offloadtest::Rule rule) { + offloadtest::Rule Rule) { using DF = offloadtest::DataFormat; switch (B->Format) { case DF::Hex8: - return formatBuffer(B, rule); + return formatBuffer(B, Rule); case DF::Hex16: - return formatBuffer(B, rule); + return formatBuffer(B, Rule); case DF::Hex32: - return formatBuffer(B, rule); + return formatBuffer(B, Rule); case DF::Hex64: - return formatBuffer(B, rule); + return formatBuffer(B, Rule); case DF::UInt16: - return formatBuffer(B, rule); + return formatBuffer(B, Rule); case DF::UInt32: - return formatBuffer(B, rule); + return formatBuffer(B, Rule); case DF::UInt64: - return formatBuffer(B, rule); + return formatBuffer(B, Rule); case DF::Int16: - return formatBuffer(B, rule); + return formatBuffer(B, Rule); case DF::Int32: - return formatBuffer(B, rule); + return formatBuffer(B, Rule); case DF::Int64: - return formatBuffer(B, rule); + return formatBuffer(B, Rule); case DF::Float16: return formatBuffer(B, - rule); // assuming no native float16 + Rule); // assuming no native float16 case DF::Float32: - return formatBuffer(B, rule); + return formatBuffer(B, Rule); case DF::Float64: - return formatBuffer(B, rule); + return formatBuffer(B, Rule); case DF::Bool: return formatBuffer(B, - rule); // Because sizeof(bool) is 1 but HLSL + Rule); // Because sizeof(bool) is 1 but HLSL // represents a bool using 4 bytes. } } From 2a9c56bdd80b68522b7a46a9e44b035466fa2631 Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Thu, 24 Jul 2025 18:58:50 -0700 Subject: [PATCH 16/19] clarify comment --- test/Tools/Offloader/BufferFloat-error-64bit.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Tools/Offloader/BufferFloat-error-64bit.test b/test/Tools/Offloader/BufferFloat-error-64bit.test index 98296f70..5f7094ba 100644 --- a/test/Tools/Offloader/BufferFloat-error-64bit.test +++ b/test/Tools/Offloader/BufferFloat-error-64bit.test @@ -139,7 +139,7 @@ DescriptorSets: # CHECK-NEXT: Full Hex 64bit representation of Actual Buffer Values: # CHECK-NEXT: [ 0x1.44cccc # The rest is #ccccccdp+4, 0x1.4000000000000p+2 ], but some implementations -# the remaining hex64 data. So, we resume checking from p+4 +# have trailing 0's for the remaining hex64 data. So, we resume checking from p+4 # CHECK: p+4, 0x1.4000000000000p+2 ] # CHECK: Test failed: Test2 @@ -232,7 +232,7 @@ DescriptorSets: # CHECK-NEXT: Full Hex 64bit representation of Actual Buffer Values: # CHECK-NEXT: [ 0x1.44cccc # The rest is #ccccccdp+4, 0x1.4000000000000p+2 ], but some implementations -# the remaining hex64 data. So, we resume checking from p+4 +# have trailing 0's for the remaining hex64 data. So, we resume checking from p+4 # CHECK: p+4, 0x1.4000000000000p+2 ] # CHECK: Test failed: Test5 From 33d3eac5363b54d5d0d7d4d38bd3599c0a2fd94f Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Thu, 24 Jul 2025 19:20:13 -0700 Subject: [PATCH 17/19] more variable rule fixes --- lib/Support/Check.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Support/Check.cpp b/lib/Support/Check.cpp index 5c5a0b3b..3231d1ea 100644 --- a/lib/Support/Check.cpp +++ b/lib/Support/Check.cpp @@ -283,17 +283,17 @@ static std::string bitPatternAsHex64(const T &Val, } template -std::string formatBuffer(offloadtest::Buffer *B, offloadtest::Rule rule) { - llvm::MutableArrayRef arr(reinterpret_cast(B->Data.get()), +std::string formatBuffer(offloadtest::Buffer *B, offloadtest::Rule Rule) { + llvm::MutableArrayRef Arr(reinterpret_cast(B->Data.get()), B->Size / sizeof(T)); - if (arr.empty()) + if (Arr.empty()) return ""; - std::string result = "[ " + bitPatternAsHex64(arr[0], rule); - for (size_t i = 1; i < arr.size(); ++i) - result += ", " + bitPatternAsHex64(arr[i], rule); - result += " ]"; - return result; + std::string Result = "[ " + bitPatternAsHex64(Arr[0], Rule); + for (size_t I = 1; I < Arr.size(); ++I) + Result += ", " + bitPatternAsHex64(Arr[I], Rule); + Result += " ]"; + return Result; } static const std::string getBufferStr(offloadtest::Buffer *B, From 2517d5e88ac7c42a9de0b38f48faef689d055072 Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Thu, 24 Jul 2025 21:29:47 -0700 Subject: [PATCH 18/19] more build errors --- lib/Support/Check.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Support/Check.cpp b/lib/Support/Check.cpp index 3231d1ea..b4f433d7 100644 --- a/lib/Support/Check.cpp +++ b/lib/Support/Check.cpp @@ -283,9 +283,10 @@ static std::string bitPatternAsHex64(const T &Val, } template -std::string formatBuffer(offloadtest::Buffer *B, offloadtest::Rule Rule) { - llvm::MutableArrayRef Arr(reinterpret_cast(B->Data.get()), - B->Size / sizeof(T)); +static std::string formatBuffer(offloadtest::Buffer *B, + offloadtest::Rule Rule) { + const llvm::MutableArrayRef Arr(reinterpret_cast(B->Data.get()), + B->Size / sizeof(T)); if (Arr.empty()) return ""; From d2f8e25fe94a730d97d614d15b04ec87efdb1779 Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Fri, 25 Jul 2025 12:55:32 -0700 Subject: [PATCH 19/19] prefix hex values with 0x --- lib/Support/Check.cpp | 2 +- test/Tools/Offloader/BufferExact-error.test | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Support/Check.cpp b/lib/Support/Check.cpp index b4f433d7..ae47e207 100644 --- a/lib/Support/Check.cpp +++ b/lib/Support/Check.cpp @@ -276,7 +276,7 @@ static std::string bitPatternAsHex64(const T &Val, std::ostringstream Oss; if (ComparisonRule == offloadtest::Rule::BufferExact) - Oss << std::hex << Val; + Oss << "0x" << std::hex << Val; else Oss << std::hexfloat << Val; return Oss.str(); diff --git a/test/Tools/Offloader/BufferExact-error.test b/test/Tools/Offloader/BufferExact-error.test index cc5c5d46..306f8a76 100644 --- a/test/Tools/Offloader/BufferExact-error.test +++ b/test/Tools/Offloader/BufferExact-error.test @@ -71,6 +71,6 @@ DescriptorSets: # CHECK: Width: 0 # CHECK: Depth: 0 # CHECK: Full Hex 64bit representation of Expected Buffer Values: -# CHECK: [ 1, 2, 3, 4 ] +# CHECK: [ 0x1, 0x2, 0x3, 0x4 ] # CHECK: Full Hex 64bit representation of Actual Buffer Values: -# CHECK: [ 14, 1e, 28, 32 ] +# CHECK: [ 0x14, 0x1e, 0x28, 0x32 ]