8000 Distributed nearest callback by aprokop · Pull Request #1075 · arborx/ArborX · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Distributed nearest callback #1075

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

Merged
merged 10 commits into from
May 22, 2024

Conversation

aprokop
Copy link
Contributor
@aprokop aprokop commented Apr 25, 2024

[The 3-round rework of #737 will be pushed in that branch once this PR has been merged].

Works for both APIv1 and APIv2 (that was quite tricky).

Introduces two ways to do a nearest callback in the distributed setting:

  • 2-round communication for a constrained callback

Constrained meaning that

  • It is allowed to be called on not final matches
  • For each match, it outputs exactly one result

Constrained callback is indicated with a new tag.

Current limitations:

  • I have not thought yet about post-callbacks and whether they should be allowed
    To be fair, even with the spatial callbacks I'm not sure what that means

@aprokop aprokop added the enhancement New feature or request label Apr 25, 2024
@aprokop aprokop force-pushed the distributed_nearest_callback branch from bff4f8e to ab1eb5d Compare May 3, 2024 21:59
@aprokop aprokop marked this pull request as ready for review May 3, 2024 22:00
namespace Details
{

template <typename Tree, typename Callback, typename OutValue, bool UseValues>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The OutValue argument is really annoying. Currently, no avoiding it. The issue is that we can't determine from the callback's signature what the output value type is going to be. The way we are doing things right now is that determine that from the storage arrays passed in by a user.

@@ -84,7 +84,7 @@ struct LegacyCallbackWrapper
PairValueIndex<Value, Index> const &value,
Output const &out) const
{
_callback(predicate, value.index, out);
_callback(predicate, (int)value.index, out);
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 is a more precise treatment for APIv1. I also needed this due to the default distributed callback now being templated on the value, resulting in the unsigned -> signed loss of precision errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand that change nor your "a more precise treatment for APIv1" comment.
In any case we will also need to add a comment in the code to explain why we cast.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Our definition of the original callback was operator()(Query const& query, int i). Without casting, the second argument is actually of type the default index of PairValueIndex, which is unsigned. That diverged from the original APIv1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

and you prefer explicit cast than implicit for readability right, it is not needed per se?
(just trying to make sure I understand)

Copy link
Contributor

Choose a reason for hiding this comment

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

Needed for aggregate initialization

The problem with tags is that their behavior is not visible for users.
If a previous version of ArborX ignores tags, it may just silently do
something else.

Instead, we want to fail compilation if the user indicates an intention
we do not support. This is one way to do it: user has to wrap their
callback into a class.
@aprokop aprokop requested a review from masterleinad May 14, 2024 14:43
@@ -84,7 +84,7 @@ struct LegacyCallbackWrapper
PairValueIndex<Value, Index> const &value,
Output const &out) const
{
_callback(predicate, value.index, out);
_callback(predicate, (int)value.index, out);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand that change nor your "a more precise treatment for APIv1" comment.
In any case we will also need to add a comment in the code to explain why we cast.

[[maybe_unused]] int count = 0;
_callback(query, value, [&](OutValue const &ov) {
out_value = ov;
++count;
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this incrementing the counter need to be atomic?

Copy link
Contributor Author
@aprokop aprokop May 21, 2024

Choose a reason for hiding this comment

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

This assumes that each nearest query is executed by a single thread. If that assumption is wrong, we don't have an easy way to check this, unless we create a full view and do atomics.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment to that effect

@aprokop
Copy link
Contributor Author
aprokop commented May 22, 2024

@dalg24 Should have addressed all your comments with one exception.

Regarding atomics, I think it is fine as it is. I did not do atomics, as I think it is fine as it is. The only way I can see us triggering it if we call callbacks on the on-node nearest neighbor search results in parallel. We don't currently do that, nor do we have any plans to do it, as nearest neighbors require priority trees. The only exception to the latter is k = 1 specialization in BruteForce (not currently implemented), but even that would result in a single answer and thus no parallel callback calls for the same query.

@aprokop aprokop requested a review from dalg24 May 22, 2024 15:21
Copy link
Contributor
@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

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

Just a few last comments

[[maybe_unused]] int count = 0;
_callback(query, value, [&](OutValue const &ov) {
out_value = ov;
++count;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment to that effect

@@ -84,7 +84,7 @@ struct LegacyCallbackWrapper
PairValueIndex<Value, Index> const &value,
Output const &out) const
{
_callback(predicate, value.index, out);
_callback(predicate, (int)value.index, out);
Copy link
Contributor

Choose a reason for hiding this comment

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

and you prefer explicit cast than implicit for readability right, it is not needed per se?
(just trying to make sure I understand)

Copy link
Contributor
@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

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

Merge after you add the comments I asked for

@aprokop
Copy link
Contributor Author
aprokop commented May 22, 2024

4 builds (all CUDA and SYCL) timed out, though 2 of them made through the first make+ctest. 3 builds passed. Given that there's been only comment change since 94330e2, I'm comfortable merging this.

@aprokop aprokop merged commit f7f234f into arborx:master May 22, 2024
1 of 2 checks passed
@aprokop aprokop deleted the distributed_nearest_callback branch May 22, 2024 19:16
@aprokop aprokop mentioned this pull request May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0