Skip to content

Commit

Permalink
Merge pull request #5775 from mvieth/normal3d_dynamic_omp
Browse files Browse the repository at this point in the history
NormalEstimationOMP: use dynamic scheduling for faster computation
  • Loading branch information
mvieth authored Aug 7, 2023
2 parents de6d715 + be05749 commit 97ef1b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions features/include/pcl/features/impl/normal_3d_omp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ pcl::NormalEstimationOMP<PointInT, PointOutT>::computeFeature (PointCloudOut &ou
default(none) \
shared(output) \
firstprivate(nn_indices, nn_dists) \
num_threads(threads_)
num_threads(threads_) \
schedule(dynamic, chunk_size_)
// Iterating over the entire index vector
for (std::ptrdiff_t idx = 0; idx < static_cast<std::ptrdiff_t> (indices_->size ()); ++idx)
{
Expand Down Expand Up @@ -106,7 +107,8 @@ pcl::NormalEstimationOMP<PointInT, PointOutT>::computeFeature (PointCloudOut &ou
default(none) \
shared(output) \
firstprivate(nn_indices, nn_dists) \
num_threads(threads_)
num_threads(threads_) \
schedule(dynamic, chunk_size_)
// Iterating over the entire index vector
for (std::ptrdiff_t idx = 0; idx < static_cast<std::ptrdiff_t> (indices_->size ()); ++idx)
{
Expand Down
5 changes: 4 additions & 1 deletion features/include/pcl/features/normal_3d_omp.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ namespace pcl
public:
/** \brief Initialize the scheduler and set the number of threads to use.
* \param nr_threads the number of hardware threads to use (0 sets the value back to automatic)
* \param chunk_size PCL will use dynamic scheduling with this chunk size. Setting it too low will lead to more parallelization overhead. Setting it too high will lead to a worse balancing between the threads.
*/
NormalEstimationOMP (unsigned int nr_threads = 0)
NormalEstimationOMP (unsigned int nr_threads = 0, int chunk_size = 256): chunk_size_(chunk_size)
{
feature_name_ = "NormalEstimationOMP";

Expand All @@ -90,6 +91,8 @@ namespace pcl
/** \brief The number of threads the scheduler should use. */
unsigned int threads_;

/** \brief Chunk size for (dynamic) scheduling. */
int chunk_size_;
private:
/** \brief Estimate normals for all points given in <setInputCloud (), setIndices ()> using the surface in
* setSearchSurface () and the spatial locator in setSearchMethod ()
Expand Down

0 comments on commit 97ef1b7

Please sign in to comment.