diff --git a/nvbench/CMakeLists.txt b/nvbench/CMakeLists.txt index 58e9c09..7b5bd0a 100644 --- a/nvbench/CMakeLists.txt +++ b/nvbench/CMakeLists.txt @@ -13,8 +13,8 @@ set(srcs markdown_format.cu named_values.cu option_parser.cu - output_format.cu output_multiplex.cu + printer_base.cu runner.cu state.cu string_axis.cu diff --git a/nvbench/benchmark_base.cuh b/nvbench/benchmark_base.cuh index 7b7980b..01195a2 100644 --- a/nvbench/benchmark_base.cuh +++ b/nvbench/benchmark_base.cuh @@ -13,7 +13,7 @@ namespace nvbench { -struct output_format; +struct printer_base; struct runner_base; template @@ -135,12 +135,12 @@ struct benchmark_base void run() { this->do_run(); } - void set_printer(optional_ref printer) + void set_printer(optional_ref printer) { m_printer = printer; } - [[nodiscard]] optional_ref get_printer() const + [[nodiscard]] optional_ref get_printer() const { return m_printer; } @@ -217,7 +217,7 @@ protected: std::vector m_devices; std::vector m_states; - optional_ref m_printer; + optional_ref m_printer; nvbench::int64_t m_min_samples{10}; nvbench::float64_t m_min_time{0.5}; diff --git a/nvbench/csv_format.cuh b/nvbench/csv_format.cuh index af8b497..46cb0ab 100644 --- a/nvbench/csv_format.cuh +++ b/nvbench/csv_format.cuh @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace nvbench { @@ -8,12 +8,12 @@ namespace nvbench /*! * CSV output format. */ -struct csv_format : nvbench::output_format +struct csv_format : nvbench::printer_base { - using output_format::output_format; + using printer_base::printer_base; private: - // Virtual API from output_format: + // Virtual API from printer_base: void do_print_benchmark_results(const benchmark_vector &benches) override; }; diff --git a/nvbench/detail/measure_cold.cu b/nvbench/detail/measure_cold.cu index 6cb64da..fdbca26 100644 --- a/nvbench/detail/measure_cold.cu +++ b/nvbench/detail/measure_cold.cu @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include diff --git a/nvbench/detail/measure_hot.cu b/nvbench/detail/measure_hot.cu index c0e25f0..995e313 100644 --- a/nvbench/detail/measure_hot.cu +++ b/nvbench/detail/measure_hot.cu @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include diff --git a/nvbench/main.cuh b/nvbench/main.cuh index 656b1c6..7315a37 100644 --- a/nvbench/main.cuh +++ b/nvbench/main.cuh @@ -4,11 +4,11 @@ #include #include #include -#include +#include #include // std::ref -#include // std::nullopt #include +#include // std::nullopt #define NVBENCH_MAIN \ int main(int argc, char const *const *argv) \ diff --git a/nvbench/markdown_format.cu b/nvbench/markdown_format.cu index 2e57e8f..3c0be09 100644 --- a/nvbench/markdown_format.cu +++ b/nvbench/markdown_format.cu @@ -127,7 +127,7 @@ void markdown_format::do_log_run_state(const nvbench::state &exec_state) } void markdown_format::do_print_benchmark_list( - const output_format::benchmark_vector &benches) + const printer_base::benchmark_vector &benches) { fmt::memory_buffer buffer; fmt::format_to(buffer, "# Benchmarks\n\n"); @@ -183,7 +183,7 @@ void markdown_format::do_print_benchmark_list( } void markdown_format::do_print_benchmark_results( - const output_format::benchmark_vector &benches) + const printer_base::benchmark_vector &benches) { auto format_visitor = [](const auto &v) { using T = std::decay_t; diff --git a/nvbench/markdown_format.cuh b/nvbench/markdown_format.cuh index 2cb1d33..124e4ae 100644 --- a/nvbench/markdown_format.cuh +++ b/nvbench/markdown_format.cuh @@ -1,6 +1,6 @@ #pragma once -#include +#include #include @@ -15,9 +15,9 @@ struct summary; * * Includes customization points to modify numeric formatting. */ -struct markdown_format : nvbench::output_format +struct markdown_format : nvbench::printer_base { - using output_format::output_format; + using printer_base::printer_base; /*! * Enable / disable color in the output. @@ -33,7 +33,7 @@ struct markdown_format : nvbench::output_format /*!@}*/ private: - // Virtual API from output_format: + // Virtual API from printer_base: void do_print_device_info() override; void do_print_log_preamble() override; void do_print_log_epilogue() override; diff --git a/nvbench/option_parser.cu b/nvbench/option_parser.cu index 5464fcf..fda552c 100644 --- a/nvbench/option_parser.cu +++ b/nvbench/option_parser.cu @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include @@ -774,9 +774,6 @@ catch (std::exception &e) e.what()); } -nvbench::output_format &option_parser::get_printer() -{ - return m_printer; -} +nvbench::printer_base &option_parser::get_printer() { return m_printer; } } // namespace nvbench diff --git a/nvbench/option_parser.cuh b/nvbench/option_parser.cuh index 28ab60a..134cb49 100644 --- a/nvbench/option_parser.cuh +++ b/nvbench/option_parser.cuh @@ -13,7 +13,7 @@ namespace nvbench struct benchmark_base; struct float64_axis; struct int64_axis; -struct output_format; +struct printer_base; struct string_axis; struct type_axis; @@ -51,8 +51,8 @@ struct option_parser * * The returned object is only valid for the lifetime of this option_parser. */ - // output_format has no useful const API, so no const overload. - [[nodiscard]] nvbench::output_format &get_printer(); + // printer_base has no useful const API, so no const overload. + [[nodiscard]] nvbench::printer_base &get_printer(); private: void parse_impl(); diff --git a/nvbench/output_multiplex.cu b/nvbench/output_multiplex.cu index b778c7a..63194b4 100644 --- a/nvbench/output_multiplex.cu +++ b/nvbench/output_multiplex.cu @@ -6,12 +6,12 @@ namespace nvbench { output_multiplex::output_multiplex() - : output_format(std::cerr) // Nothing should write to this. + : printer_base(std::cerr) // Nothing should write to this. {} void output_multiplex::do_print_device_info() { - for (auto &format_ptr : m_formats) + for (auto &format_ptr : m_printers) { format_ptr->print_device_info(); } @@ -19,7 +19,7 @@ void output_multiplex::do_print_device_info() void output_multiplex::do_print_log_preamble() { - for (auto &format_ptr : m_formats) + for (auto &format_ptr : m_printers) { format_ptr->print_log_preamble(); } @@ -27,7 +27,7 @@ void output_multiplex::do_print_log_preamble() void output_multiplex::do_print_log_epilogue() { - for (auto &format_ptr : m_formats) + for (auto &format_ptr : m_printers) { format_ptr->print_log_epilogue(); } @@ -35,7 +35,7 @@ void output_multiplex::do_print_log_epilogue() void output_multiplex::do_log(nvbench::log_level level, const std::string &str) { - for (auto &format_ptr : m_formats) + for (auto &format_ptr : m_printers) { format_ptr->log(level, str); } @@ -43,7 +43,7 @@ void output_multiplex::do_log(nvbench::log_level level, const std::string &str) void output_multiplex::do_log_run_state(const nvbench::state &exec_state) { - for (auto &format_ptr : m_formats) + for (auto &format_ptr : m_printers) { format_ptr->log_run_state(exec_state); } @@ -51,7 +51,7 @@ void output_multiplex::do_log_run_state(const nvbench::state &exec_state) void output_multiplex::do_print_benchmark_list(const benchmark_vector &benches) { - for (auto &format_ptr : m_formats) + for (auto &format_ptr : m_printers) { format_ptr->print_benchmark_list(benches); } @@ -60,7 +60,7 @@ void output_multiplex::do_print_benchmark_list(const benchmark_vector &benches) void output_multiplex::do_print_benchmark_results( const benchmark_vector &benches) { - for (auto &format_ptr : m_formats) + for (auto &format_ptr : m_printers) { format_ptr->print_benchmark_results(benches); } diff --git a/nvbench/output_multiplex.cuh b/nvbench/output_multiplex.cuh index 23c6e87..ebf5829 100644 --- a/nvbench/output_multiplex.cuh +++ b/nvbench/output_multiplex.cuh @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -9,9 +9,9 @@ namespace nvbench { /*! - * An nvbench::output_format that just forwards calls to other `output_format`s. + * An nvbench::printer_base that just forwards calls to other `printer_base`s. */ -struct output_multiplex : nvbench::output_format +struct output_multiplex : nvbench::printer_base { output_multiplex(); @@ -19,13 +19,13 @@ struct output_multiplex : nvbench::output_format template Format &emplace(Ts &&...ts) { - m_formats.push_back(std::make_unique(std::forward(ts)...)); - return static_cast(*m_formats.back()); + m_printers.push_back(std::make_unique(std::forward(ts)...)); + return static_cast(*m_printers.back()); } [[nodiscard]] std::size_t get_output_count() const { - return m_formats.size(); + return m_printers.size(); } private: @@ -37,7 +37,7 @@ private: void do_print_benchmark_list(const benchmark_vector &benches) override; void do_print_benchmark_results(const benchmark_vector &benches) override; - std::vector> m_formats; + std::vector> m_printers; }; } // namespace nvbench diff --git a/nvbench/output_format.cu b/nvbench/printer_base.cu similarity index 52% rename from nvbench/output_format.cu rename to nvbench/printer_base.cu index c9a14b7..080dabb 100644 --- a/nvbench/output_format.cu +++ b/nvbench/printer_base.cu @@ -1,15 +1,15 @@ -#include +#include #include namespace nvbench { -output_format::output_format(std::ostream &ostream) +printer_base::printer_base(std::ostream &ostream) : m_ostream{ostream} {} // Defined here to keep out of the header -output_format::~output_format() = default; +printer_base::~printer_base() = default; } // namespace nvbench diff --git a/nvbench/output_format.cuh b/nvbench/printer_base.cuh similarity index 86% rename from nvbench/output_format.cuh rename to nvbench/printer_base.cuh index 3fb3a1c..d2023fb 100644 --- a/nvbench/output_format.cuh +++ b/nvbench/printer_base.cuh @@ -30,21 +30,21 @@ enum class log_level * Interactive terminal output formats should implement the logging functions so * users have some feedback. */ -struct output_format +struct printer_base { using benchmark_vector = std::vector>; /*! - * Construct a new output_format that will write to ostream. + * Construct a new printer_base that will write to ostream. */ - explicit output_format(std::ostream &ostream); - ~output_format(); + explicit printer_base(std::ostream &ostream); + ~printer_base(); // move-only - output_format(const output_format &) = delete; - output_format(output_format &&) = default; - output_format &operator=(const output_format &) = delete; - output_format &operator=(output_format &&) = default; + printer_base(const printer_base &) = delete; + printer_base(printer_base &&) = default; + printer_base &operator=(const printer_base &) = delete; + printer_base &operator=(printer_base &&) = default; /*! * Print a summary of all detected devices, if supported. diff --git a/nvbench/runner.cu b/nvbench/runner.cu index 4aac22a..b72c901 100644 --- a/nvbench/runner.cu +++ b/nvbench/runner.cu @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include