Skip to content

Commit

Permalink
Move point cloud functions into ArborXBenchmark namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed May 3, 2024
1 parent 1fbee14 commit 170087a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
16 changes: 10 additions & 6 deletions benchmarks/bvh_driver/benchmark_registration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

struct Spec
{
using PointCloudType = ArborXBenchmark::PointCloudType;

std::string backends;
int n_values;
int n_queries;
Expand Down Expand Up @@ -98,7 +100,7 @@ struct Spec

template <typename DeviceType>
Kokkos::View<ArborX::Point *, DeviceType>
constructPoints(int n_values, PointCloudType point_cloud_type)
constructPoints(int n_values, ArborXBenchmark::PointCloudType point_cloud_type)
{
Kokkos::View<ArborX::Point *, DeviceType> random_points(
Kokkos::view_alloc(Kokkos::WithoutInitializing,
Expand All @@ -109,22 +111,23 @@ constructPoints(int n_values, PointCloudType point_cloud_type)
// boxes 2x2x2 centered around a random point) will remain constant as
// problem size is changed.
auto const a = std::cbrt(n_values);
generatePointCloud(point_cloud_type, a, random_points);
ArborXBenchmark::generatePointCloud(point_cloud_type, a, random_points);

return random_points;
}

template <typename DeviceType>
Kokkos::View<decltype(ArborX::intersects(ArborX::Sphere{})) *, DeviceType>
makeSpatialQueries(int n_values, int n_queries, int n_neighbors,
PointCloudType target_point_cloud_type)
ArborXBenchmark::PointCloudType target_point_cloud_type)
{
Kokkos::View<ArborX::Point *, DeviceType> random_points(
Kokkos::view_alloc(Kokkos::WithoutInitializing,
"Benchmark::random_points"),
n_queries);
auto const a = std::cbrt(n_values);
generatePointCloud(target_point_cloud_type, a, random_points);
ArborXBenchmark::generatePointCloud(target_point_cloud_type, a,
random_points);

Kokkos::View<decltype(ArborX::intersects(ArborX::Sphere{})) *, DeviceType>
queries(
Expand All @@ -147,14 +150,15 @@ makeSpatialQueries(int n_values, int n_queries, int n_neighbors,
template <typename DeviceType>
Kokkos::View<ArborX::Nearest<ArborX::Point> *, DeviceType>
makeNearestQueries(int n_values, int n_queries, int n_neighbors,
PointCloudType target_point_cloud_type)
ArborXBenchmark::PointCloudType target_point_cloud_type)
{
Kokkos::View<ArborX::Point *, DeviceType> random_points(
Kokkos::view_alloc(Kokkos::WithoutInitializing,
"Benchmark::random_points"),
n_queries);
auto const a = std::cbrt(n_values);
generatePointCloud(target_point_cloud_type, a, random_points);
ArborXBenchmark::generatePointCloud(target_point_cloud_type, a,
random_points);

Kokkos::View<ArborX::Nearest<ArborX::Point> *, DeviceType> queries(
Kokkos::view_alloc(Kokkos::WithoutInitializing, "Benchmark::queries"),
Expand Down
7 changes: 5 additions & 2 deletions benchmarks/bvh_driver/bvh_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <iostream>

#include "benchmark_registration.hpp"
#include <point_clouds.hpp>

#ifdef ARBORX_PERFORMANCE_TESTING
#include <mpi.h>
Expand Down Expand Up @@ -275,8 +276,10 @@ int main(int argc, char *argv[])
if (vm.count("exact-spec") == 0)
{
single_spec.backends = "all";
single_spec.source_point_cloud_type = to_point_cloud_enum(source_pt_cloud);
single_spec.target_point_cloud_type = to_point_cloud_enum(target_pt_cloud);
single_spec.source_point_cloud_type =
ArborXBenchmark::to_point_cloud_enum(source_pt_cloud);
single_spec.target_point_cloud_type =
ArborXBenchmark::to_point_cloud_enum(target_pt_cloud);
specs.push_back(single_spec);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ int main(int argc, char *argv[])
Kokkos::view_alloc(space, Kokkos::WithoutInitializing,
"Benchmark::points"),
n);
generatePointCloud(PointCloudType::filled_box, std::cbrt(n), random_points);
ArborXBenchmark::generatePointCloud(
ArborXBenchmark::PointCloudType::filled_box, std::cbrt(n), random_points);
Kokkos::Profiling::popRegion();

std::cout << "#triangles : " << triangles.size() << '\n';
Expand Down
22 changes: 16 additions & 6 deletions benchmarks/utils/point_clouds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
* SPDX-License-Identifier: BSD-3-Clause *
****************************************************************************/

#ifndef ARBORX_POINT_CLOUDS_HPP
#define ARBORX_POINT_CLOUDS_HPP
#ifndef ARBORX_BENCHMARK_POINT_CLOUDS_HPP
#define ARBORX_BENCHMARK_POINT_CLOUDS_HPP

#include <ArborX_DetailsKokkosExtAccessibilityTraits.hpp>
#include <ArborX_Exception.hpp>
Expand All @@ -21,6 +21,9 @@
#include <fstream>
#include <random>

namespace ArborXBenchmark
{

enum class PointCloudType
{
filled_box,
Expand All @@ -43,6 +46,9 @@ inline PointCloudType to_point_cloud_enum(std::string const &str)
" doesn't correspond to any known PointCloudType!");
}

namespace Details
{

template <class Point, typename... ViewProperties>
void filledBoxCloud(double const half_edge,
Kokkos::View<Point *, ViewProperties...> random_points)
Expand Down Expand Up @@ -167,6 +173,8 @@ void hollowSphereCloud(double const radius,
}
}

} // namespace Details

template <class Point, typename DeviceType>
void generatePointCloud(PointCloudType const point_cloud_type,
double const length,
Expand All @@ -180,21 +188,23 @@ void generatePointCloud(PointCloudType const point_cloud_type,
switch (point_cloud_type)
{
case PointCloudType::filled_box:
filledBoxCloud(length, random_points_host);
Details::filledBoxCloud(length, random_points_host);
break;
case PointCloudType::hollow_box:
hollowBoxCloud(length, random_points_host);
Details::hollowBoxCloud(length, random_points_host);
break;
case PointCloudType::filled_sphere:
filledSphereCloud(length, random_points_host);
Details::filledSphereCloud(length, random_points_host);
break;
case PointCloudType::hollow_sphere:
hollowSphereCloud(length, random_points_host);
Details::hollowSphereCloud(length, random_points_host);
break;
default:
throw ArborX::SearchException("not implemented");
}
Kokkos::deep_copy(random_points, random_points_host);
}

} // namespace ArborXBenchmark

#endif

0 comments on commit 170087a

Please sign in to comment.