Skip to content

Try for IEEE754-precise poly2tri triangulation results - #4500

Open
roystgnr wants to merge 22 commits into
libMesh:develfrom
roystgnr:non_associative_poly2tri
Open

Try for IEEE754-precise poly2tri triangulation results#4500
roystgnr wants to merge 22 commits into
libMesh:develfrom
roystgnr:non_associative_poly2tri

Conversation

@roystgnr

Copy link
Copy Markdown
Member

@loganharbour is experimenting with adding CXXFLAGS for Haswell architecture compiler optimizations, and the fused-multiply-add instructions there are (via rounding differently) changing MOOSE XYDelaunay outputs. Compiling the whole thing with -ffp-contract=off fixes the problem, but we do want to allow fused-multiply-add in most of our code, so let's see if we can just disable non-IEEE754-compliant optimizations selectively.

Leaving this marked as draft until Logan can verify that it works for him.

@moosebuild

moosebuild commented Jul 21, 2026

Copy link
Copy Markdown

Job Coverage, step Generate coverage on 0648c87 wanted to post the following:

Coverage

Inconsistent report tags were found between the head and base reports.
This can happen when reports are missing from either the head or the base.

Inconsistent tags:
32bit-np2_threads2
Full coverage report

This comment will be updated on new commits.

@roystgnr

Copy link
Copy Markdown
Member Author

It turns out that this is insufficient, and even compiling all of src/mesh and src/numerics with safer FP arithmetic is insufficient, but if I also build all of src/geom with -ffp-contract=off then I finally get reproduceable triangulations in even unsafely-optimized MOOSE builds.

I'm not sure if I want to disable FMA optimizations for every single geometric calculation. I may have to make push/pop versions of those pragmas, and put them into enforce_ieee754.h and unenforce_ieee754.h or something, so I can start wrapping individual methods. Figuring out which individual methods need wrapping is going to take a while too.

@roystgnr

Copy link
Copy Markdown
Member Author

Still haven't had much time to play with this, but I at least checked that the rest of src/mesh and src/numerics were overkill; all we need is the stuff in this PR plus some subset of src/geom

roystgnr added 6 commits July 27, 2026 12:16
I've found a third spot that needs them and even my worst impulses can't
bring me to copy-and-paste *again*.
This is getting my downstream Poly2Tri triangulations reproduceable at
higher optimization settings
Weirdly, the same version of Eigen that gives me this warning for
-march=native builds doesn't give me this warning for default arch
builds.  I don't even want to know what they're doing under the hood
there.
@roystgnr
roystgnr marked this pull request as ready for review July 27, 2026 17:25
@roystgnr

Copy link
Copy Markdown
Member Author

-march=native on elem.C alone doesn't trigger failures downstream ... nor on face_tri*.C ... actually, I can trigger failures downstream with just FMA on face.C. It's the quasi-circumcenter calculation that's doing it. Should have been an obvious risk point, in hindsight.

@loganharbour is fixing us downstream to use tests that enforce the quality of generated triangulations without enforcing the exact mesh refinement pattern, so hopefully this will be redundant with that, but I think in general it's still an improvement for our meshes to be reproduceable, as well as to have a couple handy headers to enforce reproduceable FP arithmetic elsewhere if it's needed.

@roystgnr

Copy link
Copy Markdown
Member Author

This works with clang++ too, but I've still got nvc++ compatibility fixes to make before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants