From 377b23e009792094e805eef477b0a0a412a17678 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Fri, 5 Apr 2024 14:57:13 -0500 Subject: [PATCH] Test: cgal/cgal_mesh_criteria: disable floating point exceptions We trigger a (deliberate) floating point exception in the CGAL (header) library: ``` // The multiplications could produce some NaN, with 0 * inf. Replacing it with inf is safe. // min(x,y) (the order is essential) returns its second argument when the first is NaN. // An IEEE 754-2019 maximum could help. __m128d big = IA::largest().simd(); -> __m128d x1 = _mm_mul_pd(aa,bz); // {-ai*bi,as*bs} //x1 = _mm_min_pd(x1,big); // no NaN __m128d x2 = _mm_mul_pd(aa,c); // {-ai*bs,as*bi} x2 = _mm_min_pd(x2,big); // no NaN __m128d x3 = _mm_mul_pd(ap,bz); // {-as*bi,ai*bs} //x3 = _mm_min_pd(x3,big); // no NaN __m128d x4 = _mm_mul_pd(ap,c); // {-as*bs,ai*bi} x4 = _mm_min_pd(x4,big); // no NaN ``` Thus, disable floating point exceptions for the test. --- tests/cgal/cgal_mesh_criteria.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/cgal/cgal_mesh_criteria.cc b/tests/cgal/cgal_mesh_criteria.cc index 3ecde4ba7e..f150f591b5 100644 --- a/tests/cgal/cgal_mesh_criteria.cc +++ b/tests/cgal/cgal_mesh_criteria.cc @@ -65,6 +65,13 @@ test() int main() { + // CGAL uses hand-optimized AVX instructions for certain performance + // critical operations that can create (temporary) signalling NaNs and + // trigger a spurious floating point exception. Thus disable FE_INVALID: +#if defined(DEBUG) && defined(DEAL_II_HAVE_FP_EXCEPTIONS) + fedisableexcept(FE_INVALID); +#endif + initlog(); test(); } -- 2.39.5