Skip to content
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

NormalEstimationOMP: use dynamic scheduling for faster computation #5775

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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