Skip to content

Commit

Permalink
fix: Add omp single region
Browse files Browse the repository at this point in the history
Add `omp single` region to make sure the number of threads are only set
once.
  • Loading branch information
TomSchammo committed Nov 14, 2024
1 parent eb19c31 commit 4842f0e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cpp/src/raytracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,13 @@ void rt::intersects(torch::Tensor point_cloud,

#pragma omp parallel
{
const auto nthreads = std::thread::hardware_concurrency();
std::cout << "Setting OpenMP to use " << nthreads << " threads!\n";
omp_set_num_threads(nthreads);
#pragma omp single
{

const auto nthreads = std::thread::hardware_concurrency();
std::cout << "Setting OpenMP to use " << nthreads << " threads!\n";
omp_set_num_threads(nthreads);
}
#pragma omp parallel for schedule(dynamic)
for (tensor_size_t i = 0; i < num_points; i++) {

Expand Down

0 comments on commit 4842f0e

Please sign in to comment.