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

Tracking Throughput Measurements, main branch (2024.05.04.) #572

Merged
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
2 changes: 1 addition & 1 deletion examples/options/src/detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ std::ostream& detector::print_impl(std::ostream& out) const {

out << " Detector file : " << detector_file << "\n"
<< " Material file : " << material_file << "\n"
<< " Surface rid file : " << grid_file << "\n"
<< " Surface grid file : " << grid_file << "\n"
<< " Use detray::detector: " << (use_detray_detector ? "yes" : "no")
<< "\n"
<< " Digitization file : " << digitization_file;
Expand Down
82 changes: 73 additions & 9 deletions examples/run/common/throughput_mt.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,25 @@
#include "traccc/options/program_options.hpp"
#include "traccc/options/threading.hpp"
#include "traccc/options/throughput.hpp"
#include "traccc/options/track_finding.hpp"
#include "traccc/options/track_propagation.hpp"
#include "traccc/options/track_seeding.hpp"

// I/O include(s).
#include "traccc/io/demonstrator_edm.hpp"
#include "traccc/io/read.hpp"
#include "traccc/io/read_geometry.hpp"
#include "traccc/io/utils.hpp"

// Performance measurement include(s).
#include "traccc/performance/throughput.hpp"
#include "traccc/performance/timer.hpp"
#include "traccc/performance/timing_info.hpp"

// Detray include(s).
#include "detray/core/detector.hpp"
#include "detray/io/frontend/detector_reader.hpp"

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

Expand Down Expand Up @@ -53,12 +61,14 @@ int throughput_mt(std::string_view description, int argc, char* argv[],
opts::input_data input_opts;
opts::clusterization clusterization_opts;
opts::track_seeding seeding_opts;
opts::track_finding finding_opts;
opts::track_propagation propagation_opts;
opts::throughput throughput_opts;
opts::threading threading_opts;
opts::program_options program_opts{
description,
{detector_opts, input_opts, clusterization_opts, seeding_opts,
throughput_opts, threading_opts},
finding_opts, propagation_opts, throughput_opts, threading_opts},
argc,
argv};

Expand All @@ -75,6 +85,34 @@ int throughput_mt(std::string_view description, int argc, char* argv[],
// Memory resource to use in the test.
HOST_MR uncached_host_mr;

// Read in the geometry.
auto [surface_transforms, barcode_map] = traccc::io::read_geometry(
detector_opts.detector_file,
(detector_opts.use_detray_detector ? traccc::data_format::json
: traccc::data_format::csv));
using detector_type = detray::detector<detray::default_metadata,
detray::host_container_types>;
detector_type detector{uncached_host_mr};
if (detector_opts.use_detray_detector) {
// Set up the detector reader configuration.
detray::io::detector_reader_config cfg;
cfg.add_file(traccc::io::data_directory() +
detector_opts.detector_file);
if (detector_opts.material_file.empty() == false) {
cfg.add_file(traccc::io::data_directory() +
detector_opts.material_file);
}
if (detector_opts.grid_file.empty() == false) {
cfg.add_file(traccc::io::data_directory() +
detector_opts.grid_file);
}

// Read the detector.
auto det =
detray::io::read_detector<detector_type>(uncached_host_mr, cfg);
detector = std::move(det.first);
}

// Read in all input events into memory.
demonstrator_input input(&uncached_host_mr);

Expand All @@ -85,16 +123,38 @@ int throughput_mt(std::string_view description, int argc, char* argv[],
input.push_back(demonstrator_input::value_type(&uncached_host_mr));
}
// Read event data into input vector
io::read(input, input_opts.events, input_opts.directory,
detector_opts.detector_file, detector_opts.digitization_file,
input_opts.format);
io::read(
input, input_opts.events, input_opts.directory,
detector_opts.detector_file, detector_opts.digitization_file,
input_opts.format,
(detector_opts.use_detray_detector ? traccc::data_format::json
: traccc::data_format::csv));
}

// Set up cached memory resources on top of the host memory resource
// separately for each CPU thread.
std::vector<std::unique_ptr<vecmem::binary_page_memory_resource> >
cached_host_mrs{threading_opts.threads + 1};

// Algorithm configuration(s).
typename FULL_CHAIN_ALG::finding_algorithm::config_type finding_cfg;
finding_cfg.min_track_candidates_per_track =
finding_opts.track_candidates_range[0];
finding_cfg.max_track_candidates_per_track =
finding_opts.track_candidates_range[1];
finding_cfg.min_step_length_for_next_surface =
finding_opts.min_step_length_for_next_surface;
finding_cfg.max_step_counts_for_next_surface =
finding_opts.max_step_counts_for_next_surface;
finding_cfg.chi2_max = finding_opts.chi2_max;
finding_cfg.max_num_branches_per_seed = finding_opts.nmax_per_seed;
finding_cfg.max_num_skipping_per_cand =
finding_opts.max_num_skipping_per_cand;
propagation_opts.setup(finding_cfg.propagation);

typename FULL_CHAIN_ALG::fitting_algorithm::config_type fitting_cfg;
propagation_opts.setup(fitting_cfg.propagation);

// Set up the full-chain algorithm(s). One for each thread.
std::vector<FULL_CHAIN_ALG> algs;
algs.reserve(threading_opts.threads + 1);
Expand All @@ -108,11 +168,15 @@ int throughput_mt(std::string_view description, int argc, char* argv[],
? static_cast<vecmem::memory_resource&>(
*(cached_host_mrs.at(i)))
: static_cast<vecmem::memory_resource&>(uncached_host_mr);
algs.push_back({alg_host_mr,
clusterization_opts.target_cells_per_partition,
seeding_opts.seedfinder,
{seeding_opts.seedfinder},
seeding_opts.seedfilter});
algs.push_back(
{alg_host_mr,
clusterization_opts.target_cells_per_partition,
seeding_opts.seedfinder,
{seeding_opts.seedfinder},
seeding_opts.seedfilter,
finding_cfg,
fitting_cfg,
(detector_opts.use_detray_detector ? &detector : nullptr)});
}

// Seed the random number generator.
Expand Down
71 changes: 66 additions & 5 deletions examples/run/common/throughput_st.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,25 @@
#include "traccc/options/input_data.hpp"
#include "traccc/options/program_options.hpp"
#include "traccc/options/throughput.hpp"
#include "traccc/options/track_finding.hpp"
#include "traccc/options/track_propagation.hpp"
#include "traccc/options/track_seeding.hpp"

// I/O include(s).
#include "traccc/io/demonstrator_edm.hpp"
#include "traccc/io/read.hpp"
#include "traccc/io/read_geometry.hpp"
#include "traccc/io/utils.hpp"

// Performance measurement include(s).
#include "traccc/performance/throughput.hpp"
#include "traccc/performance/timer.hpp"
#include "traccc/performance/timing_info.hpp"

// Detray include(s).
#include "detray/core/detector.hpp"
#include "detray/io/frontend/detector_reader.hpp"

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

Expand All @@ -44,11 +52,13 @@ int throughput_st(std::string_view description, int argc, char* argv[],
opts::input_data input_opts;
opts::clusterization clusterization_opts;
opts::track_seeding seeding_opts;
opts::track_finding finding_opts;
opts::track_propagation propagation_opts;
opts::throughput throughput_opts;
opts::program_options program_opts{
description,
{detector_opts, input_opts, clusterization_opts, seeding_opts,
throughput_opts},
finding_opts, propagation_opts, throughput_opts},
argc,
argv};

Expand All @@ -60,6 +70,34 @@ int throughput_st(std::string_view description, int argc, char* argv[],
std::unique_ptr<vecmem::binary_page_memory_resource> cached_host_mr =
std::make_unique<vecmem::binary_page_memory_resource>(uncached_host_mr);

// Read in the geometry.
auto [surface_transforms, barcode_map] = traccc::io::read_geometry(
detector_opts.detector_file,
(detector_opts.use_detray_detector ? traccc::data_format::json
: traccc::data_format::csv));
using detector_type = detray::detector<detray::default_metadata,
detray::host_container_types>;
detector_type detector{uncached_host_mr};
if (detector_opts.use_detray_detector) {
// Set up the detector reader configuration.
detray::io::detector_reader_config cfg;
cfg.add_file(traccc::io::data_directory() +
detector_opts.detector_file);
if (detector_opts.material_file.empty() == false) {
cfg.add_file(traccc::io::data_directory() +
detector_opts.material_file);
}
if (detector_opts.grid_file.empty() == false) {
cfg.add_file(traccc::io::data_directory() +
detector_opts.grid_file);
}

// Read the detector.
auto det =
detray::io::read_detector<detector_type>(uncached_host_mr, cfg);
detector = std::move(det.first);
}

vecmem::memory_resource& alg_host_mr =
use_host_caching
? static_cast<vecmem::memory_resource&>(*cached_host_mr)
Expand All @@ -75,17 +113,40 @@ int throughput_st(std::string_view description, int argc, char* argv[],
input.push_back(demonstrator_input::value_type(&uncached_host_mr));
}
// Read event data into input vector
io::read(input, input_opts.events, input_opts.directory,
detector_opts.detector_file, detector_opts.digitization_file,
input_opts.format);
io::read(
input, input_opts.events, input_opts.directory,
detector_opts.detector_file, detector_opts.digitization_file,
input_opts.format,
(detector_opts.use_detray_detector ? traccc::data_format::json
: traccc::data_format::csv));
}

// Algorithm configuration(s).
typename FULL_CHAIN_ALG::finding_algorithm::config_type finding_cfg;
finding_cfg.min_track_candidates_per_track =
finding_opts.track_candidates_range[0];
finding_cfg.max_track_candidates_per_track =
finding_opts.track_candidates_range[1];
finding_cfg.min_step_length_for_next_surface =
finding_opts.min_step_length_for_next_surface;
finding_cfg.max_step_counts_for_next_surface =
finding_opts.max_step_counts_for_next_surface;
finding_cfg.chi2_max = finding_opts.chi2_max;
finding_cfg.max_num_branches_per_seed = finding_opts.nmax_per_seed;
finding_cfg.max_num_skipping_per_cand =
finding_opts.max_num_skipping_per_cand;
propagation_opts.setup(finding_cfg.propagation);

typename FULL_CHAIN_ALG::fitting_algorithm::config_type fitting_cfg;
propagation_opts.setup(fitting_cfg.propagation);

// Set up the full-chain algorithm.
std::unique_ptr<FULL_CHAIN_ALG> alg = std::make_unique<FULL_CHAIN_ALG>(
alg_host_mr, clusterization_opts.target_cells_per_partition,
seeding_opts.seedfinder,
spacepoint_grid_config{seeding_opts.seedfinder},
seeding_opts.seedfilter);
seeding_opts.seedfilter, finding_cfg, fitting_cfg,
(detector_opts.use_detray_detector ? &detector : nullptr));

