Arrangement: Use Compact Container for DCEL#5408
Conversation
| */ | ||
| template <class V, class H, class F> | ||
| class Arr_inner_ccb : public In_place_list_base<Arr_inner_ccb<V,H,F> > | ||
| class Arr_inner_ccb : public Compact_container_base |
There was a problem hiding this comment.
You can use pointer p_f instead of using Compact_container_base (you will save one pointer per element).
There was a problem hiding this comment.
You are right indeed.
The reason I did not use it is that it will already be squatted when https://github.com/CGAL/cgal/pull/5166/files is merged (as I'm working on an experiment branch with all optimizations, I did not modify this part). I could modify this PR and revert back in the other one, but it's probably a waste of time.
| @@ -91,6 +91,9 @@ template <typename Point_> class Arr_vertex_base { | |||
| /*! Destructor. */ | |||
| virtual ~Arr_vertex_base() {} | |||
There was a problem hiding this comment.
I know this is not your code, but seeing this destructor I am wondering if polymorphism is really used here ?
If not (this must be checked), virtual methods can be avoided in order to save memory.
| CC_iterator(pointer ptr) : m_ptr(ptr) { } | ||
|
|
There was a problem hiding this comment.
This new constructor is the culprit for all the compilation errors.
See for example https://cgal.geometryfactory.com/CGAL/testsuite/CGAL-5.3-Ic-66/Linear_cell_complex_Demo/TestReport_lrineau_ArchLinux-CXX17-Release.gz
In file included from /home/cgal_tester/build/src/cmake/platforms/ArchLinux-CXX17-Release/test/Linear_cell_complex_Demo/MainWindow.cpp:22:
/home/cgal_tester/build/src/cmake/platforms/ArchLinux-CXX17-Release/test/Linear_cell_complex_Demo/import_moka.h: In constructor ‘CGAL::GDart::GDart()’:
/home/cgal_tester/build/src/cmake/platforms/ArchLinux-CXX17-Release/test/Linear_cell_complex_Demo/import_moka.h:23:30: error: call of overloaded ‘CC_iterator(NULL)’ is ambiguous
23 | GDart() : dh(NULL), vh(NULL)
| ^
In file included from /mnt/testsuite/include/CGAL/Triangulation_data_structure_2.h:33,
from /mnt/testsuite/include/CGAL/Triangulation_2.h:32,
from /mnt/testsuite/include/CGAL/Constrained_triangulation_2.h:25,
from /mnt/testsuite/include/CGAL/Constrained_Delaunay_triangulation_2.h:20,
from /home/cgal_tester/build/src/cmake/platforms/ArchLinux-CXX17-Release/test/Linear_cell_complex_Demo/typedefs.h:20,
from /home/cgal_tester/build/src/cmake/platforms/ArchLinux-CXX17-Release/test/Linear_cell_complex_Demo/MainWindow.h:16,
from /home/cgal_tester/build/src/cmake/platforms/ArchLinux-CXX17-Release/test/Linear_cell_complex_Demo/MainWindow.cpp:14:
/mnt/testsuite/include/CGAL/Compact_container.h:906:5: note: candidate: ‘CGAL::internal::CC_iterator<DSC, Const>::CC_iterator(std::nullptr_t) [with DSC = CGAL::Compact_container<CGAL::Dart<3, CGAL::CMap_linear_cell_complex_storage_1<3, 3, CGAL::Linear_cell_complex_traits<3, CGAL::Epick>, Myitems, std::allocator<int>, CGAL::Boolean_tag<false> >, CGAL::Void, CGAL::Boolean_tag<false> >, std::allocator<CGAL::Dart<3, CGAL::CMap_linear_cell_complex_storage_1<3, 3, CGAL::Linear_cell_complex_traits<3, CGAL::Epick>, Myitems, std::allocator<int>, CGAL::Boolean_tag<false> >, CGAL::Void, CGAL::Boolean_tag<false> > >, CGAL::Default, CGAL::Default>; bool Const = false; std::nullptr_t = std::nullptr_t]’
906 | CC_iterator (std::nullptr_t /*CGAL_assertion_code(n)*/)
| ^~~~~~~~~~~
/mnt/testsuite/include/CGAL/Compact_container.h:878:5: note: candidate: ‘CGAL::internal::CC_iterator<DSC, Const>::CC_iterator(CGAL::internal::CC_iterator<DSC, Const>::pointer) [with DSC = CGAL::Compact_container<CGAL::Dart<3, CGAL::CMap_linear_cell_complex_storage_1<3, 3, CGAL::Linear_cell_complex_traits<3, CGAL::Epick>, Myitems, std::allocator<int>, CGAL::Boolean_tag<false> >, CGAL::Void, CGAL::Boolean_tag<false> >, std::allocator<CGAL::Dart<3, CGAL::CMap_linear_cell_complex_storage_1<3, 3, CGAL::Linear_cell_complex_traits<3, CGAL::Epick>, Myitems, std::allocator<int>, CGAL::Boolean_tag<false> >, CGAL::Void, CGAL::Boolean_tag<false> > >, CGAL::Default, CGAL::Default>; bool Const = false; CGAL::internal::CC_iterator<DSC, Const>::pointer = CGAL::Dart<3, CGAL::CMap_linear_cell_complex_storage_1<3, 3, CGAL::Linear_cell_complex_traits<3, CGAL::Epick>, Myitems, std::allocator<int>, CGAL::Boolean_tag<false> >, CGAL::Void, CGAL::Boolean_tag<false> >*]’
878 | CC_iterator(pointer ptr) : m_ptr(ptr) { }
| ^~~~~~~~~~~
/mnt/testsuite/include/CGAL/Compact_container.h:855:9: note: candidate: ‘constexpr CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Dart<3, CGAL::CMap_linear_cell_complex_storage_1<3, 3, CGAL::Linear_cell_complex_traits<3, CGAL::Epick>, Myitems, std::allocator<int>, CGAL::Boolean_tag<false> >, CGAL::Void, CGAL::Boolean_tag<false> >, std::allocator<CGAL::Dart<3, CGAL::CMap_linear_cell_complex_storage_1<3, 3, CGAL::Linear_cell_complex_traits<3, CGAL::Epick>, Myitems, std::allocator<int>, CGAL::Boolean_tag<false> >, CGAL::Void, CGAL::Boolean_tag<false> > >, CGAL::Default, CGAL::Default>, false>::CC_iterator(const CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Dart<3, CGAL::CMap_linear_cell_complex_storage_1<3, 3, CGAL::Linear_cell_complex_traits<3, CGAL::Epick>, Myitems, std::allocator<int>, CGAL::Boolean_tag<false> >, CGAL::Void, CGAL::Boolean_tag<false> >, std::allocator<CGAL::Dart<3, CGAL::CMap_linear_cell_complex_storage_1<3, 3, CGAL::Linear_cell_complex_traits<3, CGAL::Epick>, Myitems, std::allocator<int>, CGAL::Boolean_tag<false> >, CGAL::Void, CGAL::Boolean_tag<false> > >, CGAL::Default, CGAL::Default>, false>&)’
855 | class CC_iterator
| ^~~~~~~~~~~
There is already a constructor from pointers, but it is private, and take an extra int for disambiguation. See https://github.com/sgiraudot/cgal/blob/6bbd72cfde33f76eba3cf692ba969ad3735d802c/STL_Extension/include/CGAL/Compact_container.h#L950-L962.
Where in this PR is the new constructor needed?
There was a problem hiding this comment.
It's needed pretty much everywhere: the original implementation assumes that iterators can be created from pointers are the underlying structure is In_place_list. Is there any reason why this constructor should be private? The CC_iterator is pretty much just a pointer, and it's quite handy to be able to construct one from the other.
There was a problem hiding this comment.
My guess is that was to avoid errors with implicit conversions, in the past before C++11 explicit constructors. I think the constructor from a pointer could be made public, but not documented, but only if it is explicit.
|
Alright, so as suggested by Laurent, I made the constructor from a pointer explicit. It did require some changes in the arrangement iterators. I also replaced |
|
Errors : Most of the red squares in https://cgal.geometryfactory.com/CGAL/testsuite/results-5.3-Ic-90.shtml |
|
I'll look into it, sorry about the mess :( |
No. The culprit is 9f9e1e2 from PR #5233 (I have bisected). That is the one responsible for all the compilation errors about |
|
There are errors though, like https://cgal.geometryfactory.com/CGAL/testsuite/CGAL-5.3-Ic-90/Polygon_Demo/TestReport_lrineau_Fedora-with-LEDA.gz that seem to be related to the change of Compact_container iterators. |
|
Thanks Laurent! |
By rebase you mean that you still merge |
|
Oh okay, I missed that… I used to do |
|
I fixed the bug (it was just the way a loop was written which made an iterator to |
|
This warning does not seem to come from my PR, I can reproduce it without |
|
Successfully tested in https://cgal.geometryfactory.com/CGAL/testsuite/results-5.3-Ic-114.shtml |
|
Just a quick note in case someone runs into this PR in the future: contrary to what I originally claimed, this PR does not introduce a memory overhead. Some structures do need an additional pointer for the Compact Container, but all structures used to need 2 pointers from the From Efi's tests: |
Summary of Changes
The DCEL data structure currently uses
In_place_list. Although using thefast_pool_allocatoralready speeds this structure up, I experimented with the Compact Container and noticed it was more efficient.In_place_list_base), and thus the memory usage is decreasedfast_pool_allocatorremains more efficient thanstd::allocatorBy running the testsuite locally, I got errors from iterators constructed from
0. I replaced that bynullptrand it fixed the problems.Release Management