Skip to content
Snippets Groups Projects

Store indices of children nodes rather than pointer in the bounding volume hierarchy

Merged Arndt, Daniel requested to merge github/fork/dalg24/node_ptr into master

Created by: dalg24

Motivation: this will let us copy trees between host and device and enable checkpoint/restart if that's something we want to get into.

Note that indices are store as ptrdiff_t that has the same size as a pointer so that we do not change the alignment.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Author Owner

    Created by: dalg24

    Have you considered switching from from getBoundingVolume(Node*) to getBoundingVolume(index)

    I have. You need to now about the root so it remains a member function of BVH. I see no advantage in changing at the moment.

    from distance(Node*) to distance(index)?

    We can explore later but same I see no immediate benefit and it is not necessary to achieve the goal of the PR.

    In general, is there a reason to keep Node* usage in many places in the code?

    We can revisit later, this calls for more careful thinking.

  • Author Owner

    Created by: dalg24

    So you did not figure out how to store invalid = -1 in Node?

    I don't have a CUDA build going and this felt not worth fixing. You really want me to look into this?

  • Author Owner

    Created by: aprokop

    @dalg24 The reason I'm asking is that I want to play around with separating the bounding boxes from tree again, and those things would help a lot.

  • Author Owner

    Created by: aprokop

    I don't have a CUDA build going and this felt not worth fixing. You really want me to look into this?

    Not really, was just wondering. Would be nice to have a single -1, instead of 3, but it's not a big deal.

  • Arndt, Daniel
  • Author Owner

    Created by: dalg24

    @dalg24 The reason I'm asking is that I want to play around with separating the bounding boxes from tree again, and those things would help a lot.

    That's orthogonal we do not access the bounding boxes directly through the node.

    $ git grep getBoundingVolume src/details/ArborX_DetailsTreeTraversal.hpp
    src/details/ArborX_DetailsTreeTraversal.hpp:      if (predicate(bvh.getBoundingVolume(bvh.getRoot())))
    src/details/ArborX_DetailsTreeTraversal.hpp:          if (predicate(bvh.getBoundingVolume(child)))
    src/details/ArborX_DetailsTreeTraversal.hpp:                                          bvh.getBoundingVolume(node));
    src/details/ArborX_DetailsTreeTraversal.hpp:          return distance(geometry, bvh.getBoundingVolume(node));
  • Arndt, Daniel
  • Author Owner

    Created by: dalg24

    Blocking this PR until thorough performance testing is done. This affects everything, and we need to make sure it does not introduce performance regression for any of the backends.

    Are you going to take care of this?

  • Author Owner

    Created by: aprokop

    Are you going to take care of this?

    I could, but don't see why I should.

  • Author Owner

    Created by: aprokop

    That's orthogonal we do not access the bounding boxes directly through the node.

    I don't understand. You use getBoundingVolume(Node*) in many places...

  • Author Owner

    Created by: dalg24

    That's orthogonal we do not access the bounding boxes directly through the node.

    I don't understand. You use getBoundingVolume(Node*) in many places...

    Not doing node->bounding_box anywhere, only place that need to change is BVH::getBoundingVolume(Node *).

  • Author Owner

    Created by: aprokop

    Yay, that worked! Can you please post a comment of what you had to do to fix it?

  • Author Owner

    Created by: dalg24

    @aprokop I fixed the memory access violation issues.

  • Arndt, Daniel
    Arndt, Daniel @6da started a thread on commit 9fcd14d3
  • 285 285 std::cout << "ref=" << ref.str() << "\n";
    286 286
    287 287 // hierarchy generation
    288 using ArborX::Box;
    289 using ArborX::Details::makeLeafNode;
    288 290 using ArborX::Details::Node;
    289 291 Kokkos::View<Node *, DeviceType> leaf_nodes("leaf_nodes", n);
    290 292 Kokkos::View<Node *, DeviceType> internal_nodes("internal_nodes", n - 1);
  • Arndt, Daniel
    Arndt, Daniel @6da started a thread on commit 9fcd14d3
  • 285 285 std::cout << "ref=" << ref.str() << "\n";
    286 286
    287 287 // hierarchy generation
    288 using ArborX::Box;
    289 using ArborX::Details::makeLeafNode;
    288 290 using ArborX::Details::Node;
    289 291 Kokkos::View<Node *, DeviceType> leaf_nodes("leaf_nodes", n);
    290 292 Kokkos::View<Node *, DeviceType> internal_nodes("internal_nodes", n - 1);
    • Author Owner

      Created by: dalg24

      It was a hack. I like that we ensure that the routine to generate the hierarchy does not assume that we have that array with the internal nodes and then the leaves.

  • Arndt, Daniel
  • Arndt, Daniel
  • Author Owner

    Created by: aprokop

    Cuda (Summit)

    No difference in timings except for a single case: radius search for filled box/filled ball, where the new version is slightly (~10%) faster (better for larger). NOTE: both labels in plot are CUDA. comparison_radius_search_filled_box

    Serial (Summit)

    For serial, most things are pretty close, though radius search for both filled and hollow variants is consistently slower for all scales by about 3-5%.

    OpenMP (Summit) 42/smt1

    For the most part, little difference. The sticking out thing is radius search for filled box, where the new version is consistently 8% slower. comparison_radius_search_filled_box

  • Author Owner

    Created by: aprokop

    @Rombur @masterleinad Any opinion on this PR?

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading