Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
2 changes: 2 additions & 0 deletions include/Support/Pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ struct Buffer {
int Channels;
int Stride;
std::unique_ptr<char[]> Data;
std::unique_ptr<llvm::yaml::Hex64> HexData;
size_t Size;
size_t HexSize;
OutputProperties OutputProps;
uint32_t Counter;

Expand Down
10 changes: 9 additions & 1 deletion lib/Support/Check.cpp
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Do we want to add a test case of the correct error message output?

We could use FileCheck to ensure the hex values or whatnot are being formatted as expected

Original file line number Diff line number Diff line change
Expand Up @@ -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;

Choose a reason for hiding this comment

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

Minor nit: Would it make sense to move the declarations of Str and OS to the beginning of this function and get rid of TestRuleStr and TestRuleOStr? Would probably want to increase the size of the llvm::SmallString in that case.

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";
Expand Down
13 changes: 13 additions & 0 deletions lib/Support/Pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ void MappingTraits<offloadtest::DescriptorSet>::mapping(
I.mapRequired("Resources", D.Resources);
}

template <typename T> 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));
return Raw;
}

void MappingTraits<offloadtest::Buffer>::mapping(IO &I,
offloadtest::Buffer &B) {
I.mapRequired("Name", B.Name);
Expand All @@ -108,7 +115,13 @@ void MappingTraits<offloadtest::Buffer>::mapping(IO &I,
if (I.outputting()) { \
llvm::MutableArrayRef<Type> Arr(reinterpret_cast<Type *>(B.Data.get()), \
B.Size / sizeof(Type)); \
std::vector<llvm::yaml::Hex64> HexVec; \
HexVec.reserve(Arr.size()); \
for (const auto &val : Arr) \
HexVec.emplace_back(bitPatternAsHex64(val)); \
llvm::MutableArrayRef<llvm::yaml::Hex64> HexArr(HexVec); \
I.mapRequired("Data", Arr); \
I.mapRequired("HexData", HexArr); \
} else { \
int64_t ZeroInitSize; \
I.mapOptional("ZeroInitSize", ZeroInitSize, 0); \
Expand Down