-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvement backports from CDT_3 branch (Follow-up to PR #8170) #8273
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
#if CGAL_USE_BOOST_UNORDERED | ||
typedef boost::unordered_flat_map<Edge, Context_list*, boost::hash<Edge>> Sc_to_c_map; | ||
#else | ||
typedef std::unordered_map<Edge, Context_list*, boost::hash<Edge>> Sc_to_c_map; | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order of the sequence of values from the range CGAL::Constrained_triangulation_plus_2<Tr>::subconstraints()
- The patch 93fd966 makes the range
CGAL::Constrained_triangulation_plus_2<Tr>::subconstraints()
non-deterministic: instead of astd::map
with a customcompare
functor, now the sub-constraints are in an unordered map, for efficiency reasons. Note that the range was never documented as sorted or deterministic. - As my patch had broken a test from Mesh_2 (the test
test_meshing
), I had to fix that non-determinism. That was complicated to fix directly inConstrained_triangulation_plus_2
orConstrained_triangulation_plus_2
. Instead, I have chosen to fix the only place in CGAL where the order of that range mattered, inMesh_2/include/CGAL/Mesh_2/Refine_edges.h
. See the commit 82b5359.
Is that correct? That is a sort of breaking change, but the ordering of Ctp_2::constraints()
was never documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jane (IRL) suggested that:
- it is documented that there is a breaking change
- and add a Tag to
Constrained_triangulation_plus_2
to allow users to fallback to the previous behavior.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea how big the gain in efficiency is @lrineau ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to avoid ping-pong changes, I suggest to have CGAL::unordered_map
and to use it everywhere (at least for default hashable items).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Speedups
Any idea how big the gain in efficiency is @lrineau ?
One the data set "Thingi #101881", I have run the experimental CDT_3 code, with compilation flags -O3 -DCGAL_NDEBUG
. The timings of the step "conforming of facets borders" vary a lot:
with... | time | factor |
---|---|---|
std::map |
4110 ms | 1.00 |
std::unordered_map |
3623 ms | 0.88 |
boost::unordered_flat_map |
2897 ms | 0.70 |
I have repeated multiple time each of the three runs. The variance of the timings between each run is less than 5%, and the difference between the three implementations is about 15%.
And the code the "CDT_3 conforming" does a lot more than just handling the CGAL::Constrained_triangulation_plus_2
data-structure. The speedups are significant, in my opinion.
Code
I suggest to have
CGAL::unordered_map
Indeed. I have a patch. I will push it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had several times users where we worked hard to make algorithms deterministic for reproductibility. So this is maybe more important than speed. Also I find it more natural that subconstraints are ordered along the constraint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realize that subconstraints are not the subconstraints of a constraint, but all subconstraints in the constrained triangulation. Instead iterating over the Xmap, why don't we iterate over the vertices of the constraints, as a subconstraint is just a pair of consecutive vertices on a constraint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CGAL::unordered_map
I have pushed the commit 5526857. The results of the testsuites of Triangulation_2
, Mesh_2
, and Polyline_simplification_2
are PASSED on my machine (with Boost.Unordered available).
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
...and `refactor Polyline_constraint_hierarchy_2` to use it. `CGAL::unordered_flat_map` will be Boost `unordered_flat_map` if availlable, or the standard `std::unordered_map` otherwise.
To debug non-determinism on Linux platforms.
Summary of Changes
In the PR #8170, merged for CGAL-6.0, there was several commits that I had to revert, because they broke the testsuite results:
save_binary_file
. That was no correct as regards to the C3t3 concept. It is now fixed by commit c10dcf7 from this PR.Polyline_constraint_hierarchy_2
using an unordered map, instead of astd::map
. The issue was that is broke the determinism of Mesh_2. See Improvement backports from CDT_3 branch (Follow-up to PR #8170) #8273 (comment).CGAL::Segment_3
, for some CGAL kernels.This pull-request reintroduces those features, for CGAL-6.1.
Release Management