Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into add_tokamak_bench…
Browse files Browse the repository at this point in the history
…mark
  • Loading branch information
masterleinad committed Sep 18, 2023
2 parents 70e92fc + 19696cb commit 2678ec0
Show file tree
Hide file tree
Showing 59 changed files with 1,155 additions and 330 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: github-windows

on: [push, pull_request]

concurrency:
group: ${ {github.event_name }}-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{github.event_name == 'pull_request'}}

jobs:
windows-threads:
name: Windows Threads
runs-on: windows-2022

steps:
- uses: actions/checkout@v3
- name: Install dependencies via vcpkg
uses: johnwason/vcpkg-action@v5
id: vcpkg
with:
pkgs: boost-test boost-program-options boost-geometry benchmark
triplet: x64-windows-release
token: ${{ github.token }}
- uses: actions/checkout@v3
with:
repository: kokkos/kokkos
ref: 4.0.00
path: ${GITHUB_WORKSPACE}/../kokkos
- name: Install Kokkos
shell: bash
working-directory: ${GITHUB_WORKSPACE}/../kokkos
run: |
mkdir build
cd build
cmake -D CMAKE_INSTALL_PREFIX=C:\kokkos-install \
-D Kokkos_ENABLE_THREADS=ON \
..
cmake --build . --target install -- -m
- name: Configure ArborX
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="/EHsc /bigobj" -DKokkos_ROOT="C:\kokkos-install" ${{ steps.vcpkg.outputs.vcpkg-cmake-config }} -DARBORX_ENABLE_MPI=OFF -DARBORX_ENABLE_TESTS=ON -DARBORX_ENABLE_EXAMPLES=ON -DARBORX_ENABLE_BENCHMARKS=ON ..
- name: Build ArborX
shell: bash
run: |
cmake --build build --target install -- -m
cd build
6 changes: 3 additions & 3 deletions .jenkins/continuous.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pipeline {

environment {
CCACHE_DIR = '/tmp/ccache'
CCACHE_MAXSIZE = '10G'
CCACHE_MAXSIZE = '5G'
ARBORX_DIR = '/opt/arborx'
BENCHMARK_COLOR = 'no'
BOOST_TEST_COLOR_OUTPUT = 'no'
Expand Down Expand Up @@ -421,7 +421,7 @@ pipeline {
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_CXX_COMPILER=${DPCPP} \
-D CMAKE_CXX_EXTENSIONS=OFF \
-D CMAKE_CXX_FLAGS="-fp-model=precise -fsycl-device-code-split=per_kernel -Wpedantic -Wall -Wextra -Wno-unknown-cuda-version -Wno-deprecated-declarations" \
-D CMAKE_CXX_FLAGS="-fp-model=precise -fsycl-device-code-split=per_kernel -Wpedantic -Wall -Wextra -Wno-sycl-target -Wno-unknown-cuda-version -Wno-deprecated-declarations" \
-D CMAKE_PREFIX_PATH="$KOKKOS_DIR;$BOOST_DIR;$BENCHMARK_DIR" \
-D ARBORX_ENABLE_MPI=ON \
-D MPIEXEC_PREFLAGS="--allow-run-as-root" \
Expand Down Expand Up @@ -458,7 +458,7 @@ pipeline {
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_CXX_COMPILER=${DPCPP} \
-D CMAKE_CXX_EXTENSIONS=OFF \
-D CMAKE_CXX_FLAGS="-Wno-unknown-cuda-version -Wno-deprecated-declarations" \
-D CMAKE_CXX_FLAGS="-Wno-sycl-target -Wno-unknown-cuda-version -Wno-deprecated-declarations" \
-D CMAKE_PREFIX_PATH="$KOKKOS_DIR;$ARBORX_DIR" \
examples \
'''
Expand Down
43 changes: 42 additions & 1 deletion .jenkins/nightly.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,48 @@ pipeline {
sh 'cmake -S source-kokkos -B build-kokkos -D CMAKE_INSTALL_PREFIX=$PWD/install-kokkos $CMAKE_OPTIONS -D Kokkos_ENABLE_CUDA=ON -D Kokkos_ENABLE_CUDA_LAMBDA=ON'
sh 'cmake --build build-kokkos --parallel 8'
sh 'cmake --install build-kokkos'
sh 'cmake -B build-arborx -D CMAKE_INSTALL_PREFIX=$PWD/install-arborx -D Kokkos_ROOT=$PWD/install-kokkos $CMAKE_OPTIONS -D ARBORX_ENABLE_BENCHMARKS=ON -D ARBORX_ENABLE_TESTS=ON -D ARBORX_ENABLE_EXAMPLES=ON'
// Disable tests as Ubuntu 22.04 comes with Boost 1.74 which causes build issues with CUDA
sh 'cmake -B build-arborx -D CMAKE_INSTALL_PREFIX=$PWD/install-arborx -D Kokkos_ROOT=$PWD/install-kokkos $CMAKE_OPTIONS -D ARBORX_ENABLE_BENCHMARKS=ON -D ARBORX_ENABLE_TESTS=OFF -D ARBORX_ENABLE_EXAMPLES=ON'
sh 'cmake --build build-arborx --parallel 8'
dir('build-arborx') {
sh 'ctest $CTEST_OPTIONS'
}
sh 'cmake --install build-arborx'
sh 'cmake -S examples -B build-examples -D ArborX_ROOT=$PWD/install-arborx -D Kokkos_ROOT=$PWD/install-kokkos $CMAKE_OPTIONS'
sh 'cmake --build build-examples --parallel 8'
dir('build-examples') {
sh 'ctest $CTEST_OPTIONS'
}
}
post {
always {
xunit reduceLog: false, tools:[CTest(deleteOutputFiles: true, failIfNotNew: true, pattern: 'build-*/Testing/**/Test.xml', skipNoTestFiles: false, stopProcessingIfError: true)]
}
}
}
stage('CUDA-12.2.0-MPI') {
agent {
docker {
image 'nvidia/cuda:12.2.0-devel-ubuntu22.04'
label 'NVIDIA_Tesla_V100-PCIE-32GB && nvidia-docker'
}
}
environment {
CTEST_OPTIONS = '--timeout 180 --no-compress-output -T Test'
CMAKE_OPTIONS = '-D CMAKE_BUILD_TYPE=Release -D CMAKE_CXX_STANDARD=17 -D CMAKE_CXX_EXTENSIONS=OFF'
}
steps {
sh 'apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y git cmake libboost-program-options-dev libboost-test-dev libbenchmark-dev libopenmpi-dev'
sh 'rm -rf source* build* install*'
sh 'git clone https://github.com/kokkos/kokkos.git --branch develop --depth 1 source-kokkos'
dir('source-kokkos') {
sh 'git rev-parse --short HEAD'
}
sh 'cmake -S source-kokkos -B build-kokkos -D CMAKE_INSTALL_PREFIX=$PWD/install-kokkos $CMAKE_OPTIONS -D Kokkos_ENABLE_CUDA=ON -D Kokkos_ENABLE_CUDA_LAMBDA=ON'
sh 'cmake --build build-kokkos --parallel 8'
sh 'cmake --install build-kokkos'
// Disable tests as Ubuntu 22.04 comes with Boost 1.74 which causes build issues with CUDA
sh 'cmake -B build-arborx -D CMAKE_INSTALL_PREFIX=$PWD/install-arborx -D Kokkos_ROOT=$PWD/install-kokkos $CMAKE_OPTIONS -D ARBORX_ENABLE_MPI=ON -D MPIEXEC_PREFLAGS="--allow-run-as-root" -D MPIEXEC_MAX_NUMPROCS=4 -D ARBORX_ENABLE_BENCHMARKS=ON -D ARBORX_ENABLE_TESTS=OFF -D ARBORX_ENABLE_EXAMPLES=ON'
sh 'cmake --build build-arborx --parallel 8'
dir('build-arborx') {
sh 'ctest $CTEST_OPTIONS'
Expand Down
11 changes: 8 additions & 3 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ find_package(benchmark 1.5.4 REQUIRED)
message(STATUS "Found benchmark: ${benchmark_DIR} (version \"${benchmark_VERSION}\")")

add_subdirectory(brute_force_vs_bvh)
add_subdirectory(bvh_driver)
add_subdirectory(dbscan)
add_subdirectory(develop)
add_subdirectory(execution_space_instances)
add_subdirectory(tokamak)
add_subdirectory(union_find)
if(NOT WIN32)
# FIXME: for now, skip the benchmarks using Google benchmark
# when building for Windows, as we have trouble linking it
# with the installed version of the Google benchmark
add_subdirectory(bvh_driver)
add_subdirectory(develop)
add_subdirectory(union_find)
endif()

if (ARBORX_ENABLE_MPI)
add_subdirectory(distributed_tree_driver)
Expand Down
74 changes: 46 additions & 28 deletions benchmarks/brute_force_vs_bvh/brute_force_vs_bvh_timpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using MemorySpace = ExecutionSpace::memory_space;

namespace ArborXBenchmark
{
template <int DIM>
template <int DIM, typename FloatingPoint>
struct Placeholder
{
int count;
Expand All @@ -33,17 +33,17 @@ struct Placeholder

// Primitives are a set of points located at (i, i, i),
// with i = 0, ..., n-1
template <int DIM>
struct ArborX::AccessTraits<ArborXBenchmark::Placeholder<DIM>,
template <int DIM, typename FloatingPoint>
struct ArborX::AccessTraits<ArborXBenchmark::Placeholder<DIM, FloatingPoint>,
ArborX::PrimitivesTag>
{
using Primitives = ArborXBenchmark::Placeholder<DIM>;
using Primitives = ArborXBenchmark::Placeholder<DIM, FloatingPoint>;
using memory_space = MemorySpace;
using size_type = typename MemorySpace::size_type;
static KOKKOS_FUNCTION size_type size(Primitives d) { return d.count; }
static KOKKOS_FUNCTION auto get(Primitives, size_type i)
{
ArborX::ExperimentalHyperGeometry::Point<DIM> point;
ArborX::ExperimentalHyperGeometry::Point<DIM, FloatingPoint> point;
for (int d = 0; d < DIM; ++d)
point[d] = i;
return point;
Expand All @@ -52,38 +52,38 @@ struct ArborX::AccessTraits<ArborXBenchmark::Placeholder<DIM>,

// Predicates are sphere intersections with spheres of radius i
// centered at (i, i, i), with i = 0, ..., n-1
template <int DIM>
struct ArborX::AccessTraits<ArborXBenchmark::Placeholder<DIM>,
template <int DIM, typename FloatingPoint>
struct ArborX::AccessTraits<ArborXBenchmark::Placeholder<DIM, FloatingPoint>,
ArborX::PredicatesTag>
{
using Predicates = ArborXBenchmark::Placeholder<DIM>;
using Predicates = ArborXBenchmark::Placeholder<DIM, FloatingPoint>;
using memory_space = MemorySpace;
using size_type = typename MemorySpace::size_type;
static KOKKOS_FUNCTION size_type size(Predicates d) { return d.count; }
static KOKKOS_FUNCTION auto get(Predicates, size_type i)
{
ArborX::ExperimentalHyperGeometry::Point<DIM> center;
ArborX::ExperimentalHyperGeometry::Point<DIM, FloatingPoint> center;
for (int d = 0; d < DIM; ++d)
center[d] = i;
return attach(intersects(ArborX::ExperimentalHyperGeometry::Sphere<DIM>{
center, (float)i}),
i);
return attach(
intersects(
ArborX::ExperimentalHyperGeometry::Sphere<DIM, FloatingPoint>{
center, (FloatingPoint)i}),
i);
}
};

template <int DIM>
void ArborXBenchmark::run(int nprimitives, int nqueries, int nrepeats)
namespace ArborXBenchmark
{
ExecutionSpace space{};
Placeholder<DIM> primitives{nprimitives};
Placeholder<DIM> predicates{nqueries};

printf("Dimension : %d\n", DIM);
printf("Primitives: %d\n", nprimitives);
printf("Predicates: %d\n", nqueries);
printf("Iterations: %d\n", nrepeats);
template <int DIM, typename FloatingPoint>
static void run_fp(int nprimitives, int nqueries, int nrepeats)
{
ExecutionSpace space{};
Placeholder<DIM, FloatingPoint> primitives{nprimitives};
Placeholder<DIM, FloatingPoint> predicates{nqueries};

using Box = ArborX::ExperimentalHyperGeometry::Box<DIM>;
using Box = ArborX::ExperimentalHyperGeometry::Box<DIM, FloatingPoint>;

for (int i = 0; i < nrepeats; i++)
{
Expand All @@ -94,31 +94,49 @@ void ArborXBenchmark::run(int nprimitives, int nqueries, int nrepeats)
MemorySpace, ArborX::Details::PairIndexVolume<Box>>
bvh{space, primitives};

Kokkos::View<int *, ExecutionSpace> indices("indices_ref", 0);
Kokkos::View<int *, ExecutionSpace> offset("offset_ref", 0);
Kokkos::View<int *, ExecutionSpace> indices("Benchmark::indices_ref", 0);
Kokkos::View<int *, ExecutionSpace> offset("Benchmark::offset_ref", 0);
bvh.query(space, predicates, indices, offset);

space.fence();
double time = timer.seconds();
if (i == 0)
printf("Collisions: %.5f\n",
(float)(indices.extent(0)) / (nprimitives * nqueries));
printf("Time BVH: %lf\n", time);
printf("Time BVH : %lf\n", time);
out_count = indices.extent(0);
}

{
Kokkos::Timer timer;
ArborX::BruteForce<MemorySpace, Box> brute{space, primitives};

Kokkos::View<int *, ExecutionSpace> indices("indices", 0);
Kokkos::View<int *, ExecutionSpace> offset("offset", 0);
Kokkos::View<int *, ExecutionSpace> indices("Benchmark::indices", 0);
Kokkos::View<int *, ExecutionSpace> offset("Benchmark::offset", 0);
brute.query(space, predicates, indices, offset);

space.fence();
double time = timer.seconds();
printf("Time BF: %lf\n", time);
printf("Time BF : %lf\n", time);
assert(out_count == indices.extent(0));
}
}
}

template <int DIM>
void run(int nprimitives, int nqueries, int nrepeats)
{
printf("Dimension : %d\n", DIM);
printf("Primitives: %d\n", nprimitives);
printf("Predicates: %d\n", nqueries);
printf("Iterations: %d\n", nrepeats);

printf("-------------------\n");
printf("Precision : float\n");
run_fp<DIM, float>(nprimitives, nqueries, nrepeats);
printf("-------------------\n");
printf("Precision : double\n");
run_fp<DIM, double>(nprimitives, nqueries, nrepeats);
}

} // namespace ArborXBenchmark
32 changes: 19 additions & 13 deletions benchmarks/bvh_driver/benchmark_registration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ Kokkos::View<ArborX::Point *, DeviceType>
constructPoints(int n_values, PointCloudType point_cloud_type)
{
Kokkos::View<ArborX::Point *, DeviceType> random_points(
Kokkos::view_alloc(Kokkos::WithoutInitializing, "random_points"),
Kokkos::view_alloc(Kokkos::WithoutInitializing,
"Benchmark::random_points"),
n_values);
// Generate random points uniformly distributed within a box. The edge
// length of the box chosen such that object density (here objects will be
Expand All @@ -119,21 +120,24 @@ makeSpatialQueries(int n_values, int n_queries, int n_neighbors,
PointCloudType target_point_cloud_type)
{
Kokkos::View<ArborX::Point *, DeviceType> random_points(
Kokkos::view_alloc(Kokkos::WithoutInitializing, "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);

Kokkos::View<decltype(ArborX::intersects(ArborX::Sphere{})) *, DeviceType>
queries(Kokkos::view_alloc(Kokkos::WithoutInitializing, "queries"),
n_queries);
queries(
Kokkos::view_alloc(Kokkos::WithoutInitializing, "Benchmark::queries"),
n_queries);
// Radius is computed so that the number of results per query for a uniformly
// distributed points in a [-a,a]^3 box is approximately n_neighbors.
// Calculation: n_values*(4/3*M_PI*r^3)/(2a)^3 = n_neighbors
double const r = std::cbrt(static_cast<double>(n_neighbors) * 6. / M_PI);
// Calculation: n_values*(4/3*pi*r^3)/(2a)^3 = n_neighbors
double const r = std::cbrt(static_cast<double>(n_neighbors) * 6. /
Kokkos::numbers::pi_v<double>);
using ExecutionSpace = typename DeviceType::execution_space;
Kokkos::parallel_for(
"bvh_driver:setup_radius_search_queries",
"Benchmark::setup_radius_search_queries",
Kokkos::RangePolicy<ExecutionSpace>(0, n_queries), KOKKOS_LAMBDA(int i) {
queries(i) = ArborX::intersects(ArborX::Sphere{random_points(i), r});
});
Expand All @@ -146,16 +150,18 @@ makeNearestQueries(int n_values, int n_queries, int n_neighbors,
PointCloudType target_point_cloud_type)
{
Kokkos::View<ArborX::Point *, DeviceType> random_points(
Kokkos::view_alloc(Kokkos::WithoutInitializing, "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);

Kokkos::View<ArborX::Nearest<ArborX::Point> *, DeviceType> queries(
Kokkos::view_alloc(Kokkos::WithoutInitializing, "queries"), n_queries);
Kokkos::view_alloc(Kokkos::WithoutInitializing, "Benchmark::queries"),
n_queries);
using ExecutionSpace = typename DeviceType::execution_space;
Kokkos::parallel_for(
"bvh_driver:setup_knn_search_queries",
"Benchmark::setup_knn_search_queries",
Kokkos::RangePolicy<ExecutionSpace>(0, n_queries), KOKKOS_LAMBDA(int i) {
queries(i) =
ArborX::nearest<ArborX::Point>(random_points(i), n_neighbors);
Expand Down Expand Up @@ -334,8 +340,8 @@ void BM_knn_search(benchmark::State &state, Spec const &spec)

for (auto _ : state)
{
Kokkos::View<int *, DeviceType> offset("offset", 0);
Kokkos::View<int *, DeviceType> indices("indices", 0);
Kokkos::View<int *, DeviceType> offset("Benchmark::offset", 0);
Kokkos::View<int *, DeviceType> indices("Benchmark::indices", 0);

exec_space.fence();
auto const start = std::chrono::high_resolution_clock::now();
Expand Down Expand Up @@ -370,7 +376,7 @@ void BM_knn_callback_search(benchmark::State &state, Spec const &spec)

for (auto _ : state)
{
Kokkos::View<int *, DeviceType> num_neigh("Testing::num_neigh",
Kokkos::View<int *, DeviceType> num_neigh("Benchmark::num_neigh",
spec.n_queries);
CountCallback<DeviceType> callback{num_neigh};

Expand Down
Loading

0 comments on commit 2678ec0

Please sign in to comment.