mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-03-14 20:27:24 +00:00
Log commandline args in JSON output.
This commit is contained in:
@@ -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";
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <nvbench/types.cuh>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
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<std::string>& 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<std::string> m_argv;
|
||||
};
|
||||
|
||||
} // namespace nvbench
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -121,7 +121,7 @@ private:
|
||||
|
||||
void update_used_device_state() const;
|
||||
|
||||
// less gross argv:
|
||||
// Command line args
|
||||
std::vector<std::string> m_args;
|
||||
|
||||
// Store benchmark modifiers passed in before any benchmarks are requested as
|
||||
|
||||
@@ -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<std::string> &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<std::string>&) {}
|
||||
virtual void do_print_device_info() {}
|
||||
virtual void do_print_log_preamble() {}
|
||||
virtual void do_print_log_epilogue() {}
|
||||
|
||||
@@ -46,6 +46,7 @@ struct printer_multiplex : nvbench::printer_base
|
||||
}
|
||||
|
||||
protected:
|
||||
void do_log_argv(const std::vector<std::string> &argv) override;
|
||||
void do_print_device_info() override;
|
||||
void do_print_log_preamble() override;
|
||||
void do_print_log_epilogue() override;
|
||||
|
||||
@@ -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<std::string> &argv)
|
||||
{
|
||||
printer_base::do_log_argv(argv);
|
||||
for (auto &format_ptr : m_printers)
|
||||
{
|
||||
format_ptr->log_argv(argv);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace nvbench
|
||||
|
||||
Reference in New Issue
Block a user