BLI: Optimize utility for index counting #109628

Merged
Hans Goudey merged 9 commits from HooglyBoogly/blender:bli-index-count into main 2023-07-05 16:05:22 +02:00

9 Commits

Author SHA1 Message Date
Hans Goudey 5daa89666b Add check for thread count < 4 2023-07-05 09:47:26 -04:00
Hans Goudey 2b8d53f669 Merge branch 'main' into bli-index-count 2023-07-05 09:47:09 -04:00
Hans Goudey d9286288f2 Use atomic implementation 2023-07-03 19:46:37 -04:00
Hans Goudey 848024900b Merge branch 'main' into bli-index-count 2023-07-03 18:47:26 -04:00
Hans Goudey fbca37ff01 Remove performance changes 2023-07-03 18:44:52 -04:00
Hans Goudey f726797376 Merge branch 'main' into bli-index-count 2023-07-03 14:33:18 -04:00
Hans Goudey c945c4cf51 Merge branch 'main' into bli-index-count 2023-07-03 09:54:00 -04:00
Hans Goudey bdc1bf8048 Merge branch 'main' into bli-index-count 2023-07-02 22:15:46 -04:00
Hans Goudey e05df28192 BLI: Add utility for index counting
The utility counts the number of occurences of each index in an array.
This happens to build offsets for mesh topology maps, or to count the
number of connected elements. Some users are geometry nodes,
the subdivision draw cache, and mesh to curve conversion.

Now that the utility is in one place, it's reasonable to optimize it
with compiler flags. On GCC, unrolling the loop gave me a 1.9x
performance improvement, counting the number corners for each
vertex in a 4 million vertex mesh went from 7.4 to 3.9 ms.

In a couple places this improves code reuse, sharing the
implementation of the pattern where it was repeated before.
2023-07-02 18:37:55 -04:00