Skip to content

Commit

Permalink
Updated the example applications for the modified "options code".
Browse files Browse the repository at this point in the history
Made all of the applications print their configuration parameters
in a uniform way, using the helper code introduced with the
"options code".
  • Loading branch information
krasznaa committed Mar 5, 2024
1 parent b341d05 commit 6c87150
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 70 deletions.
21 changes: 13 additions & 8 deletions examples/run/cpu/seeding_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
using namespace traccc;
namespace po = boost::program_options;

int seq_run(const traccc::seeding_input_config& /*i_cfg*/,
const traccc::finding_input_config<traccc::scalar>& finding_cfg,
const traccc::propagation_options<traccc::scalar>& propagation_opts,
int seq_run(const traccc::seeding_input_options& /*i_cfg*/,
const traccc::finding_input_options& finding_cfg,
const traccc::propagation_options& propagation_opts,
const traccc::common_options& common_opts,
const traccc::detector_input_options& det_opts) {

Expand Down Expand Up @@ -272,9 +272,9 @@ int main(int argc, char* argv[]) {
desc.add_options()("help,h", "Give some help with the program's options");
traccc::common_options common_opts(desc);
traccc::detector_input_options det_opts(desc);
traccc::seeding_input_config seeding_input_cfg(desc);
traccc::finding_input_config<traccc::scalar> finding_input_cfg(desc);
traccc::propagation_options<traccc::scalar> propagation_opts(desc);
traccc::seeding_input_options seeding_input_cfg(desc);
traccc::finding_input_options finding_input_cfg(desc);
traccc::propagation_options propagation_opts(desc);

po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
Expand All @@ -289,8 +289,13 @@ int main(int argc, char* argv[]) {
finding_input_cfg.read(vm);
propagation_opts.read(vm);

std::cout << "Running " << argv[0] << " " << det_opts.detector_file << " "
<< common_opts.input_directory << " " << common_opts.events
// Tell the user what's happening.
std::cout << "\nRunning the tracking chain on the host\n\n"
<< common_opts << "\n"
<< det_opts << "\n"
<< seeding_input_cfg << "\n"
<< finding_input_cfg << "\n"
<< propagation_opts << "\n"
<< std::endl;

return seq_run(seeding_input_cfg, finding_input_cfg, propagation_opts,
Expand Down
12 changes: 7 additions & 5 deletions examples/run/cpu/seq_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

namespace po = boost::program_options;

int seq_run(const traccc::full_tracking_input_config& i_cfg,
int seq_run(const traccc::full_tracking_input_options& i_cfg,
const traccc::common_options& common_opts,
const traccc::detector_input_options& det_opts) {

Expand Down Expand Up @@ -162,7 +162,7 @@ int main(int argc, char* argv[]) {
desc.add_options()("help,h", "Give some help with the program's options");
traccc::common_options common_opts(desc);
traccc::detector_input_options det_opts(desc);
traccc::full_tracking_input_config full_tracking_input_cfg(desc);
traccc::full_tracking_input_options full_tracking_input_cfg(desc);

po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
Expand All @@ -175,9 +175,11 @@ int main(int argc, char* argv[]) {
det_opts.read(vm);
full_tracking_input_cfg.read(vm);

std::cout << "Running " << argv[0] << " "
<< full_tracking_input_cfg.detector_file << " "
<< common_opts.input_directory << " " << common_opts.events
// Tell the user what's happening.
std::cout << "\nRunning the full tracking chain on the host\n\n"
<< common_opts << "\n"
<< det_opts << "\n"
<< full_tracking_input_cfg << "\n"
<< std::endl;

return seq_run(full_tracking_input_cfg, common_opts, det_opts);
Expand Down
17 changes: 11 additions & 6 deletions examples/run/cpu/truth_finding_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
using namespace traccc;
namespace po = boost::program_options;

int seq_run(const traccc::finding_input_config<traccc::scalar>& i_cfg,
const traccc::propagation_options<scalar>& propagation_opts,
int seq_run(const traccc::finding_input_options& i_cfg,
const traccc::propagation_options& propagation_opts,
const traccc::common_options& common_opts,
const traccc::detector_input_options& det_opts) {

Expand Down Expand Up @@ -203,8 +203,8 @@ int main(int argc, char* argv[]) {
desc.add_options()("help,h", "Give some help with the program's options");
traccc::common_options common_opts(desc);
traccc::detector_input_options det_opts(desc);
traccc::finding_input_config<traccc::scalar> finding_input_cfg(desc);
traccc::propagation_options<scalar> propagation_opts(desc);
traccc::finding_input_options finding_input_cfg(desc);
traccc::propagation_options propagation_opts(desc);

po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
Expand All @@ -218,8 +218,13 @@ int main(int argc, char* argv[]) {
finding_input_cfg.read(vm);
propagation_opts.read(vm);

std::cout << "Running " << argv[0] << " " << common_opts.input_directory
<< " " << common_opts.events << std::endl;
// Tell the user what's happening.
std::cout << "\nRunning truth track finding on the host\n\n"
<< common_opts << "\n"
<< det_opts << "\n"
<< finding_input_cfg << "\n"
<< propagation_opts << "\n"
<< std::endl;

return seq_run(finding_input_cfg, propagation_opts, common_opts, det_opts);
}
10 changes: 7 additions & 3 deletions examples/run/cpu/truth_fitting_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int main(int argc, char* argv[]) {
desc.add_options()("help,h", "Give some help with the program's options");
traccc::common_options common_opts(desc);
traccc::detector_input_options det_opts(desc);
traccc::propagation_options<scalar> propagation_opts(desc);
traccc::propagation_options propagation_opts(desc);

po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
Expand All @@ -64,8 +64,12 @@ int main(int argc, char* argv[]) {

propagation_opts.read(vm);

std::cout << "Running " << argv[0] << " " << common_opts.input_directory
<< " " << common_opts.events << std::endl;
// Tell the user what's happening.
std::cout << "\nRunning truth track fitting on the host\n\n"
<< common_opts << "\n"
<< det_opts << "\n"
<< propagation_opts << "\n"
<< std::endl;

/// Type declarations
using host_detector_type = detray::detector<detray::default_metadata,
Expand Down
21 changes: 13 additions & 8 deletions examples/run/cuda/seeding_example_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
using namespace traccc;
namespace po = boost::program_options;

int seq_run(const traccc::seeding_input_config& /*i_cfg*/,
const traccc::finding_input_config<traccc::scalar>& finding_cfg,
const traccc::propagation_options<traccc::scalar>& propagation_opts,
int seq_run(const traccc::seeding_input_options& /*i_cfg*/,
const traccc::finding_input_options& finding_cfg,
const traccc::propagation_options& propagation_opts,
const traccc::common_options& common_opts,
const traccc::detector_input_options& det_opts, bool run_cpu) {

Expand Down Expand Up @@ -485,9 +485,9 @@ int main(int argc, char* argv[]) {
desc.add_options()("help,h", "Give some help with the program's options");
traccc::common_options common_opts(desc);
traccc::detector_input_options det_opts(desc);
traccc::seeding_input_config seeding_input_cfg(desc);
traccc::finding_input_config<traccc::scalar> finding_input_cfg(desc);
traccc::propagation_options<traccc::scalar> propagation_opts(desc);
traccc::seeding_input_options seeding_input_cfg(desc);
traccc::finding_input_options finding_input_cfg(desc);
traccc::propagation_options propagation_opts(desc);
desc.add_options()("run-cpu", po::value<bool>()->default_value(false),
"run cpu tracking as well");

Expand All @@ -505,8 +505,13 @@ int main(int argc, char* argv[]) {
propagation_opts.read(vm);
auto run_cpu = vm["run-cpu"].as<bool>();

std::cout << "Running " << argv[0] << " " << det_opts.detector_file << " "
<< common_opts.input_directory << " " << common_opts.events
// Tell the user what's happening.
std::cout << "\nRunning the tracking chain using CUDA\n\n"
<< common_opts << "\n"
<< det_opts << "\n"
<< seeding_input_cfg << "\n"
<< finding_input_cfg << "\n"
<< propagation_opts << "\n"
<< std::endl;

return seq_run(seeding_input_cfg, finding_input_cfg, propagation_opts,
Expand Down
12 changes: 7 additions & 5 deletions examples/run/cuda/seq_example_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

namespace po = boost::program_options;

int seq_run(const traccc::full_tracking_input_config& i_cfg,
int seq_run(const traccc::full_tracking_input_options& i_cfg,
const traccc::common_options& common_opts,
const traccc::detector_input_options& det_opts, bool run_cpu) {

Expand Down Expand Up @@ -308,7 +308,7 @@ int main(int argc, char* argv[]) {
desc.add_options()("help,h", "Give some help with the program's options");
traccc::common_options common_opts(desc);
traccc::detector_input_options det_opts(desc);
traccc::full_tracking_input_config full_tracking_input_cfg(desc);
traccc::full_tracking_input_options full_tracking_input_cfg(desc);
desc.add_options()("run-cpu", po::value<bool>()->default_value(false),
"run cpu tracking as well");

Expand All @@ -324,9 +324,11 @@ int main(int argc, char* argv[]) {
full_tracking_input_cfg.read(vm);
auto run_cpu = vm["run-cpu"].as<bool>();

std::cout << "Running " << argv[0] << " "
<< full_tracking_input_cfg.detector_file << " "
<< common_opts.input_directory << " " << common_opts.events
// Tell the user what's happening.
std::cout << "\nRunning the full tracking chain using CUDA\n\n"
<< common_opts << "\n"
<< det_opts << "\n"
<< full_tracking_input_cfg << "\n"
<< std::endl;

return seq_run(full_tracking_input_cfg, common_opts, det_opts, run_cpu);
Expand Down
17 changes: 11 additions & 6 deletions examples/run/cuda/truth_finding_example_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
using namespace traccc;
namespace po = boost::program_options;

int seq_run(const traccc::finding_input_config<traccc::scalar>& i_cfg,
const traccc::propagation_options<scalar>& propagation_opts,
int seq_run(const traccc::finding_input_options& i_cfg,
const traccc::propagation_options& propagation_opts,
const traccc::common_options& common_opts,
const traccc::detector_input_options& det_opts, bool run_cpu) {

Expand Down Expand Up @@ -360,8 +360,8 @@ int main(int argc, char* argv[]) {
desc.add_options()("help,h", "Give some help with the program's options");
traccc::common_options common_opts(desc);
traccc::detector_input_options det_opts(desc);
traccc::finding_input_config<traccc::scalar> finding_input_cfg(desc);
traccc::propagation_options<scalar> propagation_opts(desc);
traccc::finding_input_options finding_input_cfg(desc);
traccc::propagation_options propagation_opts(desc);
desc.add_options()("run-cpu", po::value<bool>()->default_value(false),
"run cpu tracking as well");

Expand All @@ -379,8 +379,13 @@ int main(int argc, char* argv[]) {
propagation_opts.read(vm);
auto run_cpu = vm["run-cpu"].as<bool>();

std::cout << "Running " << argv[0] << " " << common_opts.input_directory
<< " " << common_opts.events << std::endl;
// Tell the user what's happening.
std::cout << "\nRunning truth track finding using CUDA\n\n"
<< common_opts << "\n"
<< det_opts << "\n"
<< finding_input_cfg << "\n"
<< propagation_opts << "\n"
<< std::endl;

return seq_run(finding_input_cfg, propagation_opts, common_opts, det_opts,
run_cpu);
Expand Down
10 changes: 7 additions & 3 deletions examples/run/cuda/truth_fitting_example_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int main(int argc, char* argv[]) {
desc.add_options()("help,h", "Give some help with the program's options");
traccc::common_options common_opts(desc);
traccc::detector_input_options det_opts(desc);
traccc::propagation_options<scalar> propagation_opts(desc);
traccc::propagation_options propagation_opts(desc);
desc.add_options()("run-cpu", po::value<bool>()->default_value(false),
"run cpu tracking as well");

Expand All @@ -78,8 +78,12 @@ int main(int argc, char* argv[]) {
propagation_opts.read(vm);
auto run_cpu = vm["run-cpu"].as<bool>();

std::cout << "Running " << argv[0] << " " << common_opts.input_directory
<< " " << common_opts.events << std::endl;
// Tell the user what's happening.
std::cout << "\nRunning truth track fitting using CUDA\n\n"
<< common_opts << "\n"
<< det_opts << "\n"
<< propagation_opts << "\n"
<< std::endl;

/// Type declarations
using host_detector_type = detray::detector<detray::default_metadata,
Expand Down
11 changes: 7 additions & 4 deletions examples/run/sycl/seeding_example_sycl.sycl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

namespace po = boost::program_options;

int seq_run(const traccc::seeding_input_config& /*i_cfg*/,
int seq_run(const traccc::seeding_input_options& /*i_cfg*/,
const traccc::common_options& common_opts,
const traccc::detector_input_options& det_opts, bool run_cpu) {

Expand Down Expand Up @@ -279,7 +279,7 @@ int main(int argc, char* argv[]) {
desc.add_options()("help,h", "Give some help with the program's options");
traccc::common_options common_opts(desc);
traccc::detector_input_options det_opts(desc);
traccc::seeding_input_config seeding_input_cfg(desc);
traccc::seeding_input_options seeding_input_cfg(desc);
desc.add_options()("run-cpu", po::value<bool>()->default_value(false),
"run cpu tracking as well");

Expand All @@ -296,8 +296,11 @@ int main(int argc, char* argv[]) {
seeding_input_cfg.read(vm);
auto run_cpu = vm["run-cpu"].as<bool>();

std::cout << "Running " << argv[0] << " " << det_opts.detector_file << " "
<< common_opts.input_directory << " " << common_opts.events
// Tell the user what's happening.
std::cout << "\nRunning the tracking chain using SYCL\n\n"
<< common_opts << "\n"
<< det_opts << "\n"
<< seeding_input_cfg << "\n"
<< std::endl;

return seq_run(seeding_input_cfg, common_opts, det_opts, run_cpu);
Expand Down
14 changes: 8 additions & 6 deletions examples/run/sycl/seq_example_sycl.sycl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ auto handle_async_error = [](::sycl::exception_list elist) {
}
};

int seq_run(const traccc::full_tracking_input_config& i_cfg,
int seq_run(const traccc::full_tracking_input_options& i_cfg,
const traccc::common_options& common_opts,
const traccc::detector_input_options& det_opts, bool run_cpu) {

Expand Down Expand Up @@ -334,7 +334,7 @@ int main(int argc, char* argv[]) {
desc.add_options()("help,h", "Give some help with the program's options");
traccc::common_options common_opts(desc);
traccc::detector_input_options det_opts(desc);
traccc::full_tracking_input_config full_tracking_input_cfg(desc);
traccc::full_tracking_input_options full_tracking_input_cfg(desc);
desc.add_options()("run-cpu", po::value<bool>()->default_value(false),
"run cpu tracking as well");

Expand All @@ -350,10 +350,12 @@ int main(int argc, char* argv[]) {
full_tracking_input_cfg.read(vm);
auto run_cpu = vm["run-cpu"].as<bool>();

std::cout << "Running " << argv[0] << " "
<< full_tracking_input_cfg.detector_file << " "
<< common_opts.input_directory << " " << common_opts.events
// Tell the user what's happening.
std::cout << "\nRunning the full tracking chain using SYCL\n\n"
<< common_opts << "\n"
<< det_opts << "\n"
<< full_tracking_input_cfg << "\n"
<< std::endl;

return seq_run(full_tracking_input_cfg, common_opts, det_opts, run_cpu);
}
}
4 changes: 2 additions & 2 deletions examples/simulation/simulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ int main(int argc, char* argv[]) {
desc.add_options()("events", po::value<unsigned int>()->required(),
"number of events");
traccc::detector_input_options det_opts(desc);
traccc::particle_gen_options<scalar> pg_opts(desc);
traccc::propagation_options<scalar> propagation_opts(desc);
traccc::particle_gen_options pg_opts(desc);
traccc::propagation_options propagation_opts(desc);

po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
Expand Down
12 changes: 6 additions & 6 deletions examples/simulation/simulate_telescope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ using namespace traccc;
namespace po = boost::program_options;

int simulate(std::string output_directory, unsigned int events,
const traccc::particle_gen_options<scalar>& pg_opts,
const traccc::propagation_options<scalar>& propagation_opts,
const traccc::telescope_detector_options<scalar>& telescope_opts) {
const traccc::particle_gen_options& pg_opts,
const traccc::propagation_options& propagation_opts,
const traccc::telescope_detector_options& telescope_opts) {

// Use deterministic random number generator for testing
using uniform_gen_t =
Expand Down Expand Up @@ -153,9 +153,9 @@ int main(int argc, char* argv[]) {
"specify the directory of output data");
desc.add_options()("events", po::value<unsigned int>()->required(),
"number of events");
traccc::particle_gen_options<scalar> pg_opts(desc);
traccc::propagation_options<scalar> propagation_opts(desc);
traccc::telescope_detector_options<scalar> telescope_opts(desc);
traccc::particle_gen_options pg_opts(desc);
traccc::propagation_options propagation_opts(desc);
traccc::telescope_detector_options telescope_opts(desc);

po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
Expand Down
Loading

0 comments on commit 6c87150

Please sign in to comment.