Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: Measure wall time in multithreaded benchmark and reduce number of events #872

Merged
merged 2 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions benchmarks/common/benchmarks/toy_detector_benchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@

// Detray include(s).
#include <detray/detectors/bfield.hpp>
#include <detray/io/frontend/detector_reader.hpp>
#include <detray/io/frontend/detector_writer.hpp>
#include <detray/navigation/navigator.hpp>
#include <detray/propagator/propagator.hpp>
#include <detray/propagator/rk_stepper.hpp>
#include <detray/test/utils/detectors/build_toy_detector.hpp>
#include <detray/test/utils/simulation/event_generator/track_generators.hpp>
#include <detray/tracks/ray.hpp>
Expand All @@ -42,8 +38,11 @@ class ToyDetectorBenchmark : public benchmark::Fixture {
// VecMem memory resource(s)
vecmem::host_memory_resource host_mr;

static const int n_events = 100u;
static const int n_tracks = 5000u;
// TODO: This causes a segmentation fault
// static const int n_events = 100u;
// static const int n_tracks = 5000u;
static const int n_events = 50u;
static const int n_tracks = 10000u;

std::vector<traccc::spacepoint_collection_types::host> spacepoints;
std::vector<traccc::measurement_collection_types::host> measurements;
Expand Down
8 changes: 3 additions & 5 deletions benchmarks/cpu/toy_detector_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,16 @@
#include "benchmarks/toy_detector_benchmark.hpp"

// Detray include(s).
#include <detray/core/detector.hpp>
#include <detray/detectors/bfield.hpp>
#include <detray/io/frontend/detector_reader.hpp>
#include <detray/navigation/navigator.hpp>
#include <detray/propagator/propagator.hpp>
#include <detray/propagator/rk_stepper.hpp>

// VecMem include(s).
#include <vecmem/memory/host_memory_resource.hpp>

// Google benchmark include(s).
#include <benchmark/benchmark.h>

BENCHMARK_F(ToyDetectorBenchmark, CPU)(benchmark::State& state) {
BENCHMARK_DEFINE_F(ToyDetectorBenchmark, CPU)(benchmark::State& state) {

// Type declarations
using host_detector_type = traccc::default_detector::host;
Expand Down Expand Up @@ -88,3 +84,5 @@ BENCHMARK_F(ToyDetectorBenchmark, CPU)(benchmark::State& state) {
state.counters["event_throughput_Hz"] = benchmark::Counter(
static_cast<double>(n_events), benchmark::Counter::kIsRate);
}

BENCHMARK_REGISTER_F(ToyDetectorBenchmark, CPU)->UseRealTime();
6 changes: 3 additions & 3 deletions benchmarks/cuda/toy_detector_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
#include "benchmarks/toy_detector_benchmark.hpp"

// Detray include(s).
#include <detray/core/detector.hpp>
#include <detray/detectors/bfield.hpp>
#include <detray/io/frontend/detector_reader.hpp>
#include <detray/navigation/navigator.hpp>
#include <detray/propagator/propagator.hpp>
#include <detray/propagator/rk_stepper.hpp>

// VecMem include(s).
Expand All @@ -39,7 +37,7 @@
// Google benchmark include(s).
#include <benchmark/benchmark.h>

BENCHMARK_F(ToyDetectorBenchmark, CUDA)(benchmark::State& state) {
BENCHMARK_DEFINE_F(ToyDetectorBenchmark, CUDA)(benchmark::State& state) {

// Type declarations
using rk_stepper_type = detray::rk_stepper<
Expand Down Expand Up @@ -163,3 +161,5 @@ BENCHMARK_F(ToyDetectorBenchmark, CUDA)(benchmark::State& state) {
state.counters["event_throughput_Hz"] = benchmark::Counter(
static_cast<double>(n_events), benchmark::Counter::kIsRate);
}

BENCHMARK_REGISTER_F(ToyDetectorBenchmark, CUDA)->UseRealTime();
Loading