Skip to content

Commit

Permalink
Small fix in OpenMP for loop
Browse files Browse the repository at this point in the history
One compiler complained that "‘kdtree’ is predetermined ‘shared’ for ‘shared’". kdtree is a const variable, which are always shared. The solution is to remove kdtree from the shared clause (not explicitly declare it as shared again).
Then we also have to remove `default(none)` because otherwise other compilers complain that the data sharing attribute is not explicitly defined for kdtree. Normally, `default(none)` is recommended because it forces the programmer to consider which variables should be shared and which ones private. But since the code is finished, it is okay to remove `default(none)`.
Basically, this solution (no `default(none)` and don't explicitly define the const `kdtree` as shared) is the only one that works with all compilers.
  • Loading branch information
mvieth committed Aug 18, 2024
1 parent 4885cf7 commit 0ddeb32
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions registration/include/pcl/registration/impl/gicp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ GeneralizedIterativeClosestPoint<PointSource, PointTarget, Scalar>::computeCovar
if (cloud_covariances.size() < cloud->size())
cloud_covariances.resize(cloud->size());

#pragma omp parallel for default(none) num_threads(threads_) schedule(dynamic, 32) \
shared(cloud, cloud_covariances, kdtree) \
firstprivate(mean, cov, nn_indices, nn_dist_sq)
#pragma omp parallel for num_threads(threads_) schedule(dynamic, 32) \
shared(cloud, cloud_covariances) firstprivate(mean, cov, nn_indices, nn_dist_sq)
for (std::ptrdiff_t i = 0; i < static_cast<std::ptrdiff_t>(cloud->size()); ++i) {
const PointT& query_point = (*cloud)[i];
// Zero out the cov and mean
Expand Down

0 comments on commit 0ddeb32

Please sign in to comment.