Skip to content

Commit 6e14ede

Browse files
committed
Move MinimumSpanningTree and WeightedEdge to Experimenal namespace
1 parent fee3d77 commit 6e14ede

9 files changed

+68
-63
lines changed

benchmarks/dbscan/dbscan_timpl.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ bool ArborXBenchmark::run(ArborXBenchmark::Parameters const &params)
317317
{
318318

319319
Kokkos::Profiling::pushRegion("ArborX::MST::total");
320-
ArborX::Details::MinimumSpanningTree<MemorySpace> mst(
320+
ArborX::Experimental::MinimumSpanningTree<MemorySpace> mst(
321321
exec_space, primitives, params.core_min_size);
322322
Kokkos::Profiling::popRegion();
323323

src/cluster/ArborX_Dendrogram.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct Dendrogram
4444

4545
template <typename ExecutionSpace>
4646
Dendrogram(ExecutionSpace const &exec_space,
47-
Kokkos::View<Details::WeightedEdge *, MemorySpace> edges)
47+
Kokkos::View<Experimental::WeightedEdge *, MemorySpace> edges)
4848
: _parents("ArborX::Dendrogram::parents", 0)
4949
, _parent_heights("ArborX::Dendrogram::parent_heights", 0)
5050
{
@@ -81,7 +81,7 @@ struct Dendrogram
8181
template <typename ExecutionSpace>
8282
void splitEdges(
8383
ExecutionSpace const &exec_space,
84-
Kokkos::View<Details::WeightedEdge *, MemorySpace> edges,
84+
Kokkos::View<Experimental::WeightedEdge *, MemorySpace> edges,
8585
Kokkos::View<Details::UnweightedEdge *, MemorySpace> unweighted_edges,
8686
Kokkos::View<float *, MemorySpace> weights)
8787
{

src/cluster/ArborX_MinimumSpanningTree.hpp

+32-30
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
#include <Kokkos_Core.hpp>
2626
#include <Kokkos_Profiling_ScopedRegion.hpp>
2727

28-
namespace ArborX::Details
28+
namespace ArborX::Experimental
2929
{
3030

31-
template <class MemorySpace, BoruvkaMode Mode = BoruvkaMode::MST>
31+
template <class MemorySpace,
32+
Details::BoruvkaMode Mode = Details::BoruvkaMode::MST>
3233
struct MinimumSpanningTree
3334
{
3435
using memory_space = MemorySpace;
@@ -69,11 +70,11 @@ struct MinimumSpanningTree
6970
bvh.query(
7071
space,
7172
Experimental::attach_indices(Experimental::make_nearest(points, k)),
72-
MaxDistance<Points, decltype(core_distances)>{points,
73-
core_distances});
73+
Details::MaxDistance<Points, decltype(core_distances)>{
74+
points, core_distances});
7475
Kokkos::Profiling::popRegion();
7576

76-
MutualReachability<decltype(core_distances)> mutual_reachability{
77+
Details::MutualReachability<decltype(core_distances)> mutual_reachability{
7778
core_distances};
7879
Kokkos::Profiling::pushRegion("ArborX::MST::boruvka");
7980
doBoruvka(space, bvh, mutual_reachability);
@@ -82,11 +83,11 @@ struct MinimumSpanningTree
8283
else
8384
{
8485
Kokkos::Profiling::pushRegion("ArborX::MST::boruvka");
85-
doBoruvka(space, bvh, Euclidean{});
86+
doBoruvka(space, bvh, Details::Euclidean{});
8687
Kokkos::Profiling::popRegion();
8788
}
8889

89-
finalizeEdges(space, bvh, edges);
90+
Details::finalizeEdges(space, bvh, edges);
9091

9192
Kokkos::Profiling::popRegion();
9293
}
@@ -107,7 +108,7 @@ struct MinimumSpanningTree
107108
Kokkos::view_alloc(space, Kokkos::WithoutInitializing,
108109
"ArborX::MST::tree_parents"),
109110
2 * n - 1);
110-
findParents(space, bvh, tree_parents);
111+
Details::findParents(space, bvh, tree_parents);
111112

112113
Kokkos::Profiling::pushRegion("ArborX::MST::initialize_node_labels");
113114
Kokkos::View<int *, MemorySpace> labels(
@@ -118,7 +119,7 @@ struct MinimumSpanningTree
118119
Kokkos::subview(labels, std::make_pair((decltype(n))0, n)));
119120
Kokkos::Profiling::popRegion();
120121

121-
Kokkos::View<DirectedEdge *, MemorySpace> component_out_edges(
122+
Kokkos::View<Details::DirectedEdge *, MemorySpace> component_out_edges(
122123
Kokkos::view_alloc(space, Kokkos::WithoutInitializing,
123124
"ArborX::MST::component_out_edges"),
124125
n);
@@ -169,7 +170,7 @@ struct MinimumSpanningTree
169170

170171
Kokkos::View<int *, MemorySpace> sided_parents("ArborX::MST::sided_parents",
171172
0);
172-
if constexpr (Mode == BoruvkaMode::HDBSCAN)
173+
if constexpr (Mode == Details::BoruvkaMode::HDBSCAN)
173174
{
174175
KokkosExt::reallocWithoutInitializing(space, edges_mapping, n - 1);
175176
KokkosExt::reallocWithoutInitializing(space, sided_parents, n - 1);
@@ -189,16 +190,16 @@ struct MinimumSpanningTree
189190
std::to_string(num_components));
190191

191192
// Propagate leaf node labels to internal nodes
192-
reduceLabels(space, tree_parents, labels);
193+
Details::reduceLabels(space, tree_parents, labels);
193194

194195
constexpr auto inf = KokkosExt::ArithmeticTraits::infinity<float>::value;
195-
constexpr DirectedEdge uninitialized_edge;
196+
constexpr Details::DirectedEdge uninitialized_edge;
196197
Kokkos::deep_copy(space, component_out_edges, uninitialized_edge);
197198
Kokkos::deep_copy(space, weights, inf);
198199
Kokkos::deep_copy(space, radii, inf);
199200
resetSharedRadii(space, bvh, labels, metric, radii);
200201

201-
FindComponentNearestNeighbors(
202+
Details::FindComponentNearestNeighbors(
202203
space, bvh, labels, weights, component_out_edges, metric, radii,
203204
lower_bounds, std::bool_constant<use_shared_radii>());
204205
retrieveEdges(space, labels, weights, component_out_edges);
@@ -207,48 +208,49 @@ struct MinimumSpanningTree
207208
updateLowerBounds(space, labels, component_out_edges, lower_bounds);
208209
}
209210

210-
UpdateComponentsAndEdges<decltype(labels), decltype(component_out_edges),
211-
decltype(edges), decltype(edges_mapping),
212-
decltype(num_edges), Mode>
211+
Details::UpdateComponentsAndEdges<
212+
decltype(labels), decltype(component_out_edges), decltype(edges),
213+
decltype(edges_mapping), decltype(num_edges), Mode>
213214
f{labels, component_out_edges, edges, edges_mapping, num_edges};
214215

215216
// For every component C and a found shortest edge `(u, w)`, add the
216217
// edge to the list of MST edges.
217218
Kokkos::parallel_for(
218219
"ArborX::MST::update_unidirectional_edges",
219-
Kokkos::RangePolicy<ExecutionSpace, UnidirectionalEdgesTag>(space, 0,
220-
n),
220+
Kokkos::RangePolicy<ExecutionSpace, Details::UnidirectionalEdgesTag>(
221+
space, 0, n),
221222
f);
222223

223224
int num_edges_host;
224225
Kokkos::deep_copy(space, num_edges_host, num_edges);
225226
space.fence();
226227

227-
if constexpr (Mode == BoruvkaMode::HDBSCAN)
228+
if constexpr (Mode == Details::BoruvkaMode::HDBSCAN)
228229
{
229230
Kokkos::parallel_for(
230231
"ArborX::MST::update_bidirectional_edges",
231-
Kokkos::RangePolicy<ExecutionSpace, BidirectionalEdgesTag>(space, 0,
232-
n),
232+
Kokkos::RangePolicy<ExecutionSpace, Details::BidirectionalEdgesTag>(
233+
space, 0, n),
233234
f);
234235

235236
if (iterations > 1)
236-
updateSidedParents(space, labels, edges, edges_mapping, sided_parents,
237-
edges_start, edges_end);
237+
Details::updateSidedParents(space, labels, edges, edges_mapping,
238+
sided_parents, edges_start, edges_end);
238239
else
239240
{
240241
Kokkos::Profiling::ScopedRegion guard(
241242
"ArborX::MST::compute_vertex_parents");
242-
assignVertexParents(space, labels, component_out_edges, edges_mapping,
243-
bvh, dendrogram_parents);
243+
Details::assignVertexParents(space, labels, component_out_edges,
244+
edges_mapping, bvh, dendrogram_parents);
244245
}
245246
}
246247

247248
// For every component C and a found shortest edge `(u, w)`, merge C
248249
// with the component that w belongs to by updating the labels
249250
Kokkos::parallel_for(
250251
"ArborX::MST::update_labels",
251-
Kokkos::RangePolicy<ExecutionSpace, LabelsTag>(space, 0, n), f);
252+
Kokkos::RangePolicy<ExecutionSpace, Details::LabelsTag>(space, 0, n),
253+
f);
252254

253255
num_components = static_cast<int>(n) - num_edges_host;
254256

@@ -267,17 +269,17 @@ struct MinimumSpanningTree
267269
Kokkos::resize(component_out_edges, 0);
268270
Kokkos::resize(tree_parents, 0);
269271

270-
if constexpr (Mode == BoruvkaMode::HDBSCAN)
272+
if constexpr (Mode == Details::BoruvkaMode::HDBSCAN)
271273
{
272274

273275
// Done with the recursion as there are no more alpha edges. Assign
274276
// all current edges to the root chain.
275277
Kokkos::deep_copy(space,
276278
Kokkos::subview(sided_parents,
277279
std::make_pair(edges_start, edges_end)),
278-
ROOT_CHAIN_VALUE);
280+
Details::ROOT_CHAIN_VALUE);
279281

280-
computeParents(space, edges, sided_parents, dendrogram_parents);
282+
Details::computeParents(space, edges, sided_parents, dendrogram_parents);
281283

282284
KokkosExt::reallocWithoutInitializing(space, dendrogram_parent_heights,
283285
n - 1);
@@ -293,6 +295,6 @@ struct MinimumSpanningTree
293295
}
294296
};
295297

296-
} // namespace ArborX::Details
298+
} // namespace ArborX::Experimental
297299

