Skip to content

Parallel voxelgrid - #6479

Draft
jmackay2 wants to merge 4 commits into
PointCloudLibrary:masterfrom
jmackay2:voxelgrid_parallel
Draft

Parallel voxelgrid#6479
jmackay2 wants to merge 4 commits into
PointCloudLibrary:masterfrom
jmackay2:voxelgrid_parallel

Conversation

@jmackay2

Copy link
Copy Markdown
Contributor

This adds OpenMP parallelization to voxelgrid.

This was tested on Ubuntu 24.04.

The benchmark on my machine gives the following:

-----------------------------------------------------------------------
Benchmark                             Time             CPU   Iterations
-----------------------------------------------------------------------
BM_VoxelGrid_milk                  7.31 ms         7.31 ms           96
BM_VoxelGrid_milk_2Threads         5.98 ms         5.98 ms          116
BM_VoxelGrid_milk_MaxThreads       4.54 ms         4.54 ms          153
BM_ApproximateVoxelGrid_milk       2.73 ms         2.73 ms          257
BM_VoxelGrid_mug                   5.83 ms         5.83 ms          120
BM_VoxelGrid_mug_2Threads          5.00 ms         5.00 ms          139
BM_VoxelGrid_mug_MaxThreads        3.95 ms         3.94 ms          177
BM_ApproximateVoxelGrid_mug        2.20 ms         2.20 ms          322

@mvieth

mvieth commented Sep 10, 2026

Copy link
Copy Markdown
Member

This looks like an interesting addition! Two early thoughts (no full review yet):

  • MSVC (Windows) unfortunately only supports OpenMP 2.0, so you either have to make sure to only use things available in OpenMP 2.0, or check the version in a preprocessor statement and provide an alternative
  • Have you checked the speed-up for each part individually? E.g. for getMinMax3D, for computing the indices, for sorting, for computing the centroids. Would be interesting to see, which parts benefit most (are easily parallelizable without overhead), and which parts not so much.

@larshg

larshg commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

This looks like an interesting addition! Two early thoughts (no full review yet):

  • MSVC (Windows) unfortunately only supports OpenMP 2.0, so you either have to make sure to only use things available in OpenMP 2.0, or check the version in a preprocessor statement and provide an alternative

Looked a bit into this and we can change to use /openmp:llvm (from visual studio 2019 16.10 it supports x86 and arm as well) - to support newer versions of openmp.
https://learn.microsoft.com/en-us/cpp/build/reference/openmp-enable-openmp-2-0-support?view=msvc-170

The version output from cmake is however still wrong, see:
https://developercommunity.visualstudio.com/t/Wrong-OpenMP-Version-when-using-openmp:/10830231?sort=newest

It looks like they will transition to use openmp:llvm as default and patch any errors for the version they ship and eventually upstream according to:
https://devblogs.microsoft.com/cppblog/improved-openmp-support-for-cpp-in-visual-studio/

I just got a it building locally and see similar improvements:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants