Skip to content

Commit 2164d92

Browse files
mimodekjaerMark BrettellMarkMark BrettellFabrice Le Goff
authored
GBTS seeding example (#1286)
* Add GBTS options for mt runner * setting up gbts algs in full_chain cpu/cuda compilation * GBTS working in the mt * adding placeholders for backends without GBTS impl * formatting and placeholders for sycl alpaka * testing with extra compiler flags * formatting * reverting extra compilation flags * removing submodule * more itk_throughput tyding * sign conversion and array type fixes * rebase fixes * reabse fixes and adding GBTS to full_chain seeding * formatting * reorder arguments * fixes and adding asserts to alpaka and sycl * changing asserts to print statments * add unused to gbts config * update GBTS not implemented logging * fix logger * formatting * fixed: forgotten rebase conflict * revert to triplet_seeding_alg output type for the common seed type * GBTS seeding example Adding the seeding example for the ability to run physics performance testing on the GBTS algorithm. This is building on PR-1194 and PR-1284. * Adding throughput st to make baseline performance optimisations, and testing for that * Adding seq_example for testing * VecMem Update, main branch (2026.04.10.) (#1291) * Updated the project to vecmem 1.24.0. * Switched to creating detector design buffers more easily. Using the code that's now available from vecmem directly. * GBTS example changes I have add the cuda seeding and seq example, while extending the thoughput_st to also have the option for GBTS * reformating I just ran pre-commit * gbts runtime error if input is missing I have just added a small check to see if the files exists, so it throws a proper error instead of a seg fault * GBTS cleanup Here i have cleaned the code a bit so there should be no more wrong changes * gbts formating I forgot to run precommit again --------- Co-authored-by: Mark Brettell <mbrettel@lxplus902.cern.ch> Co-authored-by: Mark <markbrettel@cern.ch> Co-authored-by: Mark Brettell <egi71871@hepacc09.pp.rl.ac.uk> Co-authored-by: Fabrice Le Goff <fabrice.le.goff@cern.ch> Co-authored-by: Attila Krasznahorkay <30694331+krasznaa@users.noreply.github.com>
1 parent f081805 commit 2164d92

4 files changed

Lines changed: 70 additions & 26 deletions

File tree

examples/options/src/track_gbts_seeding.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,12 @@ void track_gbts_seeding::read(const boost::program_options::variables_map &) {
167167
std::vector<std::pair<int, std::vector<int>>> binTables;
168168
traccc::device::gbts_layerInfo layerInfo;
169169

170-
std::ifstream barcodeBinningFile(
171-
std::filesystem::path(config_dir + "/barcodeBinning.txt"));
170+
auto barcodeBinningPath =
171+
std::filesystem::path(config_dir + "/barcodeBinning.txt");
172+
if (!std::filesystem::exists(barcodeBinningPath)) {
173+
throw std::runtime_error("barcodeBinning.txt file not found");
174+
}
175+
std::ifstream barcodeBinningFile(barcodeBinningPath);
172176

173177
unsigned int nBarcodes = 0;
174178
barcodeBinningFile >> nBarcodes;
@@ -182,8 +186,11 @@ void track_gbts_seeding::read(const boost::program_options::variables_map &) {
182186
barcodeBinning.push_back(barcodeLayerPair);
183187
}
184188

185-
std::ifstream binTablesFile(
186-
std::filesystem::path(config_dir + "/binTables.txt"));
189+
auto binTablesPath = std::filesystem::path(config_dir + "/binTables.txt");
190+
if (!std::filesystem::exists(binTablesPath)) {
191+
throw std::runtime_error("binTables.txt file not found");
192+
}
193+
std::ifstream binTablesFile(binTablesPath);
187194

188195
unsigned int nBinPairs = 0;
189196
binTablesFile >> nBinPairs;
@@ -196,8 +203,11 @@ void track_gbts_seeding::read(const boost::program_options::variables_map &) {
196203
binTables.emplace_back(bin1, bin2);
197204
}
198205

199-
std::ifstream layerInfoFile(
200-
std::filesystem::path(config_dir + "/layerInfo.txt"));
206+
auto layerInfoPath = std::filesystem::path(config_dir + "/layerInfo.txt");
207+
if (!std::filesystem::exists(layerInfoPath)) {
208+
throw std::runtime_error("layerInfo.txt file not found");
209+
}
210+
std::ifstream layerInfoFile(layerInfoPath);
201211

202212
unsigned int nLayers = 0;
203213
layerInfoFile >> nLayers;

examples/run/common/include/traccc/examples/impl/throughput_st.ipp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ int throughput_st(std::string_view description, int argc, char* argv[]) {
6767
opts::input_data input_opts;
6868
opts::clusterization clusterization_opts;
6969
opts::track_seeding seeding_opts;
70+
opts::track_gbts_seeding seeding_gbts_opts;
7071
opts::track_finding finding_opts;
7172
opts::track_propagation propagation_opts;
7273
opts::track_fitting fitting_opts;
@@ -75,8 +76,8 @@ int throughput_st(std::string_view description, int argc, char* argv[]) {
7576
opts::program_options program_opts{
7677
description,
7778
{detector_opts, bfield_opts, input_opts, clusterization_opts,
78-
seeding_opts, finding_opts, propagation_opts, fitting_opts,
79-
throughput_opts, logging_opts},
79+
seeding_opts, seeding_gbts_opts, finding_opts, propagation_opts,
80+
fitting_opts, throughput_opts, logging_opts},
8081
argc,
8182
argv,
8283
prelogger->cloneWithSuffix("Options")};
@@ -132,7 +133,7 @@ int throughput_st(std::string_view description, int argc, char* argv[]) {
132133
const traccc::seedfinder_config seedfinder_config(seeding_opts);
133134
const traccc::seedfilter_config seedfilter_config(seeding_opts);
134135
const traccc::spacepoint_grid_config spacepoint_grid_config(seeding_opts);
135-
traccc::gbts_seedfinder_config gbts_config;
136+
const traccc::gbts_seedfinder_config gbts_config(seeding_gbts_opts);
136137
const traccc::track_params_estimation_config track_params_estimation_config;
137138

138139
typename FULL_CHAIN_ALG::finding_algorithm::config_type finding_cfg(
@@ -148,7 +149,7 @@ int throughput_st(std::string_view description, int argc, char* argv[]) {
148149
host_mr, clustering_cfg, seedfinder_config, spacepoint_grid_config,
149150
seedfilter_config, gbts_config, track_params_estimation_config,
150151
finding_cfg, fitting_cfg, det_descr, det_cond, field, &detector,
151-
logger().clone("FullChainAlg"));
152+
logger().clone("FullChainAlg"), seeding_gbts_opts.useGBTS);
152153

153154
// Seed the random number generator.
154155
if (throughput_opts.random_seed == 0) {

examples/run/cuda/apps/seeding_example_cuda.cpp

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
#include <vecmem/utils/cuda/async_copy.hpp>
6060
#include <vecmem/utils/cuda/copy.hpp>
6161

62+
#include "traccc/cuda/gbts_seeding/gbts_seeding_algorithm.hpp"
63+
#include "traccc/gbts_seeding/gbts_seeding_config.hpp"
64+
#include "traccc/options/track_gbts_seeding.hpp"
65+
6266
// System include(s).
6367
#include <exception>
6468
#include <iomanip>
@@ -67,6 +71,7 @@
6771
using namespace traccc;
6872

6973
int seq_run(const traccc::opts::track_seeding& seeding_opts,
74+
const traccc::opts::track_gbts_seeding& seeding_gbts_opts,
7075
const traccc::opts::track_finding& finding_opts,
7176
const traccc::opts::track_propagation& propagation_opts,
7277
[[maybe_unused]] const traccc::opts::track_fitting& fitting_opts,
@@ -78,7 +83,7 @@ int seq_run(const traccc::opts::track_seeding& seeding_opts,
7883
const traccc::opts::truth_finding& truth_finding_opts,
7984
const traccc::opts::seed_matching& seed_matching_opts,
8085
const traccc::opts::track_matching& track_matching_opts,
81-
std::unique_ptr<const traccc::Logger> ilogger) {
86+
std::unique_ptr<const traccc::Logger> ilogger, bool usingGBTS) {
8287
TRACCC_LOCAL_LOGGER(std::move(ilogger));
8388

8489
// Memory resources used by the application.
@@ -156,6 +161,8 @@ int seq_run(const traccc::opts::track_seeding& seeding_opts,
156161
const traccc::detector_buffer detector_buffer =
157162
traccc::buffer_from_host_detector(host_det, mng_mr, host_copy);
158163

164+
// GBTS seeding configuration
165+
const traccc::gbts_seedfinder_config gbts_config(seeding_gbts_opts);
159166
// Seeding algorithm
160167
const traccc::seedfinder_config seedfinder_config(seeding_opts);
161168
const traccc::seedfilter_config seedfilter_config(seeding_opts);
@@ -180,6 +187,8 @@ int seq_run(const traccc::opts::track_seeding& seeding_opts,
180187
async_copy,
181188
stream,
182189
logger().clone("CudaSeedingAlg")};
190+
traccc::cuda::gbts_seeding_algorithm gbts_sa_cuda(
191+
gbts_config, mr, copy, stream, logger().clone("CudaGbtsSeedingAlg"));
183192
traccc::cuda::seed_parameter_estimation_algorithm tp_cuda{
184193
track_params_estimation_config, mr, async_copy, stream,
185194
logger().clone("CudaTrackParEstAlg")};
@@ -264,7 +273,12 @@ int seq_run(const traccc::opts::track_seeding& seeding_opts,
264273
{
265274
traccc::performance::timer t("Seeding (cuda)", elapsedTimes);
266275
// Reconstruct the spacepoints into seeds.
267-
seeds_cuda_buffer = sa_cuda(spacepoints_cuda_buffer);
276+
if (usingGBTS) {
277+
seeds_cuda_buffer = gbts_sa_cuda(spacepoints_cuda_buffer,
278+
measurements_cuda_buffer);
279+
} else {
280+
seeds_cuda_buffer = sa_cuda(spacepoints_cuda_buffer);
281+
}
268282
stream.synchronize();
269283
} // stop measuring seeding cuda timer
270284

@@ -452,6 +466,7 @@ int main(int argc, char* argv[]) {
452466
traccc::opts::magnetic_field bfield_opts;
453467
traccc::opts::input_data input_opts;
454468
traccc::opts::track_seeding seeding_opts;
469+
traccc::opts::track_gbts_seeding seeding_gbts_opts;
455470
traccc::opts::track_finding finding_opts;
456471
traccc::opts::track_propagation propagation_opts;
457472
traccc::opts::track_fitting fitting_opts;
@@ -462,16 +477,18 @@ int main(int argc, char* argv[]) {
462477
traccc::opts::track_matching track_matching_opts;
463478
traccc::opts::program_options program_opts{
464479
"Full Tracking Chain Using CUDA (without clusterization)",
465-
{detector_opts, bfield_opts, input_opts, seeding_opts, finding_opts,
466-
propagation_opts, fitting_opts, performance_opts, accelerator_opts,
467-
truth_finding_opts, seed_matching_opts, track_matching_opts},
480+
{detector_opts, bfield_opts, input_opts, seeding_opts,
481+
seeding_gbts_opts, finding_opts, propagation_opts, fitting_opts,
482+
performance_opts, accelerator_opts, truth_finding_opts,
483+
seed_matching_opts, track_matching_opts},
468484
argc,
469485
argv,
470486
logger->cloneWithSuffix("Options")};
471487

472488
// Run the application.
473-
return seq_run(seeding_opts, finding_opts, propagation_opts, fitting_opts,
474-
input_opts, detector_opts, bfield_opts, performance_opts,
475-
accelerator_opts, truth_finding_opts, seed_matching_opts,
476-
track_matching_opts, logger->clone());
489+
return seq_run(seeding_opts, seeding_gbts_opts, finding_opts,
490+
propagation_opts, fitting_opts, input_opts, detector_opts,
491+
bfield_opts, performance_opts, accelerator_opts,
492+
truth_finding_opts, seed_matching_opts, track_matching_opts,
493+
logger->clone(), seeding_gbts_opts.useGBTS);
477494
}

examples/run/cuda/apps/seq_example_cuda.cpp

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "traccc/cuda/clusterization/measurement_sorting_algorithm.hpp"
1414
#include "traccc/cuda/finding/combinatorial_kalman_filter_algorithm.hpp"
1515
#include "traccc/cuda/fitting/kalman_fitting_algorithm.hpp"
16+
#include "traccc/cuda/gbts_seeding/gbts_seeding_algorithm.hpp"
1617
#include "traccc/cuda/seeding/seed_parameter_estimation_algorithm.hpp"
1718
#include "traccc/cuda/seeding/silicon_pixel_spacepoint_formation_algorithm.hpp"
1819
#include "traccc/cuda/seeding/triplet_seeding_algorithm.hpp"
@@ -23,6 +24,7 @@
2324
#include "traccc/examples/make_magnetic_field.hpp"
2425
#include "traccc/finding/combinatorial_kalman_filter_algorithm.hpp"
2526
#include "traccc/fitting/kalman_fitting_algorithm.hpp"
27+
#include "traccc/gbts_seeding/gbts_seeding_config.hpp"
2628
#include "traccc/geometry/detector.hpp"
2729
#include "traccc/geometry/detector_buffer.hpp"
2830
#include "traccc/geometry/host_detector.hpp"
@@ -39,6 +41,7 @@
3941
#include "traccc/options/program_options.hpp"
4042
#include "traccc/options/track_finding.hpp"
4143
#include "traccc/options/track_fitting.hpp"
44+
#include "traccc/options/track_gbts_seeding.hpp"
4245
#include "traccc/options/track_propagation.hpp"
4346
#include "traccc/options/track_resolution.hpp"
4447
#include "traccc/options/track_seeding.hpp"
@@ -68,13 +71,14 @@ int seq_run(const traccc::opts::detector& detector_opts,
6871
const traccc::opts::input_data& input_opts,
6972
const traccc::opts::clusterization& clusterization_opts,
7073
const traccc::opts::track_seeding& seeding_opts,
74+
const traccc::opts::track_gbts_seeding& seeding_gbts_opts,
7175
const traccc::opts::track_finding& finding_opts,
7276
const traccc::opts::track_propagation& propagation_opts,
7377
const traccc::opts::track_resolution& resolution_opts,
7478
const traccc::opts::track_fitting& fitting_opts,
7579
const traccc::opts::performance& performance_opts,
7680
const traccc::opts::accelerator& accelerator_opts,
77-
std::unique_ptr<const traccc::Logger> ilogger) {
81+
std::unique_ptr<const traccc::Logger> ilogger, bool usingGBTS) {
7882
TRACCC_LOCAL_LOGGER(std::move(ilogger));
7983

8084
// Memory resources used by the application.
@@ -172,6 +176,9 @@ int seq_run(const traccc::opts::detector& detector_opts,
172176
const traccc::seedfilter_config seedfilter_config(seeding_opts);
173177
const traccc::spacepoint_grid_config spacepoint_grid_config(seeding_opts);
174178

179+
// GBTS seeding configuration
180+
traccc::gbts_seedfinder_config gbts_config(seeding_gbts_opts);
181+
175182
traccc::finding_config finding_cfg(finding_opts);
176183
finding_cfg.propagation = propagation_config;
177184

@@ -219,6 +226,8 @@ int seq_run(const traccc::opts::detector& detector_opts,
219226
traccc::cuda::triplet_seeding_algorithm sa_cuda(
220227
seedfinder_config, spacepoint_grid_config, seedfilter_config, mr, copy,
221228
stream, logger().clone("CudaSeedingAlg"));
229+
traccc::cuda::gbts_seeding_algorithm gbts_sa_cuda(
230+
gbts_config, mr, copy, stream, logger().clone("CudaGbtsSeedingAlg"));
222231
traccc::cuda::seed_parameter_estimation_algorithm tp_cuda(
223232
track_params_estimation_config, mr, copy, stream,
224233
logger().clone("CudaTrackParEstAlg"));
@@ -332,7 +341,12 @@ int seq_run(const traccc::opts::detector& detector_opts,
332341
// CUDA
333342
{
334343
traccc::performance::timer t("Seeding (cuda)", elapsedTimes);
335-
seeds_cuda_buffer = sa_cuda(spacepoints_cuda_buffer);
344+
if (usingGBTS) {
345+
seeds_cuda_buffer = gbts_sa_cuda(spacepoints_cuda_buffer,
346+
measurements_cuda_buffer);
347+
} else {
348+
seeds_cuda_buffer = sa_cuda(spacepoints_cuda_buffer);
349+
}
336350
stream.synchronize();
337351
} // stop measuring seeding cuda timer
338352

@@ -593,6 +607,7 @@ int main(int argc, char* argv[]) {
593607
traccc::opts::input_data input_opts;
594608
traccc::opts::clusterization clusterization_opts;
595609
traccc::opts::track_seeding seeding_opts;
610+
traccc::opts::track_gbts_seeding seeding_gbts_opts;
596611
traccc::opts::track_finding finding_opts;
597612
traccc::opts::track_propagation propagation_opts;
598613
traccc::opts::track_resolution resolution_opts;
@@ -602,15 +617,16 @@ int main(int argc, char* argv[]) {
602617
traccc::opts::program_options program_opts{
603618
"Full Tracking Chain Using CUDA",
604619
{detector_opts, bfield_opts, input_opts, clusterization_opts,
605-
seeding_opts, finding_opts, propagation_opts, resolution_opts,
606-
performance_opts, fitting_opts, accelerator_opts},
620+
seeding_opts, seeding_gbts_opts, finding_opts, propagation_opts,
621+
resolution_opts, performance_opts, fitting_opts, accelerator_opts},
607622
argc,
608623
argv,
609624
logger->cloneWithSuffix("Options")};
610625

611626
// Run the application.
612627
return seq_run(detector_opts, bfield_opts, input_opts, clusterization_opts,
613-
seeding_opts, finding_opts, propagation_opts,
614-
resolution_opts, fitting_opts, performance_opts,
615-
accelerator_opts, logger->clone());
628+
seeding_opts, seeding_gbts_opts, finding_opts,
629+
propagation_opts, resolution_opts, fitting_opts,
630+
performance_opts, accelerator_opts, logger->clone(),
631+
seeding_gbts_opts.useGBTS);
616632
}

0 commit comments

Comments
 (0)