// Seed the random number generator.
std::srand(std::time(0));
Expand Down
12 changes: 7 additions & 5 deletions examples/run/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ add_library( traccc_examples_cpu STATIC
"full_chain_algorithm.hpp"
"full_chain_algorithm.cpp" )
target_link_libraries( traccc_examples_cpu
PUBLIC vecmem::core traccc::core )
PUBLIC vecmem::core detray::core detray::utils traccc::core )

traccc_add_executable( throughput_st "throughput_st.cpp"
LINK_LIBRARIES vecmem::core traccc::core traccc::io
traccc::performance traccc::options traccc_examples_cpu )
LINK_LIBRARIES vecmem::core detray::utils detray::io
traccc::core traccc::io traccc::performance
traccc::options traccc_examples_cpu )

traccc_add_executable( throughput_mt "throughput_mt.cpp"
LINK_LIBRARIES TBB::tbb vecmem::core traccc::core traccc::io
traccc::performance traccc::options traccc_examples_cpu )
LINK_LIBRARIES TBB::tbb vecmem::core detray::utils detray::io
traccc::core traccc::io traccc::performance
traccc::options traccc_examples_cpu )
48 changes: 39 additions & 9 deletions examples/run/cpu/full_chain_algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,56 @@ full_chain_algorithm::full_chain_algorithm(
vecmem::memory_resource& mr, unsigned int,
const seedfinder_config& finder_config,
const spacepoint_grid_config& grid_config,
const seedfilter_config& filter_config)
: m_clusterization(mr),
const seedfilter_config& filter_config,
const finding_algorithm::config_type& finding_config,
const fitting_algorithm::config_type& fitting_config,
detector_type* detector)
: m_field_vec{0.f, 0.f, finder_config.bFieldInZ},
m_field(detray::bfield::create_const_field(m_field_vec)),
m_detector(detector),
m_clusterization(mr),
m_spacepoint_formation(mr),
m_seeding(finder_config, grid_config, filter_config, mr),
m_track_parameter_estimation(mr),
m_finding(finding_config),
m_fitting(fitting_config),
m_finder_config(finder_config),
m_grid_config(grid_config),
m_filter_config(filter_config) {}
m_filter_config(filter_config),
m_finding_config(finding_config),
m_fitting_config(fitting_config) {}

