From 27b23eeb46f59bfdced503e11bf96f6351c57e7e Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Tue, 19 Oct 2021 17:50:31 -0400 Subject: [PATCH] Add new `--version` option to benchmark executables. --- nvbench/option_parser.cu | 18 ++++++++++++++++++ nvbench/option_parser.cuh | 1 + 2 files changed, 19 insertions(+) diff --git a/nvbench/option_parser.cu b/nvbench/option_parser.cu index 3f162af..35b47af 100644 --- a/nvbench/option_parser.cu +++ b/nvbench/option_parser.cu @@ -21,10 +21,12 @@ #include #include #include +#include #include #include #include #include +#include #include @@ -383,6 +385,11 @@ void option_parser::parse_range(option_parser::arg_iterator_t first, this->print_help_axis(); std::exit(0); } + else if (arg == "--version") + { + this->print_version(); + std::exit(0); + } else if (arg == "--list" || arg == "-l") { this->print_list(); @@ -531,6 +538,17 @@ std::ostream &option_parser::printer_spec_to_ostream(const std::string &spec) } } +void option_parser::print_version() const +{ + fmt::print("NVBench v{}.{}.{} ({}:{})\n", + NVBENCH_VERSION_MAJOR, + NVBENCH_VERSION_MINOR, + NVBENCH_VERSION_PATCH, + NVBENCH_GIT_BRANCH, + NVBENCH_GIT_VERSION); + std::exit(0); +} + void option_parser::print_list() const { const auto &bench_mgr = nvbench::benchmark_manager::get(); diff --git a/nvbench/option_parser.cuh b/nvbench/option_parser.cuh index ad26670..da23834 100644 --- a/nvbench/option_parser.cuh +++ b/nvbench/option_parser.cuh @@ -84,6 +84,7 @@ private: std::ostream &printer_spec_to_ostream(const std::string &spec); + void print_version() const; void print_list() const; void print_help() const; void print_help_axis() const;