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

Update DBSCAN post-processing to avoid calling sort #453

Merged
merged 9 commits into from
Jan 12, 2021

Conversation

aprokop
Copy link
Contributor

@aprokop aprokop commented Jan 6, 2021

We know that Kokkos::BinSort struggles on arrays with duplicated
indices, which is certainly the case here, as the sort is called on
cluster indices.

The new approach completely avoids that. And, in fact, seems to be
faster.

@aprokop aprokop added the performance Something is slower than it should be label Jan 6, 2021
@aprokop
Copy link
Contributor Author

aprokop commented Jan 6, 2021

I tried this on V100, and it dropped the postprocessing time from 0.27 to 0.15. In serial, I actually was able to run the 1M problem while it just hanged previously.

@dalg24 Can you please try it on HIP to make sure it does not introduce a regression?
@masterleinad Could you please give it a whirl with SYCL?

@aprokop
Copy link
Contributor Author

aprokop commented Jan 6, 2021

One details that the current version of the patch introduces is that the resulting crs-like storage is not deterministic, while previously it was (in most cases, due to Thrust sort being stable).

It's not a problem per say, as the result is still valid, but it is hard to test against a golden file when spitting out cluster centers, as they are subject to summation order.

I'd like to be able to sort indices corresponding to the same offset entry prior to center computation, but not sure how to efficiently. Any thoughts?

Update: Thanks to a hint from @dalg24, this was resolved by using a heap to order the indices before the printout.

@masterleinad
Copy link
Collaborator

@masterleinad Could you please give it a whirl with SYCL?

This pull request more or less eliminates postprocessing for SYCL.

@aprokop aprokop force-pushed the dbscan_postprocess branch 4 times, most recently from 3afcbcd to 0461dc9 Compare January 6, 2021 22:44
@aprokop
Copy link
Contributor Author

aprokop commented Jan 6, 2021

OK, this is ready for a review.

examples/dbscan/dbscan.cpp Outdated Show resolved Hide resolved
test/tstHeapOperations.cpp Outdated Show resolved Hide resolved
BOOST_AUTO_TEST_CASE(sort_heap)
{
for (auto heap : {std::vector<int>{36, 19, 25, 17, 3, 7, 1, 2, 9},
for (auto heap : {std::vector<int>{}, std::vector<int>{3},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not strictly belong to this PR, but I think it's helpful to slightly expand the testing.

src/details/ArborX_DetailsHeap.hpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@masterleinad masterleinad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments but looks good to me.

examples/dbscan/ArborX_DBSCAN.hpp Show resolved Hide resolved
Comment on lines +132 to +141
// FIXME we don't want to modify the clusters view in this check. What we
// want here is to create a view on the host, and deep_copy into it.
// create_mirror_view_and_copy won't work, because it is a no-op if clusters
// is already on the host.
decltype(Kokkos::create_mirror_view(Kokkos::HostSpace{},
std::declval<ClusterView>()))
clusters_host(Kokkos::ViewAllocateWithoutInitializing(
"ArborX::DBSCAN::clusters_host"),
clusters.size());
Kokkos::deep_copy(exec_space, clusters_host, clusters);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be useful to have in Kokkos.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure would be nice if some kind soul could introduce it there. Definitely not doing it myself.

@aprokop
Copy link
Contributor Author

aprokop commented Jan 8, 2021

@dalg24 I removed the heapSort. This should have addressed all your comments.

We know that Kokkos::BinSort struggles on arrays with duplicated
indices, which is certainly the case here, as the sort is called on
cluster indices.

The new approach completely avoids that. And, in fact, seems to be
faster.
The passed `clusters` view was unintentionally modified during
verification, causing issues for post-processing when verify was
enabled. This problem has been around for a long time, and was uncovered
before because the output results were never checked when run with
verify.
@aprokop
Copy link
Contributor Author

aprokop commented Jan 12, 2021

Rebased on master, as it was conflicting after merging #450.

test/tstHeapOperations.cpp Outdated Show resolved Hide resolved
@aprokop aprokop merged commit f39640a into arborx:master Jan 12, 2021
@aprokop aprokop deleted the dbscan_postprocess branch January 12, 2021 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Something is slower than it should be
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants