-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Make omp naming and functionality consistent. #6293
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
base: master
Are you sure you want to change the base?
Conversation
///number of threads to be used, default 0 (auto) | ||
unsigned int threads_{0}; | ||
///number of threads to be used | ||
unsigned int num_threads_{1}; |
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.
This defaulted to 0, ie. automatic number of threads, but now it defaults to 1 (as majority of the algorithms did) - but I guess we don't have any rule here, whether or not to include it?
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.
Pull Request Overview
This PR standardizes the OpenMP thread‐count parameter name to num_threads
, updates default values to 1, adds auto‐detection of hardware threads when requests are zero, and replaces all threads_
references in pragmas with num_threads_
.
- Renamed
threads_
tonum_threads_
and updated constructors/signatures. - Changed
setNumberOfThreads
logic to usenum_threads
andomp_get_num_procs()
. - Updated all OpenMP pragmas to use
num_threads(num_threads_)
.
Reviewed Changes
Copilot reviewed 65 out of 65 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
filters/include/pcl/filters/pyramid.h | Renamed and rewrote setNumberOfThreads , member renaming |
filters/include/pcl/filters/impl/pyramid.hpp | Updated OMP pragmas to use num_threads_ |
filters/include/pcl/filters/impl/fast_bilateral_omp.hpp | Renamed parameter, updated logic and pragmas |
filters/include/pcl/filters/impl/convolution_3d.hpp | Updated OMP pragmas |
filters/include/pcl/filters/impl/convolution.hpp | Updated OMP pragmas |
filters/include/pcl/filters/fast_bilateral_omp.h | Renamed constructor and parameter |
filters/include/pcl/filters/convolution_3d.h | Renamed and rewrote setNumberOfThreads , member renaming |
filters/include/pcl/filters/convolution.h | Renamed and rewrote setNumberOfThreads , member renaming |
features/include/pcl/features/shot_omp.h | Renamed constructor and parameter, member renaming |
features/include/pcl/features/shot_lrf_omp.h | Renamed parameter and member |
features/include/pcl/features/principal_curvatures.h | Renamed constructor and parameter, member renaming |
features/include/pcl/features/normal_3d_omp.h | Renamed constructor and parameter, member renaming |
features/include/pcl/features/intensity_gradient.h | Renamed and rewrote setNumberOfThreads , member renaming |
features/include/pcl/features/impl/shot_omp.hpp | Updated calls and pragmas to use num_threads_ |
features/include/pcl/features/impl/shot_lrf_omp.hpp | Updated parameter logic and pragmas |
features/include/pcl/features/impl/principal_curvatures.hpp | Updated setNumberOfThreads logic and pragmas |
features/include/pcl/features/impl/normal_3d_omp.hpp | Updated setNumberOfThreads logic and pragmas |
features/include/pcl/features/impl/intensity_gradient.hpp | Removed old detection logic, updated pragmas |
features/include/pcl/features/impl/fpfh_omp.hpp | Updated setNumberOfThreads logic and pragmas |
features/include/pcl/features/fpfh_omp.h | Renamed constructor and parameter, member renaming |
#ifdef _OPENMP | ||
num_threads_ = num_threads != 0 ? num_threads : omp_get_num_procs(); | ||
#else | ||
if (num_threads_ != 1) { |
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.
The warning condition checks num_threads_
(the member) rather than the requested num_threads
parameter. It should warn when the user-requested num_threads
is not 1.
if (num_threads_ != 1) { | |
if (num_threads != 1) { |
Copilot uses AI. Check for mistakes.
@@ -155,7 +165,7 @@ namespace pcl | |||
/// Threshold distance between adjacent points | |||
float threshold_{0.01f}; | |||
/// \brief number of threads | |||
unsigned int threads_{0}; | |||
unsigned int num_threads_{1}; |
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.
Defaulting num_threads_
to 1 changes the previous auto-detection behavior when setNumberOfThreads(0)
was never called. Consider initializing to 0 or calling setNumberOfThreads(0)
in the constructor to preserve auto-detect.
unsigned int num_threads_{1}; | |
unsigned int num_threads_{0}; |
Copilot uses AI. Check for mistakes.
*/ | ||
inline void | ||
setNumberOfThreads (unsigned int nr_threads = 0) { threads_ = nr_threads; } | ||
setNumberOfThreads(unsigned int num_threads = 0) |
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.
[nitpick] The setNumberOfThreads
logic is duplicated across many classes. Consider extracting it into a shared helper or macro to reduce code repetition and ease future updates.
Copilot uses AI. Check for mistakes.
b054dd8
to
808f253
Compare
An idea: how about, instead of having As a second step, we could then discuss also moving |
Yeah, It seems PCLBase is used for all algorithms, so could make sense. I'm not sure how we should do it with setNumberOfThreads. Not sure if it its enough, just documenting, that not all classes make use of the set value. |
Should we default to using omp_get_num_procs() threads instead of 1 - I would expect code to be multithreaded by default 😄 |
I am also fine with
Sounds good to me. How are you planning to do that? Calling |
Should SampleConsensus inherit from PCLBase as well? The I/O Imagegrabber also has parallelizing, but should they also inherit from PCLBase? So I guess I/O shouldn't, but SampleConsesus could(Should)? |
5a216b8
to
9679064
Compare
I think I would not change any inheritance. |
c072a2f
to
fb4af32
Compare
b225008
to
656b4eb
Compare
Set number of threads using omp_get_num_procs in initCompute.
ad60cbf
to
d1f3bcf
Compare
No description provided.