summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorVincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com>2019-12-20 16:04:50 +0100
committerGitHub <noreply@github.com>2019-12-20 16:04:50 +0100
commit2842ab896b21e4577198216e814084cfd88d989c (patch)
tree99fb1073da4a589ecd5503e635f6370bafbba374 /src/common
parent0d3675360ce4c23d9fd4c7c157810c31ed06403b (diff)
parent291286815e282c9693f17615f8c46a49f87bf887 (diff)
Merge pull request #164 from VincentRouvreau/failed_tests_on_x86_fix
Fix #118 - protect some bottleneck tests
Diffstat (limited to 'src/common')
-rw-r--r--src/common/include/gudhi/Unitary_tests_utils.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/common/include/gudhi/Unitary_tests_utils.h b/src/common/include/gudhi/Unitary_tests_utils.h
index 7d039304..9b86460a 100644
--- a/src/common/include/gudhi/Unitary_tests_utils.h
+++ b/src/common/include/gudhi/Unitary_tests_utils.h
@@ -26,4 +26,15 @@ void GUDHI_TEST_FLOAT_EQUALITY_CHECK(FloatingType a, FloatingType b,
BOOST_CHECK(std::fabs(a - b) <= epsilon);
}
+// That's the usual x86 issue where a+b==a+b can return false (without any NaN) because one of them was stored in
+// memory (and thus rounded to 64 bits) while the other is still in a register (80 bits).
+template<typename FloatingType >
+FloatingType GUDHI_PROTECT_FLOAT(FloatingType value) {
+ volatile FloatingType protected_value = value;
+#ifdef DEBUG_TRACES
+ std::cout << "GUDHI_PROTECT_FLOAT - " << protected_value << std::endl;
+#endif
+ return protected_value;
+}
+
#endif // UNITARY_TESTS_UTILS_H_