LIHPC-Computational-Geometry / honeycomb

Combinatorial map implementation for meshing applications
https://lihpc-computational-geometry.github.io/honeycomb/
Apache License 2.0
7 stars 1 forks source link

refactor(core): improve grid building routines #209

Closed imrn99 closed 2 weeks ago

imrn99 commented 2 weeks ago
  1. remove a useless if / wrong range in the second construction loop
  2. fuse and flatten both construction loops, removing redundant computations at the same time
  3. replace link usages with set_beta usages
  4. set the last assertion to debug only (it can be removed entirely I think).

performance changes for a 512x512 grid (exec time in ms):

Grid type Original new fetch_ Optim 1, 2, 3 Optim 4
Square 157.11 89.83 92.98 24.54
Triangle 246.48 120.16 121.79 35.54
codecov-commenter commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 82.60%. Comparing base (d79671f) to head (fad1ca0).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #209 +/- ## ========================================== + Coverage 82.04% 82.60% +0.56% ========================================== Files 41 41 Lines 5681 5865 +184 ========================================== + Hits 4661 4845 +184 Misses 1020 1020 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

imrn99 commented 2 weeks ago

I was just wondering if splitting the loop into (the interior domain and then the boundary (last row & last column)) can not make the code easier to read (and perhaps more efficient without a conditional in the middle).

I managed to reorganize the code by splitting like you suggested. I also extracted some common functions which should help with readability

It does not seem to make much of a difference performance-wise (maybe 5% better? but laptop numbers aren't really reliable)