full_chain_algorithm::output_type full_chain_algorithm::operator()(
const cell_collection_types::host& cells,
const cell_module_collection_types::host& modules) const {

// Run the clusterization.
const host::clusterization_algorithm::output_type measurements =
m_clusterization(vecmem::get_data(cells), vecmem::get_data(modules));

// Run the seed-finding.
const host::spacepoint_formation_algorithm::output_type spacepoints =
m_spacepoint_formation(
vecmem::get_data(m_clusterization(vecmem::get_data(cells),
vecmem::get_data(modules))),
vecmem::get_data(modules));
return m_track_parameter_estimation(spacepoints, m_seeding(spacepoints),
{0.f, 0.f, m_finder_config.bFieldInZ});
m_spacepoint_formation(vecmem::get_data(measurements),
vecmem::get_data(modules));
const track_params_estimation::output_type track_params =
m_track_parameter_estimation(spacepoints, m_seeding(spacepoints),
m_field_vec);

// If we have a Detray detector, run the track finding and fitting.
if (m_detector != nullptr) {

// Return the final container, after track finding and fitting.
return m_fitting(
*m_detector, m_field,
m_finding(*m_detector, m_field, measurements, track_params));

}
// If not, just return an empty object.
else {

// Return an empty object.
return {};
}
}

} // namespace traccc
Loading
Loading