Skip to content

Commit 90b0ce2

Browse files
authored
Merge branch 'main' into main-det-misalign
2 parents 1816ae7 + ac8e293 commit 90b0ce2

24 files changed

+1289
-471
lines changed

core/include/detray/builders/material_map_builder.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ struct add_sf_material_map {
220220

221221
template <typename coll_t, typename index_t, typename mat_factory_t,
222222
typename bin_data_t, std::size_t DIM, typename material_store_t,
223-
typename scalar_t>
223+
concepts::scalar scalar_t>
224224
DETRAY_HOST inline std::pair<typename materials_t::id, dindex> operator()(
225225
[[maybe_unused]] const coll_t& coll,
226226
[[maybe_unused]] const index_t& index,

core/include/detray/definitions/pdg_particle.hpp

+20-3
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,37 @@ struct pdg_particle {
2929
m_charge(static_cast<scalar_t>(charge)) {}
3030

3131
DETRAY_HOST_DEVICE
32-
std::int32_t pdg_num() const { return m_pdg_num; }
32+
constexpr std::int32_t pdg_num() const { return m_pdg_num; }
3333

3434
DETRAY_HOST_DEVICE
35-
scalar_type mass() const { return m_mass; }
35+
constexpr scalar_type mass() const { return m_mass; }
3636

3737
DETRAY_HOST_DEVICE
38-
scalar_type charge() const { return m_charge; }
38+
constexpr scalar_type charge() const { return m_charge; }
3939

4040
private:
4141
std::int32_t m_pdg_num;
4242
scalar_type m_mass;
4343
scalar_type m_charge;
4444
};
4545

46+
/// Apply the charge conjugation operator to a particle hypothesis @param ptc
47+
template <concepts::scalar scalar_t>
48+
DETRAY_HOST_DEVICE constexpr pdg_particle<scalar_t> charge_conjugation(
49+
const pdg_particle<scalar_t>& ptc) {
50+
return (ptc.charge() != 0)
51+
? detray::pdg_particle<scalar_t>{-ptc.pdg_num(), ptc.mass(),
52+
-ptc.charge()}
53+
: ptc;
54+
}
55+
56+
/// @returns an updated particle hypothesis according to the track qop
57+
template <concepts::scalar scalar_t, typename track_t>
58+
DETRAY_HOST_DEVICE constexpr pdg_particle<scalar_t> update_particle_hypothesis(
59+
const pdg_particle<scalar_t>& ptc, const track_t& params) {
60+
return (ptc.charge() * params.qop() > 0.f) ? ptc : charge_conjugation(ptc);
61+
}
62+
4663
// Macro for declaring the particle
4764
#define DETRAY_DECLARE_PARTICLE(PARTICLE_NAME, PDG_NUM, MASS, CHARGE) \
4865
template <concepts::scalar scalar_t> \

core/include/detray/navigation/intersection_kernel.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ struct intersection_update {
134134
/// @return the intersection
135135
template <typename mask_group_t, typename mask_range_t, typename traj_t,
136136
typename intersection_t, typename transform_container_t,
137-
typename scalar_t>
137+
concepts::scalar scalar_t>
138138
DETRAY_HOST_DEVICE inline bool operator()(
139139
const mask_group_t &mask_group, const mask_range_t &mask_range,
140140
const traj_t &traj, intersection_t &sfi,

core/include/detray/propagator/actor_chain.hpp

+14-6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class actor_chain {
3333
public:
3434
/// Types of the actors that are registered in the chain
3535
using actor_list_type = dtuple<actors_t...>;
36+
// Tuple of actor states
37+
using state_tuple = dtuple<typename actors_t::state...>;
3638
// Type of states tuple that is used in the propagator
3739
using state = dtuple<typename actors_t::state &...>;
3840

@@ -52,8 +54,7 @@ class actor_chain {
5254
return m_actors;
5355
}
5456

55-
/// @returns a tuple of default constructible actor states and a
56-
/// corresponding tuple of references
57+
/// @returns a tuple of default constructible actor states
5758
DETRAY_HOST_DEVICE
5859
static constexpr auto make_actor_states() {
5960
// Only possible if each state is default initializable
@@ -66,10 +67,10 @@ class actor_chain {
6667
}
6768

6869
/// @returns a tuple of reference for every state in the tuple @param t
69-
DETRAY_HOST_DEVICE static constexpr state make_ref_tuple(
70+
DETRAY_HOST_DEVICE static constexpr state setup_actor_states(
7071
dtuple<typename actors_t::state...> &t) {
71-
return make_ref_tuple(t,
72-
std::make_index_sequence<sizeof...(actors_t)>{});
72+
return setup_actor_states(
73+
t, std::make_index_sequence<sizeof...(actors_t)>{});
7374
}
7475

7576
private:
@@ -110,7 +111,7 @@ class actor_chain {
110111

111112
/// @returns a tuple of reference for every state in the tuple @param t
112113
template <std::size_t... indices>
113-
DETRAY_HOST_DEVICE static constexpr state make_ref_tuple(
114+
DETRAY_HOST_DEVICE static constexpr state setup_actor_states(
114115
dtuple<typename actors_t::state...> &t,
115116
std::index_sequence<indices...> /*ids*/) {
116117
return detray::tie(detail::get<indices>(t)...);
@@ -125,6 +126,7 @@ template <>
125126
class actor_chain<> {
126127

127128
public:
129+
using state_tuple = dtuple<>;
128130
/// Empty states replaces a real actor states container
129131
struct state {};
130132

@@ -137,6 +139,12 @@ class actor_chain<> {
137139
propagator_state_t & /*p_state*/) const {
138140
/*Do nothing*/
139141
}
142+
143+
/// @returns an empty state
144+
DETRAY_HOST_DEVICE static constexpr state setup_actor_states(
145+
const state_tuple &) {
146+
return {};
147+
}
140148
};
141149

142150
} // namespace detray

tests/benchmarks/CMakeLists.txt

+35
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,47 @@
44
#
55
# Mozilla Public License Version 2.0
66

7+
# Set the common C++ flags.
8+
include(detray-compiler-options-cpp)
9+
include_directories(
10+
SYSTEM
11+
$<TARGET_PROPERTY:covfie::core,INTERFACE_INCLUDE_DIRECTORIES>
12+
)
13+
include_directories(
14+
SYSTEM
15+
$<TARGET_PROPERTY:dfelibs::dfelibs,INTERFACE_INCLUDE_DIRECTORIES>
16+
)
17+
18+
# Set up a common benchmark library.
19+
file(
20+
GLOB _detray_benchmarks_headers
21+
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
22+
"include/detray/benchmarks/*.hpp"
23+
)
24+
25+
add_library(detray_benchmarks INTERFACE "${_detray_benchmarks_headers}")
26+
add_library(detray::benchmarks ALIAS detray_benchmarks)
27+
28+
target_include_directories(
29+
detray_benchmarks
30+
INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include"
31+
)
32+
33+
target_link_libraries(
34+
detray_benchmarks
35+
INTERFACE benchmark::benchmark vecmem::core detray::core detray::test_utils
36+
)
37+
38+
unset(_detray_benchmarks_headers)
39+
740
# Set up the host/cpu benchmarks.
841
if(DETRAY_BUILD_HOST)
942
add_subdirectory(cpu)
43+
add_subdirectory(include/detray/benchmarks/cpu)
1044
endif()
1145

1246
# Set up all of the "device" benchmarks.
1347
if(DETRAY_BUILD_CUDA)
1448
add_subdirectory(cuda)
49+
add_subdirectory(include/detray/benchmarks/device)
1550
endif()

tests/benchmarks/cpu/CMakeLists.txt

+15-4
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,20 @@ message(STATUS "Building detray host benchmarks")
1010
option(DETRAY_BENCHMARK_MULTITHREAD "Enable multithreaded benchmarks" OFF)
1111
option(DETRAY_BENCHMARK_PRINTOUTS "Enable printouts in the benchmarks" OFF)
1212

13-
# Look for openMP, which is used for the CPU benchmark
13+
# Look for openMP, which is used for the CPU propagation benchmark
1414
find_package(OpenMP)
1515

1616
# Macro setting up the CPU benchmarks for a specific algebra plugin.
1717
macro(detray_add_cpu_benchmark algebra)
1818
# Build the benchmark executable.
1919
detray_add_executable(benchmark_cpu_${algebra}
20-
"benchmark_propagator.cpp"
2120
"find_volume.cpp"
2221
"grid.cpp"
2322
"grid2.cpp"
2423
"intersect_all.cpp"
2524
"intersect_surfaces.cpp"
2625
"masks.cpp"
27-
LINK_LIBRARIES benchmark::benchmark benchmark::benchmark_main vecmem::core
26+
LINK_LIBRARIES benchmark::benchmark benchmark::benchmark_main vecmem::core detray::benchmarks
2827
detray::core_${algebra} detray::test_utils
2928
)
3029

@@ -48,9 +47,21 @@ macro(detray_add_cpu_benchmark algebra)
4847
)
4948
endif()
5049

50+
# Build the benchmark executable for the propagation
51+
detray_add_executable( benchmark_cpu_propagation_${algebra}
52+
"propagation.cpp"
53+
LINK_LIBRARIES detray::benchmark_cpu benchmark::benchmark_main
54+
vecmem::core detray::core_${algebra} detray::test_utils
55+
)
56+
57+
target_compile_options(
58+
detray_benchmark_cpu_propagation_${algebra}
59+
PRIVATE "-march=native" "-ftree-vectorize"
60+
)
61+
5162
if(OpenMP_CXX_FOUND)
5263
target_link_libraries(
53-
detray_benchmark_cpu_${algebra}
64+
detray_benchmark_cpu_propagation_${algebra}
5465
PRIVATE OpenMP::OpenMP_CXX
5566
)
5667
endif()

tests/benchmarks/cpu/benchmark_propagator.cpp

-182
This file was deleted.

0 commit comments

Comments
 (0)