298300
#endif

src/cluster/detail/ArborX_BoruvkaHelpers.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class DirectedEdge
9797
, weight{weight}
9898
{}
9999
KOKKOS_DEFAULTED_FUNCTION constexpr DirectedEdge() = default;
100-
KOKKOS_FUNCTION explicit constexpr operator WeightedEdge()
100+
KOKKOS_FUNCTION explicit constexpr operator Experimental::WeightedEdge()
101101
{
102102
return {source(), target(), weight};
103103
}
@@ -453,7 +453,7 @@ struct UpdateComponentsAndEdges
453453

454454
// append new edge at the "end" of the array (akin to
455455
// std::vector::push_back)
456-
auto const edge = static_cast<WeightedEdge>(_out_edges(i));
456+
auto const edge = static_cast<Experimental::WeightedEdge>(_out_edges(i));
457457
auto const back =
458458
Kokkos::atomic_fetch_inc(&_num_edges()); // atomic post-increment
459459
_edges(back) = edge;

src/cluster/detail/ArborX_WeightedEdge.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <Kokkos_Macros.hpp>
1616
#include <Kokkos_MinMax.hpp>
1717

18-
namespace ArborX::Details
18+
namespace ArborX::Experimental
1919
{
2020

2121
struct WeightedEdge
@@ -48,6 +48,6 @@ struct WeightedEdge
4848
}
4949
};
5050

