mirror of
https://github.com/CNugteren/CLBlast.git
synced 2024-07-07 12:23:46 +02:00
Adjusted the correctness-test error margins
This commit is contained in:
parent
c93cd2fc2d
commit
7468e2ba9d
|
@ -280,21 +280,21 @@ bool TestSimilarity(const T val1, const T val2) {
|
||||||
const auto difference = std::fabs(val1 - val2);
|
const auto difference = std::fabs(val1 - val2);
|
||||||
|
|
||||||
// Set the allowed error margin for floating-point comparisons
|
// Set the allowed error margin for floating-point comparisons
|
||||||
constexpr auto kErrorMarginRelative = 1.0e-2;
|
constexpr auto kErrorMarginRelative = T{0.025};
|
||||||
constexpr auto kErrorMarginAbsolute = 1.0e-10;
|
constexpr auto kErrorMarginAbsolute = T{1.0e-6};
|
||||||
|
|
||||||
// Shortcut, handles infinities
|
// Shortcut, handles infinities
|
||||||
if (val1 == val2) {
|
if (val1 == val2) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// The values are zero or very small: the relative error is less meaningful
|
// The values are zero or very small: the relative error is less meaningful
|
||||||
else if (val1 == 0 || val2 == 0 || difference < static_cast<T>(kErrorMarginAbsolute)) {
|
else if (val1 == 0 || val2 == 0 || difference < kErrorMarginAbsolute) {
|
||||||
return (difference < static_cast<T>(kErrorMarginAbsolute));
|
return (difference < kErrorMarginAbsolute);
|
||||||
}
|
}
|
||||||
// Use relative error
|
// Use relative error
|
||||||
else {
|
else {
|
||||||
const auto absolute_sum = std::fabs(val1) + std::fabs(val2);
|
const auto absolute_sum = std::fabs(val1) + std::fabs(val2);
|
||||||
return (difference / absolute_sum) < static_cast<T>(kErrorMarginRelative);
|
return (difference / absolute_sum) < kErrorMarginRelative;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue