Skip to content

Commit

Permalink
Merge pull request #941 from aprokop/legacy_header
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop authored Aug 30, 2023
2 parents 68d0aff + ea9202f commit f71681b
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 50 deletions.
1 change: 1 addition & 0 deletions src/ArborX_LinearBVH.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <ArborX_DetailsCrsGraphWrapperImpl.hpp>
#include <ArborX_DetailsKokkosExtAccessibilityTraits.hpp>
#include <ArborX_DetailsKokkosExtScopedProfileRegion.hpp>
#include <ArborX_DetailsLegacy.hpp>
#include <ArborX_DetailsNode.hpp>
#include <ArborX_DetailsPermutedData.hpp>
#include <ArborX_DetailsSortUtils.hpp>
Expand Down
13 changes: 0 additions & 13 deletions src/details/ArborX_Callbacks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,19 +208,6 @@ void check_valid_callback(Callback const &callback, Predicates const &)
"Callback 'operator()' return type must be void");
}

template <typename Callback, typename Value>
struct LegacyCallbackWrapper
{
Callback _callback;

template <typename Predicate>
KOKKOS_FUNCTION auto operator()(Predicate const &predicate,
Value const &value) const
{
return _callback(predicate, value.index);
}
};

} // namespace Details
} // namespace ArborX

Expand Down
1 change: 1 addition & 0 deletions src/details/ArborX_DetailsHalfTraversal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <ArborX_Callbacks.hpp> // LegacyCallbackWrapper
#include <ArborX_DetailsHappyTreeFriends.hpp>
#include <ArborX_DetailsLegacy.hpp>
#include <ArborX_DetailsNode.hpp> // ROPE_SENTINEL

#include <Kokkos_Core.hpp>
Expand Down
73 changes: 73 additions & 0 deletions src/details/ArborX_DetailsLegacy.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/****************************************************************************
* Copyright (c) 2023 by the ArborX authors *
* All rights reserved. *
* *
* This file is part of the ArborX library. ArborX is *
* distributed under a BSD 3-clause license. For the licensing terms see *
* the LICENSE file in the top-level directory. *
* *
* SPDX-License-Identifier: BSD-3-Clause *
****************************************************************************/

#ifndef ARBORX_DETAILS_LEGACY_HPP
#define ARBORX_DETAILS_LEGACY_HPP

#include <ArborX_AccessTraits.hpp>
#include <ArborX_DetailsNode.hpp>

namespace ArborX::Details
{

template <typename Primitives, typename BoundingVolume>
class LegacyValues
{
Primitives _primitives;
using Access = AccessTraits<Primitives, PrimitivesTag>;

public:
using memory_space = typename Access::memory_space;
using value_type = Details::PairIndexVolume<BoundingVolume>;
using size_type =
Kokkos::detected_t<Details::AccessTraitsSizeArchetypeExpression, Access,
Primitives>;

LegacyValues(Primitives const &primitives)
: _primitives(primitives)
{}

KOKKOS_FUNCTION
decltype(auto) operator()(size_type i) const
{
if constexpr (std::is_same_v<BoundingVolume,
typename AccessTraitsHelper<Access>::type>)
{
return value_type{(unsigned)i, Access::get(_primitives, i)};
}
else
{
BoundingVolume bounding_volume{};
expand(bounding_volume, Access::get(_primitives, i));
return value_type{(unsigned)i, bounding_volume};
}
}

KOKKOS_FUNCTION
size_type size() const { return Access::size(_primitives); }
};

template <typename Callback, typename Value>
struct LegacyCallbackWrapper
{
Callback _callback;

template <typename Predicate>
KOKKOS_FUNCTION auto operator()(Predicate const &predicate,
Value const &value) const
{
return _callback(predicate, value.index);
}
};

} // namespace ArborX::Details

#endif
37 changes: 0 additions & 37 deletions src/details/ArborX_IndexableGetter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,43 +40,6 @@ struct DefaultIndexableGetter
}
};

template <typename Primitives, typename BoundingVolume>
class LegacyValues
{
Primitives _primitives;
using Access = AccessTraits<Primitives, PrimitivesTag>;

public:
using memory_space = typename Access::memory_space;
using value_type = Details::PairIndexVolume<BoundingVolume>;
using size_type =
Kokkos::detected_t<Details::AccessTraitsSizeArchetypeExpression, Access,
Primitives>;

LegacyValues(Primitives const &primitives)
: _primitives(primitives)
{}

KOKKOS_FUNCTION
decltype(auto) operator()(size_type i) const
{
if constexpr (std::is_same_v<BoundingVolume,
typename AccessTraitsHelper<Access>::type>)
{
return value_type{(unsigned)i, Access::get(_primitives, i)};
}
else
{
BoundingVolume bounding_volume{};
expand(bounding_volume, Access::get(_primitives, i));
return value_type{(unsigned)i, bounding_volume};
}
}

KOKKOS_FUNCTION
size_type size() const { return Access::size(_primitives); }
};

template <typename Primitives>
struct Indexables
{
Expand Down
1 change: 1 addition & 0 deletions test/tstDetailsTreeConstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "ArborX_EnableDeviceTypes.hpp" // ARBORX_DEVICE_TYPES
#include "ArborX_EnableViewComparison.hpp"
#include <ArborX_DetailsAlgorithms.hpp>
#include <ArborX_DetailsLegacy.hpp>
#include <ArborX_DetailsMortonCode.hpp> // expandBits, morton32
#include <ArborX_DetailsNode.hpp> // ROPE SENTINEL
#include <ArborX_DetailsSortUtils.hpp> // sortObjects
Expand Down

0 comments on commit f71681b

Please sign in to comment.