-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
[registration] Add OMP based Multi-threading to SampleConsensusPrerejective #4433
base: master
Are you sure you want to change the base?
Conversation
@koide3 Could you please tag the PR appropriately? PS: Failures on Mac |
@kunaltyagi It seems I don't have permission to edit tags... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the changes LGTM. Haven't reviewed the code deeply
registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp
Outdated
Show resolved
Hide resolved
registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp
Outdated
Show resolved
Hide resolved
registration/include/pcl/registration/sample_consensus_prerejective.h
Outdated
Show resolved
Hide resolved
registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp
Outdated
Show resolved
Hide resolved
registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp
Outdated
Show resolved
Hide resolved
registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp
Outdated
Show resolved
Hide resolved
2030a81
to
365fefe
Compare
I did rebase and squash to resolve the conflict. |
@SunBlack could you please take a look at the OMP pragma sites? |
registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp
Outdated
Show resolved
Hide resolved
registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp
Outdated
Show resolved
Hide resolved
Took a while until both compilers build the branch. @kunaltyagi After removing Ubuntu 16.04 from Azure: do we still have a GCC 6-8 anywhere, so we can still be sure to have @koide3 Are you are sure about the usage of |
Yes, 18.04 has GCC 7 on it (though we force install GCC 8 on it for now due to ... reasons) |
Yes, one copy of the them must be created for each thread. |
registration/include/pcl/registration/sample_consensus_prerejective.h
Outdated
Show resolved
Hide resolved
registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp
Outdated
Show resolved
Hide resolved
registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp
Outdated
Show resolved
Hide resolved
Do you have an estimate which parts of |
Here is a brief benchmark result. The second for loop, which is the main loop of RANSAC, is the most expensive part in this algorithm, while the first for loop is not so heavy. It seems the overhead of omp is not so large in this case, and both the loops get much faster with omp.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your benchmark looks really promising!
Do you think it would make sense to add a unit test, e.g. to copy the one in test_sac_ia.cpp and run it again with 4 threads?
registration/include/pcl/registration/sample_consensus_prerejective.h
Outdated
Show resolved
Hide resolved
registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp
Show resolved
Hide resolved
Can I do rebase and force-push to resolve the conflicts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good--just a couple minor things
registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp
Outdated
Show resolved
Hide resolved
registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp
Show resolved
Hide resolved
registration/include/pcl/registration/sample_consensus_prerejective.h
Outdated
Show resolved
Hide resolved
registration/include/pcl/registration/sample_consensus_prerejective.h
Outdated
Show resolved
Hide resolved
registration/include/pcl/registration/sample_consensus_prerejective.h
Outdated
Show resolved
Hide resolved
registration/include/pcl/registration/sample_consensus_prerejective.h
Outdated
Show resolved
Hide resolved
9f34405
to
0e622ad
Compare
Conflicts are resolved. |
registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp
Outdated
Show resolved
Hide resolved
Somehow my comment threads don't have "Resolve" buttons--maybe because I made them comments and not change requests in the first place? I do consider them all resolved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the long delay, the changes look good.
Only the windows CIs are failing, but I seem to be unable to rerun them, probably because the runs are too old? Perhaps if you close and reopen this PR?
Hopefully this fixes compile error on windows: "only a variable or static data member can be used in a data-sharing clause"
I checked again and the drawing of the random samples ( |
Ahh, yes that seems to cause problems. Atleast its not as random as it should be and according to some reading, can lead to UB, when calling rand() in multithreaded manner. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look into calling rand() in multithreaded.
I guess the |
PointCloudSource input_transformed; | ||
input_transformed.resize(input_->size()); | ||
transformPointCloud(*input_, input_transformed, final_transformation_); | ||
transformPointCloud(*input_, input_transformed, transformation); | ||
|
||
// For each point in the source dataset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nn_indices and nn_dists could be moved outside the for loop to reduce (de)allocations.
I can't confirm that: In my tests, less than 1% of the time of |
Yeah okay, that doesn't sound like much. Lets see what your tests shows 👍 |
This PR adds OMP-based multi-threading capability to
SampleConsensusPrerejective
.Changes are as follows:
getFitness()
is modified such that it uses per-threadtransformation
variablesimilar_features
are precomputed for concurrency