@@ -234,15 +234,9 @@ NeighborhoodSearch::update_point_sets()
234234 }
235235
236236 // Precompute cell indices.
237- #ifdef _MSC_VER
238- concurrency::parallel_for_each (
239- #elif defined(__APPLE__) && defined(__clang__)
240- std::for_each (oneapi::dpl::execution::par,
241- #else
242- __gnu_parallel::for_each (
243- #endif
244- m_point_sets.begin (), m_point_sets.end (), [&](PointSet& d)
245- {
237+ #pragma omp parallel for
238+ for (int j = 0 ; j < m_point_sets.size (); j++){
239+ PointSet& d = m_point_sets[j];
246240 if (d.is_dynamic ())
247241 {
248242 d.m_keys .swap (d.m_old_keys );
@@ -251,7 +245,7 @@ NeighborhoodSearch::update_point_sets()
251245 d.m_keys [i] = cell_index (d.point (i));
252246 }
253247 }
254- });
248+ }
255249
256250 std::vector<unsigned int > to_delete;
257251 if (m_erase_empty_cells)
@@ -315,15 +309,9 @@ NeighborhoodSearch::erase_empty_entries(std::vector<unsigned int> const& to_dele
315309 });
316310
317311 // Perform neighborhood search.
318- #ifdef _MSC_VER
319- concurrency::parallel_for_each (
320- #elif defined(__APPLE__) && defined(__clang__)
321- std::for_each (oneapi::dpl::execution::par,
322- #else
323- __gnu_parallel::for_each (
324- #endif
325- kvps.begin (), kvps.end (), [&](std::pair<HashKey const , unsigned int >* kvp_)
326- {
312+ #pragma omp parallel for
313+ for (int j =0 ; j < kvps.size (); j++){
314+ std::pair<HashKey const , unsigned int >* kvp_ = kvps[j];
327315 auto & kvp = *kvp_;
328316
329317 for (unsigned int i = 0 ; i < to_delete.size (); ++i)
@@ -334,7 +322,7 @@ NeighborhoodSearch::erase_empty_entries(std::vector<unsigned int> const& to_dele
334322 break ;
335323 }
336324 }
337- });
325+ }
338326}
339327
340328void
@@ -415,22 +403,16 @@ NeighborhoodSearch::query()
415403 });
416404
417405 // Perform neighborhood search.
418- #ifdef _MSC_VER
419- concurrency::parallel_for_each (
420- #elif defined(__APPLE__) && defined(__clang__)
421- std::for_each (oneapi::dpl::execution::par,
422- #else
423- __gnu_parallel::for_each (
424- #endif
425- kvps.begin (), kvps.end (), [&](std::pair<HashKey const , unsigned int > const * kvp_)
426- {
406+ #pragma omp parallel for
407+ for (int _i = 0 ; _i < kvps.size (); _i++){
408+ std::pair<HashKey const , unsigned int > const * kvp_ = kvps[_i];
427409 auto const & kvp = *kvp_;
428410 HashEntry const & entry = m_entries[kvp.second ];
429411 HashKey const & key = kvp.first ;
430412
431413 if (entry.n_searching_points == 0u )
432414 {
433- return ;
415+ continue ;
434416 }
435417
436418 for (unsigned int a = 0 ; a < entry.n_indices (); ++a)
@@ -471,26 +453,20 @@ NeighborhoodSearch::query()
471453 }
472454 }
473455 }
474- );
475456
476457
477458 std::vector<std::array<bool , 27 >> visited (m_entries.size (), {false });
478459 std::vector<Spinlock> entry_locks (m_entries.size ());
479460
480- #ifdef _MSC_VER
481- concurrency::parallel_for_each (
482- #elif defined(__APPLE__) && defined(__clang__)
483- std::for_each (oneapi::dpl::execution::par,
484- #else
485- __gnu_parallel::for_each (
486- #endif
487- kvps.begin (), kvps.end (), [&](std::pair<HashKey const , unsigned int > const * kvp_)
488- {
461+ #pragma omp parallel for
462+ for (int _i = 0 ; _i < kvps.size (); _i++){
463+ std::pair<HashKey const , unsigned int > const * kvp_ = kvps[_i];
464+
489465 auto const & kvp = *kvp_;
490466 HashEntry const & entry = m_entries[kvp.second ];
491467
492468 if (entry.n_searching_points == 0u )
493- return ;
469+ continue ;
494470 HashKey const & key = kvp.first ;
495471
496472 for (int dj = -1 ; dj <= 1 ; dj++)
@@ -579,8 +555,7 @@ NeighborhoodSearch::query()
579555 }
580556 }
581557 }
582- });
583-
558+ }
584559}
585560
586561
0 commit comments