File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -265,8 +265,8 @@ std::shared_ptr<geometry::VoxelGrid> UniformTSDFVolume::ExtractVoxelGrid()
265265#pragma omp parallel num_threads(utility::EstimateMaxThreads())
266266 {
267267#pragma omp single
268- { per_thread_voxels.resize (omp_get_num_threads ()); }
269- int thread_id = omp_get_thread_num ();
268+ { per_thread_voxels.resize (utility::GetNumThreads ()); }
269+ int thread_id = utility::GetThreadNum ();
270270
271271#ifdef _WIN32
272272#pragma omp for schedule(static)
Original file line number Diff line number Diff line change @@ -45,6 +45,22 @@ int EstimateMaxThreads() {
4545#endif
4646}
4747
48+ int GetNumThreads () {
49+ #ifdef _OPENMP
50+ return omp_get_num_threads ();
51+ #else
52+ return 1 ; // No parallelism available.
53+ #endif
54+ }
55+
56+ int GetThreadNum () {
57+ #ifdef _OPENMP
58+ return omp_get_thread_num ();
59+ #else
60+ return 0 ; // No parallelism available, so thread ID is always 0.
61+ #endif
62+ }
63+
4864bool InParallel () {
4965 // TODO: when we add TBB/Parallel STL support to ParallelFor, update this.
5066#ifdef _OPENMP
Original file line number Diff line number Diff line change @@ -13,6 +13,12 @@ namespace utility {
1313// / Estimate the maximum number of threads to be used in a parallel region.
1414int EstimateMaxThreads ();
1515
16+ // / Returns the number of threads in the current parallel region.
17+ int GetNumThreads ();
18+
19+ // / Returns the thread ID in the current parallel region.
20+ int GetThreadNum ();
21+
1622// / Returns true if in an parallel section.
1723bool InParallel ();
1824
You can’t perform that action at this time.
0 commit comments