You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
v1 is equivalent to v2 with hardcoded ValueType = int and Indexable = Box.
// The purpose of the LegacyIndexableGetter is to convert Primitives to Boxes that we then hold on.template<typename MemorySpace>
structLegacyIndexableGetter
{
using value_type = int;
using indexable_type = Box;
Kokkos::View<Box*, MemorySpace> _boxes;
template <typename ExecutionSpace, typename Primitives>
LegacyIndexableGetter(ExecutionSpace const& exec_space, Primitives const& primitives)
: _boxes(AccessTraits<Primitives, PrimitivesTag>::size(primitives))
{
using Access = AccessTraits<Primitives, PrimitivesTag>;
using Type = std::decay_t<declval(Access::get(std::declval<Primitives>(), std::declval<size_t>()))>;
if (Kokkos::is_view<Primitives>::value && std::is_same<Type, Box>{})
{
// Shorcut if Primitives is a View of boxes
_boxes = primitives;
}
else
{
autoconst n = Access::size(primitives);
Kokkos::parallel_for(Kokkos::RangePolicy<ExecutionSpace>(0, n),
KOKKOS_LAMBDA(intconst i) {
_boxes(i) += Access::get(primitives, i);
});
}
}
KOKKOS_FUNCTION indexable_type const& operator()(int i) { return_boxes(i); }
};
// The purpose of LegacyIota is to be able to specialize RangeAdaptorclassLegacyIota
{
private:using value_type = int;
using size_type = size_t;
size_type _size;
public:LegacyIota(size_type size) : _size(size) { }
KOKKOS_FUNCTION size_type size() const { return _size; }
KOKKOS_FUNCTION value_type operator()(size_type index) const { returnindex; }
};
template <>
RangeAdaptor<LegacyIota>
{
using Container = LegacyIota;
using memory_space = typename Container::memory_space;
using value_type = typename Container::value_type;
using size_type = typename Container::size_type;
KOKKOS_FUNCTION static size_type size(Container const& container) { return container.size(); }
KOKKOS_FUNCTION static value_type get(Container const& container, size_type index) { returncontainer(index); }
};
template <typename MemorySpace>
classBoundingVolumeHierarchy : publicLBVH<MemorySpace, int, LegacyIndexableGetter<MemorySpace>> {
private:using base_type = LBVH<MemorySpace, int, LegacyIndexableGetter<MemorySpace>>;
public:template <typename ExecutionSpace, typename Primitives>
BoundingVolumeHierarchy(ExecutionSpace const& exec_space, Primitives const &primitives)
: base_type(exec_space,
LegacyIota(AccessTraits<Primitives, PrimitivesTag>::size(primitives)),
LegacyIndexableGetter(primitives))
{ }
template <typename ExecutionSpace, typename Predicates, typename Callback>
voidquery(ExecutionSpace const &exec_space, Predicates const &predicates, Callback const &callback)
{
base_type::query(exec_space, predicates, callback);
}
};
Examples
Examples demonstrating how one would use the proposed interface in certain situations
Find all points within certain distance
Description: Given a cloud of points and a radius r, for every point find all points within distance r from it.
Applications: HACC, LAMPPS
Find a cell that point belongs to
Description: Given a mesh and a cloud of points, for every point find a mesh cell it belongs to.
Applications: DTK, ExaWind
Find k closest neighbors and distances to them
Description: Given two clouds of points, for ever point find k nearest
neighbors and compute a quantity based on values of those k points weighted by
distances.
Applications: DTK, machine learning
Force calculation
Description: Given a cloud of points, compute a force for every point. Computation of force to distant nodes is replaced by computing a force to internal nodes (that contains the center and mass of its descendants).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
API v2 design idea
TODO
Remaining items that probably need to be addressed:
Range adaptor
Indexable getter
Callbacks
LBVH
API v1 to API v2 adaptation
v1 is equivalent to v2 with hardcoded
ValueType = int
andIndexable = Box
.Examples
Examples demonstrating how one would use the proposed interface in certain situations
Find all points within certain distance
Description: Given a cloud of points and a radius r, for every point find all points within distance r from it.
Applications: HACC, LAMPPS
Find a cell that point belongs to
Description: Given a mesh and a cloud of points, for every point find a mesh cell it belongs to.
Applications: DTK, ExaWind
Find k closest neighbors and distances to them
Description: Given two clouds of points, for ever point find k nearest
neighbors and compute a quantity based on values of those k points weighted by
distances.
Applications: DTK, machine learning
Force calculation
Description: Given a cloud of points, compute a force for every point. Computation of force to distant nodes is replaced by computing a force to internal nodes (that contains the center and mass of its descendants).
Applications: HACC
Beta Was this translation helpful? Give feedback.
All reactions