Skip to content
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

Exit early from unionFindWithingEachDistanceCell when n <= 1 #1067

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/details/ArborX_DetailsFDBSCANDenseBox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,17 @@ void unionFindWithinEachDenseCell(ExecutionSpace const &exec_space,
CellIndices sorted_dense_cell_indices,
Permutation permute, UnionFind union_find)
{
auto const n = sorted_dense_cell_indices.size();
if (n <= 1)
return;

// The algorithm relies on the fact that the cell indices array only contains
// dense cells. Thus, as long as two cell indices are the same, a) they
// belong to the same cell, and b) that cell is dense, thus they should be in
// the same cluster. If, on the other hand, the array also contained
// non-dense cells, that would not have been possible, as an additional
// computations would have to be done to figure out if the points belong to a
// dense cell, which would have required a linear scan.
auto const n = sorted_dense_cell_indices.size();
Kokkos::parallel_for(
"ArborX::DBSCAN::union_find_within_each_dense_box",
Kokkos::RangePolicy<ExecutionSpace>(exec_space, 1, n),
Expand Down
Loading