51-
} // namespace ArborX::Details
51+
} // namespace ArborX::Experimental
5252

5353
#endif

test/tstCompileOnlyWeightedEdges.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static_assert(test_directed_edges()); // avoid warning unused function
4646

4747
KOKKOS_FUNCTION constexpr bool test_weighted_edges()
4848
{
49-
using ArborX::Details::WeightedEdge;
49+
using ArborX::Experimental::WeightedEdge;
5050

5151
static_assert(WeightedEdge{1, 2, 3} < WeightedEdge{1, 2, 4});
5252

test/tstDendrogram.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
BOOST_AUTO_TEST_SUITE(Dendrogram)
2727

28-
using ArborX::Details::WeightedEdge;
28+
using ArborX::Experimental::WeightedEdge;
2929
namespace tt = boost::test_tools;
3030

3131
namespace
@@ -54,7 +54,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(dendrogram_union_find, DeviceType,
5454
ARBORX_DEVICE_TYPES)
5555
{
5656
using ExecutionSpace = typename DeviceType::execution_space;
57-
using ArborX::Details::WeightedEdge;
57+
using ArborX::Experimental::WeightedEdge;
5858

5959
ExecutionSpace space;
6060

@@ -121,7 +121,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(dendrogram_boruvka, DeviceType,
121121
int const n = 3000;
122122
auto points = ArborXTest::make_random_cloud<ArborX::Point<3>>(space, n);
123123

124-
MinimumSpanningTree<MemorySpace, BoruvkaMode::HDBSCAN> mst(space, points);
124+
ArborX::Experimental::MinimumSpanningTree<MemorySpace, BoruvkaMode::HDBSCAN>
125+
mst(space, points);
125126
ArborX::Experimental::Dendrogram<MemorySpace> dendrogram(space, mst.edges);
126127

127128
// Because the dendrogram in the MST is permuted, we need to reorder it in the
@@ -209,8 +210,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(dendrogram_boruvka_same_weights, DeviceType,
209210

210211
// minpts = 5 is the first value that leads to the test failure with N = 4
211212
int const minpts = 5;
212-
MinimumSpanningTree<MemorySpace, BoruvkaMode::HDBSCAN> mst(space, points,
213-
minpts);
213+
ArborX::Experimental::MinimumSpanningTree<MemorySpace, BoruvkaMode::HDBSCAN>
214+
mst(space, points, minpts);
214215
ArborX::Experimental::Dendrogram<MemorySpace> dendrogram(space, mst.edges);
215216

216217
// Check that the dendrogram is binary

0 commit comments

Comments
 (0)