diff --git a/CMakeLists.txt b/CMakeLists.txt index c669e044e..26603a401 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,7 +206,6 @@ set(SOURCES src/split.cc src/task.cc src/task_manager.cc - src/user_bench.cc src/utils.cc "${CMAKE_CURRENT_BINARY_DIR}/src/version.cc" ) diff --git a/include/celerity.h b/include/celerity.h index 634744e4d..b45615ea0 100644 --- a/include/celerity.h +++ b/include/celerity.h @@ -9,7 +9,6 @@ #include "fence.h" #include "host_utils.h" #include "side_effect.h" -#include "user_bench.h" #include "version.h" namespace celerity { diff --git a/include/runtime.h b/include/runtime.h index 4cff17e07..98209ec0f 100644 --- a/include/runtime.h +++ b/include/runtime.h @@ -12,10 +12,6 @@ namespace celerity { -namespace experimental::bench::detail { - class user_benchmarker; -} // namespace experimental::bench::detail - namespace detail { class host_queue; @@ -47,8 +43,6 @@ namespace detail { task_manager& get_task_manager() const; - experimental::bench::detail::user_benchmarker& get_user_benchmarker() const { return *m_user_bench; } - void create_queue(); void destroy_queue(); @@ -86,7 +80,6 @@ namespace detail { std::thread::id m_application_thread; std::unique_ptr m_cfg; - std::unique_ptr m_user_bench; size_t m_num_nodes = 0; node_id m_local_nid = 0; size_t m_num_local_devices = 0; diff --git a/include/user_bench.h b/include/user_bench.h deleted file mode 100644 index 9d78cbbef..000000000 --- a/include/user_bench.h +++ /dev/null @@ -1,121 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include - -#include "log.h" -#include "types.h" - -namespace celerity { -namespace detail { - class config; -} - -namespace experimental { - namespace bench { - namespace detail { - using node_id = celerity::detail::node_id; - using config = celerity::detail::config; - - class user_benchmarker { - public: - user_benchmarker(config& cfg, node_id this_nid); - user_benchmarker(const user_benchmarker&) = delete; - user_benchmarker(user_benchmarker&&) = delete; - ~user_benchmarker(); - - template - void log_once(const std::string& format_string, Args&&... args) const { - if(m_this_nid == 0) { log(format_string, std::forward(args)...); } - } - - template - void begin(std::string_view format_string, Args&&... args) { - begin_section(fmt::format(format_string, std::forward(args)...)); - } - - template - void end(std::string_view format_string, Args&&... args) { - end_section(fmt::format(format_string, std::forward(args)...)); - } - - template - void event(const std::string& format_string, Args&&... args) { - std::lock_guard lk{m_mutex}; - const auto now = bench_clock::now(); - const auto dt = (m_last_event_tp != bench_clock::time_point{}) - ? std::chrono::duration_cast(now - m_last_event_tp).count() - : 0; - log(format_string + " (+{}us)", std::forward(args)..., dt); - m_last_event_tp = now; - } - - private: - using bench_clock = std::chrono::steady_clock; - using section_id = size_t; - struct section { - section_id id; - std::string name; - bench_clock::time_point start; - }; - - mutable std::mutex m_mutex; - - node_id m_this_nid; - section_id m_next_section_id = 0; - std::stack
m_sections; - bench_clock::time_point m_last_event_tp = {}; - - void begin_section(std::string name); - void end_section(const std::string& name); - - template - void log(fmt::format_string fmt_string, Args&&... args) const { - CELERITY_DEBUG("[user] {}", fmt::format(fmt_string, std::forward(args)...)); - } - }; - - user_benchmarker& get_user_benchmarker(); - } // namespace detail - - /** - * @brief Logs a message only once (on the master node). - */ - template - void log_once(const std::string& format_string, Args&&... args) { - detail::get_user_benchmarker().log_once(format_string, std::forward(args)...); - } - - /** - * @brief Begins a new benchmarking section. - * - * Sections can be nested to any depth. - */ - template - void begin(std::string_view format_string, Args&&... args) { - detail::get_user_benchmarker().begin(format_string, std::forward(args)...); - } - - /** - * @brief Ends an existing benchmarking section. - */ - template - void end(std::string_view format_string, Args&&... args) { - detail::get_user_benchmarker().end(format_string, std::forward(args)...); - } - - /** - * @brief Logs a benchmarking event. - */ - template - void event(const std::string& format_string, Args&&... args) { - detail::get_user_benchmarker().event(format_string, std::forward(args)...); - } - - } // namespace bench -} // namespace experimental -} // namespace celerity diff --git a/src/runtime.cc b/src/runtime.cc index bd4cbb2cc..890073569 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -32,7 +32,6 @@ #include "scheduler.h" #include "system_info.h" #include "task_manager.h" -#include "user_bench.h" #include "version.h" namespace celerity { @@ -147,8 +146,6 @@ namespace detail { } #endif - m_user_bench = std::make_unique(*m_cfg, m_local_nid); - cgf_diagnostics::make_available(); auto devices = std::visit( @@ -262,8 +259,6 @@ namespace detail { cgf_diagnostics::teardown(); - m_user_bench.reset(); - if(!s_test_mode) { mpi_finalize_once(); } } diff --git a/src/user_bench.cc b/src/user_bench.cc deleted file mode 100644 index b2e56922e..000000000 --- a/src/user_bench.cc +++ /dev/null @@ -1,49 +0,0 @@ -#include "user_bench.h" - -#include -#include - -#include "config.h" -#include "runtime.h" - -namespace celerity { -namespace experimental { - namespace bench { - namespace detail { - user_benchmarker::~user_benchmarker() { - while(!m_sections.empty()) { - const auto sec = m_sections.top(); - try { - end_section(sec.name); - } catch(...) {} - } - } - - user_benchmarker::user_benchmarker(config& cfg, node_id this_nid) : m_this_nid(this_nid) { - if(static_cast(bench_clock::period::num) / bench_clock::period::den > static_cast(std::micro::num) / std::micro::den) { - CELERITY_WARN("Available clock does not have sufficient precision"); - } - } - - user_benchmarker& get_user_benchmarker() { return celerity::detail::runtime::get_instance().get_user_benchmarker(); } - - void user_benchmarker::begin_section(std::string name) { - std::lock_guard lk{m_mutex}; - section sec = {m_next_section_id++, std::move(name), bench_clock::now()}; - log("Begin section {} \"{}\"", sec.id, sec.name); - m_sections.push(std::move(sec)); - } - - void user_benchmarker::end_section(const std::string& name) { - std::lock_guard lk{m_mutex}; - const auto sec = m_sections.top(); - m_sections.pop(); - if(sec.name != name) { throw std::runtime_error(fmt::format("Section name '{}' does not match last section '{}'", name, sec.name)); } - const auto duration = std::chrono::duration_cast(bench_clock::now() - sec.start); - log("End section {} \"{}\" after {}us", sec.id, name, duration.count()); - } - - } // namespace detail - } // namespace bench -} // namespace experimental -} // namespace celerity