Skip to content

Commit

Permalink
Improve performance by removing some if statements
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed Apr 3, 2024
1 parent c0deec3 commit bd02e09
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/details/ArborX_DetailsBruteForceImpl.hpp
Expand Up @@ -192,18 +192,19 @@ struct BruteForceImpl
// neighbors have been found.
auto radius = KokkosExt::ArithmeticTraits::infinity<float>::value;

for (int j = 0; j < n_indexables; ++j)
int j = 0;
for (; j < n_indexables && j < k; ++j)
{
auto const distance = predicate.distance(indexables(j));
heap.push(Kokkos::make_pair(j, distance));
}
for (; j < n_indexables; ++j)
{
auto const distance = predicate.distance(indexables(j));
if (distance < radius)
{
auto pair = Kokkos::make_pair(j, distance);
if ((int)heap.size() < k)
heap.push(pair);
else
heap.popPush(pair);
if ((int)heap.size() == k)
radius = heap.top().second;
heap.popPush(Kokkos::make_pair(j, distance));
radius = heap.top().second;
}
}
while (!heap.empty())
Expand Down

0 comments on commit bd02e09

Please sign in to comment.