diff --git a/nvbench/json_printer.cu b/nvbench/json_printer.cu index ab4024b..bc4d6ad 100644 --- a/nvbench/json_printer.cu +++ b/nvbench/json_printer.cu @@ -230,40 +230,51 @@ void json_printer::do_print_benchmark_results(const benchmark_vector &benches) { auto &metadata = root["meta"]; - auto &version = metadata["version"]; { - const auto version_info = json_printer::get_json_file_version(); - auto &json_version = version["json"]; - - json_version["major"] = version_info.major; - json_version["minor"] = version_info.minor; - json_version["patch"] = version_info.patch; - json_version["string"] = version_info.get_string(); - } + auto &argv = metadata["argv"]; + for (const auto &arg : m_argv) + { + argv.push_back(arg); + } + } // "argv" { - auto &nvb_version = version["nvbench"]; + auto &version = metadata["version"]; - nvb_version["major"] = NVBENCH_VERSION_MAJOR; - nvb_version["minor"] = NVBENCH_VERSION_MINOR; - nvb_version["patch"] = NVBENCH_VERSION_PATCH; - nvb_version["string"] = fmt::format("{}.{}.{}", - NVBENCH_VERSION_MAJOR, - NVBENCH_VERSION_MINOR, - NVBENCH_VERSION_PATCH); + { + const auto version_info = json_printer::get_json_file_version(); + auto &json_version = version["json"]; - nvb_version["git_branch"] = NVBENCH_GIT_BRANCH; - nvb_version["git_sha"] = NVBENCH_GIT_SHA1; - nvb_version["git_version"] = NVBENCH_GIT_VERSION; - nvb_version["git_is_dirty"] = + json_version["major"] = version_info.major; + json_version["minor"] = version_info.minor; + json_version["patch"] = version_info.patch; + json_version["string"] = version_info.get_string(); + } // "json" + + { + auto &nvb_version = version["nvbench"]; + + nvb_version["major"] = NVBENCH_VERSION_MAJOR; + nvb_version["minor"] = NVBENCH_VERSION_MINOR; + nvb_version["patch"] = NVBENCH_VERSION_PATCH; + nvb_version["string"] = fmt::format("{}.{}.{}", + NVBENCH_VERSION_MAJOR, + NVBENCH_VERSION_MINOR, + NVBENCH_VERSION_PATCH); + + nvb_version["git_branch"] = NVBENCH_GIT_BRANCH; + nvb_version["git_sha"] = NVBENCH_GIT_SHA1; + nvb_version["git_version"] = NVBENCH_GIT_VERSION; + nvb_version["git_is_dirty"] = #ifdef NVBENCH_GIT_IS_DIRTY - true; + true; #else - false; + false; #endif - } - } + } // "nvbench" + } // "version" + } // "meta" { auto &devices = root["devices"]; @@ -294,7 +305,7 @@ void json_printer::do_print_benchmark_results(const benchmark_vector &benches) dev_info.get_shared_memory_per_block(); device["ecc_state"] = dev_info.get_ecc_state(); } - } + } // "devices" { auto &benchmarks = root["benchmarks"]; @@ -429,7 +440,7 @@ void json_printer::do_print_benchmark_results(const benchmark_vector &benches) } } // end foreach exec_state } // end foreach benchmark - } + } // "benchmarks" m_ostream << root.dump(2) << "\n"; } diff --git a/nvbench/json_printer.cuh b/nvbench/json_printer.cuh index dfb6032..a58448f 100644 --- a/nvbench/json_printer.cuh +++ b/nvbench/json_printer.cuh @@ -23,6 +23,7 @@ #include #include +#include namespace nvbench { @@ -66,6 +67,10 @@ struct json_printer : nvbench::printer_base protected: // Virtual API from printer_base: + void do_log_argv(const std::vector& argv) override + { + m_argv = argv; + } void do_process_bulk_data_float64( nvbench::state &state, const std::string &tag, @@ -75,6 +80,8 @@ protected: bool m_enable_binary_output{false}; std::size_t m_num_jsonbin_files{}; + + std::vector m_argv; }; } // namespace nvbench diff --git a/nvbench/option_parser.cu b/nvbench/option_parser.cu index 60f49d7..e148cb0 100644 --- a/nvbench/option_parser.cu +++ b/nvbench/option_parser.cu @@ -375,6 +375,8 @@ void option_parser::parse_impl() } this->update_used_device_state(); + + m_printer.log_argv(m_args); } void option_parser::parse_range(option_parser::arg_iterator_t first, diff --git a/nvbench/option_parser.cuh b/nvbench/option_parser.cuh index 4635e42..9651ab6 100644 --- a/nvbench/option_parser.cuh +++ b/nvbench/option_parser.cuh @@ -121,7 +121,7 @@ private: void update_used_device_state() const; - // less gross argv: + // Command line args std::vector m_args; // Store benchmark modifiers passed in before any benchmarks are requested as diff --git a/nvbench/printer_base.cuh b/nvbench/printer_base.cuh index fd6c505..0e28a35 100644 --- a/nvbench/printer_base.cuh +++ b/nvbench/printer_base.cuh @@ -81,6 +81,15 @@ struct printer_base printer_base &operator=(const printer_base &) = delete; printer_base &operator=(printer_base &&) = default; + /*! + * Called once with the command line arguments used to invoke the current + * executable. + */ + void log_argv(const std::vector &argv) + { + this->do_log_argv(argv); + } + /*! * Print a summary of all detected devices, if supported. * @@ -184,6 +193,7 @@ struct printer_base protected: // Implementation hooks for subclasses: + virtual void do_log_argv(const std::vector&) {} virtual void do_print_device_info() {} virtual void do_print_log_preamble() {} virtual void do_print_log_epilogue() {} diff --git a/nvbench/printer_multiplex.cuh b/nvbench/printer_multiplex.cuh index 0bf1080..f32a0e9 100644 --- a/nvbench/printer_multiplex.cuh +++ b/nvbench/printer_multiplex.cuh @@ -46,6 +46,7 @@ struct printer_multiplex : nvbench::printer_base } protected: + void do_log_argv(const std::vector &argv) override; void do_print_device_info() override; void do_print_log_preamble() override; void do_print_log_epilogue() override; diff --git a/nvbench/printer_multiplex.cxx b/nvbench/printer_multiplex.cxx index aaa40f8..86d9954 100644 --- a/nvbench/printer_multiplex.cxx +++ b/nvbench/printer_multiplex.cxx @@ -121,5 +121,13 @@ void printer_multiplex::do_set_total_state_count(std::size_t states) format_ptr->set_total_state_count(states); } } +void printer_multiplex::do_log_argv(const std::vector &argv) +{ + printer_base::do_log_argv(argv); + for (auto &format_ptr : m_printers) + { + format_ptr->log_argv(argv); + } +} } // namespace nvbench