Skip to content

Commit

Permalink
Update current benchmarks and add new CPU and CUDA benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
niermann999 committed Dec 9, 2024
1 parent cefce90 commit 492606f
Show file tree
Hide file tree
Showing 24 changed files with 1,180 additions and 468 deletions.
23 changes: 20 additions & 3 deletions core/include/detray/definitions/pdg_particle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,37 @@ struct pdg_particle {
m_charge(static_cast<scalar_t>(charge)) {}

DETRAY_HOST_DEVICE
std::int32_t pdg_num() const { return m_pdg_num; }
constexpr std::int32_t pdg_num() const { return m_pdg_num; }

DETRAY_HOST_DEVICE
scalar_type mass() const { return m_mass; }
constexpr scalar_type mass() const { return m_mass; }

DETRAY_HOST_DEVICE
scalar_type charge() const { return m_charge; }
constexpr scalar_type charge() const { return m_charge; }

private:
std::int32_t m_pdg_num;
scalar_type m_mass;
scalar_type m_charge;
};

/// Apply the charge conjugation operator to a particle hypothesis @param ptc
template <typename scalar_t>
DETRAY_HOST_DEVICE constexpr pdg_particle<scalar_t> charge_conjugation(
const pdg_particle<scalar_t>& ptc) {
return (ptc.charge() != 0)
? detray::pdg_particle<scalar_t>{-ptc.pdg_num(), ptc.mass(),
-ptc.charge()}
: ptc;
}

/// @returns an updated particle hypothesis according to the track qop
template <typename scalar_t, typename track_t>
DETRAY_HOST_DEVICE constexpr pdg_particle<scalar_t> update_particle_hypothesis(
const pdg_particle<scalar_t>& ptc, const track_t& params) {
return (ptc.charge() * params.qop() > 0.f) ? ptc : charge_conjugation(ptc);
}

// Macro for declaring the particle
#define DETRAY_DECLARE_PARTICLE(PARTICLE_NAME, PDG_NUM, MASS, CHARGE) \
template <typename scalar_t> \
Expand Down
3 changes: 3 additions & 0 deletions core/include/detray/propagator/actor_chain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class actor_chain {
public:
/// Types of the actors that are registered in the chain
using actor_list_type = tuple_t<actors_t...>;
// Tuple of actor states
using state_tuple = tuple_t<typename actors_t::state...>;
// Type of states tuple that is used in the propagator
using state = tuple_t<typename actors_t::state &...>;

Expand Down Expand Up @@ -126,6 +128,7 @@ template <>
class actor_chain<> {

public:
using state_tuple = dtuple<>;
/// Empty states replaces a real actor states container
struct state {};

Expand Down
35 changes: 35 additions & 0 deletions tests/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,47 @@
#
# Mozilla Public License Version 2.0

# Set the common C++ flags.
include(detray-compiler-options-cpp)
include_directories(
SYSTEM
$<TARGET_PROPERTY:covfie::core,INTERFACE_INCLUDE_DIRECTORIES>
)
include_directories(
SYSTEM
$<TARGET_PROPERTY:dfelibs::dfelibs,INTERFACE_INCLUDE_DIRECTORIES>
)

# Set up a common benchmark library.
file(
GLOB _detray_benchmarks_headers
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"include/detray/benchmarks/*.hpp"
)

add_library(detray_benchmarks INTERFACE "${_detray_benchmarks_headers}")
add_library(detray::benchmarks ALIAS detray_benchmarks)

target_include_directories(
detray_benchmarks
INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include"
)

target_link_libraries(
detray_benchmarks
INTERFACE benchmark::benchmark vecmem::core detray::core detray::test_utils
)

unset(_detray_benchmarks_headers)

# Set up the host/cpu benchmarks.
if(DETRAY_BUILD_HOST)
add_subdirectory(cpu)
add_subdirectory(include/detray/benchmarks/cpu)
endif()

# Set up all of the "device" benchmarks.
if(DETRAY_BUILD_CUDA)
add_subdirectory(cuda)
add_subdirectory(include/detray/benchmarks/device)
endif()
19 changes: 15 additions & 4 deletions tests/benchmarks/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,20 @@ message(STATUS "Building detray host benchmarks")
option(DETRAY_BENCHMARK_MULTITHREAD "Enable multithreaded benchmarks" OFF)
option(DETRAY_BENCHMARK_PRINTOUTS "Enable printouts in the benchmarks" OFF)

# Look for openMP, which is used for the CPU benchmark
# Look for openMP, which is used for the CPU propagation benchmark
find_package(OpenMP)

# Macro setting up the CPU benchmarks for a specific algebra plugin.
macro(detray_add_cpu_benchmark algebra)
# Build the benchmark executable.
detray_add_executable(benchmark_cpu_${algebra}
"benchmark_propagator.cpp"
"find_volume.cpp"
"grid.cpp"
"grid2.cpp"
"intersect_all.cpp"
"intersect_surfaces.cpp"
"masks.cpp"
LINK_LIBRARIES benchmark::benchmark benchmark::benchmark_main vecmem::core
LINK_LIBRARIES benchmark::benchmark benchmark::benchmark_main vecmem::core detray::benchmarks
detray::core_${algebra} detray::test_utils
)

Expand All @@ -48,9 +47,21 @@ macro(detray_add_cpu_benchmark algebra)
)
endif()

# Build the benchmark executable for the propagation
detray_add_executable( benchmark_cpu_propagation_${algebra}
"propagation.cpp"
LINK_LIBRARIES detray::benchmark_cpu benchmark::benchmark_main
vecmem::core detray::core_${algebra} detray::test_utils
)

target_compile_options(
detray_benchmark_cpu_propagation_${algebra}
PRIVATE "-march=native" "-ftree-vectorize"
)

if(OpenMP_CXX_FOUND)
target_link_libraries(
detray_benchmark_cpu_${algebra}
detray_benchmark_cpu_propagation_${algebra}
PRIVATE OpenMP::OpenMP_CXX
)
endif()
Expand Down
183 changes: 0 additions & 183 deletions tests/benchmarks/cpu/benchmark_propagator.cpp

This file was deleted.

Loading

0 comments on commit 492606f

Please sign in to comment.