Skip to content

Commit fbc411c

Browse files
committed
Used name function object as thrust callable
1 parent 23dee88 commit fbc411c

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

source/pbat/gpu/impl/geometry/SweepAndPrune.cu

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,25 @@ void SweepAndPrune::Reserve(std::size_t nPrimitives)
3434

3535
namespace pbat {
3636
namespace gpu {
37-
namespace geometry {
3837
namespace impl {
38+
namespace geometry {
3939
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+
};
4056

4157
void RunSweepAndPruneTests()
4258
{
@@ -102,15 +118,7 @@ void RunSweepAndPruneTests()
102118
// Act
103119
gpu::impl::common::SynchronizedList<OverlapType> overlaps(3 * overlapsExpected.size());
104120
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()});
114122
std::vector<OverlapType> overlapsCpu = overlaps.Get();
115123
// Assert
116124
for (OverlapType overlap : overlapsCpu)
@@ -123,13 +131,14 @@ void RunSweepAndPruneTests()
123131
CHECK(overlapsExpected.empty());
124132
}
125133

134+
} // namespace SweepAndPrune
126135
} // namespace test
127-
} // namespace impl
128136
} // namespace geometry
137+
} // namespace impl
129138
} // namespace gpu
130139
} // namespace pbat
131140

132141
TEST_CASE("[gpu][impl][geometry] Sweep and prune")
133142
{
134-
pbat::gpu::geometry::impl::test::RunSweepAndPruneTests();
143+
pbat::gpu::impl::geometry::test::SweepAndPrune::RunSweepAndPruneTests();
135144
}

0 commit comments

Comments
 (0)