]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Test: cgal/cgal_mesh_criteria: disable floating point exceptions 16858/head
authorMatthias Maier <tamiko@43-1.org>
Fri, 5 Apr 2024 19:57:13 +0000 (14:57 -0500)
committerMatthias Maier <tamiko@43-1.org>
Sat, 6 Apr 2024 02:47:27 +0000 (21:47 -0500)
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

index 3ecde4ba7e6b509b3c14b50317a8efc9248b23b0..f150f591b595d46e0898366a548b0930e8482190 100644 (file)
@@ -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();
 }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.