-
Notifications
You must be signed in to change notification settings - Fork 35
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
Introduce Value as a generic storage in a leaf node #871
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,15 +70,15 @@ struct HappyTreeFriends | |
{ | ||
static_assert( | ||
std::is_same_v<decltype(bvh._internal_nodes(0).bounding_volume), | ||
decltype(bvh._leaf_nodes(0).bounding_volume)>); | ||
return bvh._leaf_nodes(i).bounding_volume; | ||
decltype(bvh._leaf_nodes(0).value.bounding_volume)>); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still want the static assert here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For now. Do you have a better idea or place for it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would have dropped it since this is not something that user input can break but I don't feel too strongly about it. |
||
return bvh._leaf_nodes(i).value.bounding_volume; | ||
} | ||
|
||
template <class BVH> | ||
static KOKKOS_FUNCTION auto getLeafPermutationIndex(BVH const &bvh, int i) | ||
static KOKKOS_FUNCTION auto const &getValue(BVH const &bvh, int i) | ||
{ | ||
assert(i >= 0 && i < (int)bvh.size()); | ||
return bvh._leaf_nodes(i).permutation_index; | ||
return bvh._leaf_nodes(i).value; | ||
} | ||
|
||
template <class BVH> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,24 +17,27 @@ | |
#include <Kokkos_Macros.hpp> | ||
|
||
#include <cassert> | ||
#include <climits> // UINT_MAX | ||
#include <utility> // std::move | ||
|
||
namespace ArborX | ||
{ | ||
namespace Details | ||
namespace ArborX::Details | ||
{ | ||
|
||
constexpr int ROPE_SENTINEL = -1; | ||
|
||
template <class BoundingVolume> | ||
struct PairIndexVolume | ||
{ | ||
unsigned index; | ||
BoundingVolume bounding_volume; | ||
}; | ||
|
||
template <class Value> | ||
struct LeafNode | ||
{ | ||
using bounding_volume_type = BoundingVolume; | ||
using value_type = Value; | ||
|
||
unsigned permutation_index = UINT_MAX; | ||
int rope = ROPE_SENTINEL; | ||
BoundingVolume bounding_volume; | ||
Value value; | ||
}; | ||
|
||
template <class BoundingVolume> | ||
|
@@ -48,14 +51,13 @@ struct InternalNode | |
BoundingVolume bounding_volume; | ||
}; | ||
|
||
template <class BoundingVolume> | ||
KOKKOS_INLINE_FUNCTION constexpr LeafNode<BoundingVolume> | ||
makeLeafNode(unsigned permutation_index, | ||
BoundingVolume bounding_volume) noexcept | ||
template <class Value> | ||
KOKKOS_INLINE_FUNCTION constexpr LeafNode<Value> | ||
makeLeafNode(Value value) noexcept | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like so much spelling the template parameter at the call site but I suppose this way you won't have to change the definition later. |
||
{ | ||
return {permutation_index, ROPE_SENTINEL, std::move(bounding_volume)}; | ||
return {ROPE_SENTINEL, std::move(value)}; | ||
} | ||
} // namespace Details | ||
} // namespace ArborX | ||
|
||
} // namespace ArborX::Details | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yuk. I don't have a better idea though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, would be nice to just have
getValue()
here. If we ever figure out how to move away from storing(index, volume)
together in the future, this would be possible. But right now, it comes with severe penalties.