-
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
Store index/dimension in 8 bits #8028
Conversation
You should probably ask Gudhi developers. Are they users of dD CGAL Triangulations? |
We use CGAL dD Delaunay/regular triangulations in Gudhi, yes. But I have trouble imagining using it in dimension 200+. As the CGAL user manual shows, inserting 100 points in a Delaunay triangulation of dimension 12 already takes 40 minutes and 7G of memory... (inserting n≤dim affinely independent points should be doable though not interesting, but as soon as we have to do orientation and insphere tests, things will be bad) |
If you give it dimension-250 input, I think the code will seriously consider whether life is worth it, and maybe jump out of the window. To paraphrase B. Gates, 15D ought to be enough. Although I've seen some people playing with CGAL dD-Del in dimension 17, with very very few points. B. Lévy is toying with the idea of 6D Delaunay (phase space in physics). Maybe some people in loop quantum gravity are interested in TDS in ≈10D ? |
Thanks for your comment.
Delaunay, yes, but it may be possible to build a TDS manually?
Ok so we should at least support dim 17.
The particular change in this PR is mostly useful for static dimension, and thus it could relatively easily be done automatically (if static dimension at most 255, use uint8_t, else back to int), no need for a new policy. |
@mglisse CGAL-6.0-Ic-172 has runtime errors in Triangulation test but I'm not sure it is this PR in particular
|
value -1 is used
Indeed, value -1 is used sometimes, in a way that would require further tweaks to work with unsigned storage, so I just switched to signed, i.e. dimensions up to ~120. (I don't think it fundamentally changes the issue, either we consider that any dimension above 20 is crazy, or we don't and I have to add a condition and it might as well test for 127 instead of 255.) |
I would also say go for it. At worst this will trigger an issue of a user who needs more, so we will even learn about this kind of use case. And we can offer this user an easy fix. But you have to document it, and also as breaking change in changes,md |
Done, though this means this branch now probably conflicts with the other one that touches changes.md. |
@@ -42,7 +42,7 @@ struct TFC_data< Vertex_handle, Full_cell_handle, Maximal_dimension, TDS_full_ | |||
|
|||
void set_mirror_index(const int i, const int index) | |||
{ | |||
mirror_vertices_[i] = index; | |||
mirror_vertices_[i] = static_cast<std::int_least8_t>(index); |
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.
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.
-Wstringop-overflow and -Warray-bounds are 2 of the worst offenders among the recent gcc warnings that only ever give false positives...
Except from the aforementioned warning (that is a false positive according to Marc), successfully tested in CGA-6.0-Ic-173 |
Summary of Changes
What dimensions do we want to support in the Triangulation package? The optional policy to store mirror indexes in the full cells of the TDS currently uses an
int
to store an index. Since indexes are bounded by the dimension (+1), that seems like a waste of memory. Usinguint8_t
is sufficient up to dimension ~250, reduces the memory overhead of this policy significantly, and improves performance a bit. Is it ok to assume that the dimension fits in 8 bits (with a bit of margin), or do I need to use some meta-programming so it uses different types depending on the dimension?For a dynamic dimension, having a whole vector for the mirror indexes remains a large overhead even if it is a
vector<char>
. Since we only need to store ~ d numbers of log(d) bits, a single 64-bit integer should suffice to handle dimensions up to ~ 15 (i.e. the ones I care about). Or the 3 vectors (vertices, neighbors, mirror indices) could be merged into a single vector. And we could reduce a bit the overhead by usingunique_ptr<T[]>
instead of vector, since the size is fixed at construction. But that's all for later, once I have an idea what dimensions are relevant.Release Management