@@ -34,9 +34,25 @@ void SweepAndPrune::Reserve(std::size_t nPrimitives)
34
34
35
35
namespace pbat {
36
36
namespace gpu {
37
- namespace geometry {
38
37
namespace impl {
38
+ namespace geometry {
39
39
namespace test {
40
+ namespace SweepAndPrune {
41
+
42
+ struct FOnOverlapDetected
43
+ {
44
+ using Overlap = cuda::std::pair<GpuIndex, GpuIndex>;
45
+
46
+ GpuIndex nEdges;
47
+ common::DeviceSynchronizedList<Overlap> o;
48
+ PBAT_DEVICE void operator ()(GpuIndex si, GpuIndex sj)
49
+ {
50
+ if (si < nEdges and sj >= nEdges)
51
+ o.Append (Overlap{si, sj - nEdges});
52
+ if (si >= nEdges and sj < nEdges)
53
+ o.Append (Overlap{sj, si - nEdges});
54
+ }
55
+ };
40
56
41
57
void RunSweepAndPruneTests ()
42
58
{
@@ -102,15 +118,7 @@ void RunSweepAndPruneTests()
102
118
// Act
103
119
gpu::impl::common::SynchronizedList<OverlapType> overlaps (3 * overlapsExpected.size ());
104
120
gpu::impl::geometry::SweepAndPrune sap{};
105
- sap.SortAndSweep (
106
- aabbs,
107
- cuda::proclaim_return_type<void >(
108
- [nEdges, o = overlaps.Raw ()] PBAT_DEVICE (GpuIndex si, GpuIndex sj) mutable {
109
- if (si < nEdges and sj >= nEdges)
110
- o.Append (OverlapType{si, sj - nEdges});
111
- if (si >= nEdges and sj < nEdges)
112
- o.Append (OverlapType{sj, si - nEdges});
113
- }));
121
+ sap.SortAndSweep (aabbs, FOnOverlapDetected{nEdges, overlaps.Raw ()});
114
122
std::vector<OverlapType> overlapsCpu = overlaps.Get ();
115
123
// Assert
116
124
for (OverlapType overlap : overlapsCpu)
@@ -123,13 +131,14 @@ void RunSweepAndPruneTests()
123
131
CHECK (overlapsExpected.empty ());
124
132
}
125
133
134
+ } // namespace SweepAndPrune
126
135
} // namespace test
127
- } // namespace impl
128
136
} // namespace geometry
137
+ } // namespace impl
129
138
} // namespace gpu
130
139
} // namespace pbat
131
140
132
141
TEST_CASE (" [gpu][impl][geometry] Sweep and prune" )
133
142
{
134
- pbat::gpu::geometry::impl ::test::RunSweepAndPruneTests ();
143
+ pbat::gpu::impl::geometry ::test::SweepAndPrune ::RunSweepAndPruneTests ();
135
144
}
0 commit comments