From ca94beef454e52348016bbb8358c81b4e5184c5a Mon Sep 17 00:00:00 2001 From: Philip Salzmann Date: Wed, 27 Jul 2022 15:53:52 +0200 Subject: [PATCH] clang-tidy: Fix private variable naming in test headers --- test/buffer_manager_test_utils.h | 32 +++---- test/test_utils.h | 138 +++++++++++++++---------------- 2 files changed, 85 insertions(+), 85 deletions(-) diff --git a/test/buffer_manager_test_utils.h b/test/buffer_manager_test_utils.h index 80cc6a30d..cfd2356ab 100644 --- a/test/buffer_manager_test_utils.h +++ b/test/buffer_manager_test_utils.h @@ -22,14 +22,14 @@ namespace test_utils { enum class access_target { host, device }; void initialize(detail::buffer_manager::buffer_lifecycle_callback cb = [](detail::buffer_manager::buffer_lifecycle_event, detail::buffer_id) {}) { - assert(!bm); - bm = std::make_unique(get_device_queue(), cb); - bm->enable_test_mode(); + assert(!m_bm); + m_bm = std::make_unique(get_device_queue(), cb); + m_bm->enable_test_mode(); } detail::buffer_manager& get_buffer_manager() { - if(!bm) initialize(); - return *bm; + if(!m_bm) initialize(); + return *m_bm; } static access_target get_other_target(access_target tgt) { @@ -40,10 +40,10 @@ namespace test_utils { template cl::sycl::range get_backing_buffer_range(detail::buffer_id bid, access_target tgt, cl::sycl::range range, cl::sycl::id offset) { if(tgt == access_target::host) { - auto info = bm->get_host_buffer(bid, cl::sycl::access::mode::read, detail::range_cast<3>(range), detail::id_cast<3>(offset)); + auto info = m_bm->get_host_buffer(bid, cl::sycl::access::mode::read, detail::range_cast<3>(range), detail::id_cast<3>(offset)); return info.buffer.get_range(); } - auto info = bm->get_device_buffer(bid, cl::sycl::access::mode::read, detail::range_cast<3>(range), detail::id_cast<3>(offset)); + auto info = m_bm->get_device_buffer(bid, cl::sycl::access::mode::read, detail::range_cast<3>(range), detail::id_cast<3>(offset)); return info.buffer.get_range(); } @@ -53,7 +53,7 @@ namespace test_utils { const auto offset3 = detail::id_cast<3>(offset); if(tgt == access_target::host) { - auto info = bm->get_host_buffer(bid, Mode, range3, offset3); + auto info = m_bm->get_host_buffer(bid, Mode, range3, offset3); const auto buf_range = detail::range_cast<3>(info.buffer.get_range()); for(size_t i = offset3[0]; i < offset3[0] + range3[0]; ++i) { for(size_t j = offset3[1]; j < offset3[1] + range3[1]; ++j) { @@ -68,7 +68,7 @@ namespace test_utils { } if(tgt == access_target::device) { - auto info = bm->get_device_buffer(bid, Mode, range3, offset3); + auto info = m_bm->get_device_buffer(bid, Mode, range3, offset3); const auto buf_offset = info.offset; get_device_queue() .submit([&](cl::sycl::handler& cgh) { @@ -89,7 +89,7 @@ namespace test_utils { const auto offset3 = detail::id_cast<3>(offset); if(tgt == access_target::host) { - auto info = bm->get_host_buffer(bid, cl::sycl::access::mode::read, range3, offset3); + auto info = m_bm->get_host_buffer(bid, cl::sycl::access::mode::read, range3, offset3); const auto buf_range = detail::range_cast<3>(info.buffer.get_range()); ReduceT result = init; for(size_t i = offset3[0]; i < offset3[0] + range3[0]; ++i) { @@ -105,7 +105,7 @@ namespace test_utils { return result; } - auto info = bm->get_device_buffer(bid, cl::sycl::access::mode::read, range3, offset3); + auto info = m_bm->get_device_buffer(bid, cl::sycl::access::mode::read, range3, offset3); const auto buf_offset = info.offset; cl::sycl::buffer result_buf(1); // Use 1-dimensional instead of 0-dimensional since it's NYI in hipSYCL as of 0.8.1 // Simply do a serial reduction on the device as well @@ -142,7 +142,7 @@ namespace test_utils { template accessor get_device_accessor( detail::live_pass_device_handler& cgh, detail::buffer_id bid, const cl::sycl::range& range, const cl::sycl::id& offset) { - auto buf_info = bm->get_device_buffer(bid, Mode, detail::range_cast<3>(range), detail::id_cast<3>(offset)); + auto buf_info = m_bm->get_device_buffer(bid, Mode, detail::range_cast<3>(range), detail::id_cast<3>(offset)); return detail::make_device_accessor(cgh.get_eventual_sycl_cgh(), buf_info.buffer, detail::get_effective_sycl_accessor_subrange(buf_info.offset, subrange(offset, range)), offset); } @@ -150,14 +150,14 @@ namespace test_utils { template accessor get_host_accessor( detail::buffer_id bid, const cl::sycl::range& range, const cl::sycl::id& offset) { - auto buf_info = bm->get_host_buffer(bid, Mode, detail::range_cast<3>(range), detail::id_cast<3>(offset)); + auto buf_info = m_bm->get_host_buffer(bid, Mode, detail::range_cast<3>(range), detail::id_cast<3>(offset)); return detail::make_host_accessor( - subrange(offset, range), buf_info.buffer, buf_info.offset, detail::range_cast(bm->get_buffer_info(bid).range)); + subrange(offset, range), buf_info.buffer, buf_info.offset, detail::range_cast(m_bm->get_buffer_info(bid).range)); } private: - bool initialized = false; - std::unique_ptr bm; + bool m_initialized = false; + std::unique_ptr m_bm; }; } // namespace test_utils diff --git a/test/test_utils.h b/test/test_utils.h index 5c391d43b..42b727ea8 100644 --- a/test/test_utils.h +++ b/test/test_utils.h @@ -87,16 +87,16 @@ namespace test_utils { return *instance; } - void reset() { logged_lines.clear(); } + void reset() { m_logged_lines.clear(); } bool should_log(std::string line_info) { - auto [_, is_new] = logged_lines.emplace(std::move(line_info)); + auto [_, is_new] = m_logged_lines.emplace(std::move(line_info)); return is_new; } private: inline static std::unique_ptr instance; - std::unordered_set logged_lines{}; + std::unordered_set m_logged_lines{}; }; #define CELERITY_DETAIL_REQUIRE_LOOP(...) \ @@ -134,21 +134,21 @@ namespace test_utils { void get_access(handler& cgh, Functor rmfn) { if(detail::is_prepass_handler(cgh)) { auto& prepass_cgh = dynamic_cast(cgh); // No live pass in tests - prepass_cgh.add_requirement(id, std::make_unique>(rmfn, Mode, size)); + prepass_cgh.add_requirement(m_id, std::make_unique>(rmfn, Mode, m_size)); } } - detail::buffer_id get_id() const { return id; } + detail::buffer_id get_id() const { return m_id; } - range get_range() const { return size; } + range get_range() const { return m_size; } private: friend class mock_buffer_factory; - detail::buffer_id id; - cl::sycl::range size; + detail::buffer_id m_id; + cl::sycl::range m_size; - mock_buffer(detail::buffer_id id, cl::sycl::range size) : id(id), size(size) {} + mock_buffer(detail::buffer_id id, cl::sycl::range size) : m_id(id), m_size(size) {} }; class mock_host_object { @@ -156,17 +156,17 @@ namespace test_utils { void add_side_effect(handler& cgh, const experimental::side_effect_order order) { if(detail::is_prepass_handler(cgh)) { auto& prepass_cgh = static_cast(cgh); - prepass_cgh.add_requirement(id, order); + prepass_cgh.add_requirement(m_id, order); } } private: friend class mock_host_object_factory; - detail::host_object_id id; + detail::host_object_id m_id; public: - explicit mock_host_object(detail::host_object_id id) : id(id) {} + explicit mock_host_object(detail::host_object_id id) : m_id(id) {} }; class cdag_inspector { @@ -176,14 +176,14 @@ namespace test_utils { #ifndef NDEBUG for(const auto dcid : frame->iter_dependencies()) { // Sanity check: All dependencies must have already been flushed - assert(commands.count(dcid) == 1); + assert(m_commands.count(dcid) == 1); } #endif const detail::command_id cid = frame->pkg.cid; - commands[cid] = {nid, frame->pkg, std::vector(frame->iter_dependencies().begin(), frame->iter_dependencies().end())}; - if(const auto tid = frame->pkg.get_tid()) { by_task[*tid].insert(cid); } - by_node[nid].insert(cid); + m_commands[cid] = {nid, frame->pkg, std::vector(frame->iter_dependencies().begin(), frame->iter_dependencies().end())}; + if(const auto tid = frame->pkg.get_tid()) { m_by_task[*tid].insert(cid); } + m_by_node[nid].insert(cid); }; } @@ -195,16 +195,16 @@ namespace test_utils { || cmd == detail::command_type::epoch)); std::set result; - std::transform(commands.cbegin(), commands.cend(), std::inserter(result, result.begin()), [](auto p) { return p.first; }); + std::transform(m_commands.cbegin(), m_commands.cend(), std::inserter(result, result.begin()), [](auto p) { return p.first; }); if(tid != std::nullopt) { - auto& task_set = by_task.at(*tid); + auto& task_set = m_by_task.at(*tid); std::set new_result; std::set_intersection(result.cbegin(), result.cend(), task_set.cbegin(), task_set.cend(), std::inserter(new_result, new_result.begin())); result = std::move(new_result); } if(nid != std::nullopt) { - auto& node_set = by_node.at(*nid); + auto& node_set = m_by_node.at(*nid); std::set new_result; std::set_intersection(result.cbegin(), result.cend(), node_set.cbegin(), node_set.cend(), std::inserter(new_result, new_result.begin())); result = std::move(new_result); @@ -212,7 +212,7 @@ namespace test_utils { if(cmd != std::nullopt) { std::set new_result; std::copy_if(result.cbegin(), result.cend(), std::inserter(new_result, new_result.begin()), - [this, cmd](detail::command_id cid) { return commands.at(cid).pkg.get_command_type() == cmd; }); + [this, cmd](detail::command_id cid) { return m_commands.at(cid).pkg.get_command_type() == cmd; }); result = std::move(new_result); } @@ -220,13 +220,13 @@ namespace test_utils { } bool has_dependency(detail::command_id dependent, detail::command_id dependency) const { - const auto& deps = commands.at(dependent).dependencies; + const auto& deps = m_commands.at(dependent).dependencies; return std::find(deps.cbegin(), deps.cend(), dependency) != deps.cend(); } - size_t get_dependency_count(detail::command_id dependent) const { return commands.at(dependent).dependencies.size(); } + size_t get_dependency_count(detail::command_id dependent) const { return m_commands.at(dependent).dependencies.size(); } - std::vector get_dependencies(detail::command_id dependent) const { return commands.at(dependent).dependencies; } + std::vector get_dependencies(detail::command_id dependent) const { return m_commands.at(dependent).dependencies; } private: struct cmd_info { @@ -235,80 +235,80 @@ namespace test_utils { std::vector dependencies; }; - std::map commands; - std::map> by_task; - std::map> by_node; + std::map m_commands; + std::map> m_by_task; + std::map> m_by_node; }; class cdag_test_context { public: cdag_test_context(size_t num_nodes) { - rm = std::make_unique(); - tm = std::make_unique(1 /* num_nodes */, nullptr /* host_queue */, rm.get()); - cdag = std::make_unique(); - ggen = std::make_unique(num_nodes, *rm, *cdag); - gsrlzr = std::make_unique(*cdag, inspector.get_cb()); - this->num_nodes = num_nodes; + m_rm = std::make_unique(); + m_tm = std::make_unique(1 /* num_nodes */, nullptr /* host_queue */, m_rm.get()); + m_cdag = std::make_unique(); + m_ggen = std::make_unique(num_nodes, *m_rm, *m_cdag); + m_gsrlzr = std::make_unique(*m_cdag, m_inspector.get_cb()); + this->m_num_nodes = num_nodes; } - detail::reduction_manager& get_reduction_manager() { return *rm; } - detail::task_manager& get_task_manager() { return *tm; } - detail::command_graph& get_command_graph() { return *cdag; } - detail::graph_generator& get_graph_generator() { return *ggen; } - cdag_inspector& get_inspector() { return inspector; } - detail::graph_serializer& get_graph_serializer() { return *gsrlzr; } + detail::reduction_manager& get_reduction_manager() { return *m_rm; } + detail::task_manager& get_task_manager() { return *m_tm; } + detail::command_graph& get_command_graph() { return *m_cdag; } + detail::graph_generator& get_graph_generator() { return *m_ggen; } + cdag_inspector& get_inspector() { return m_inspector; } + detail::graph_serializer& get_graph_serializer() { return *m_gsrlzr; } detail::task_id build_task_horizons() { const auto most_recently_generated_task_horizon = detail::task_manager_testspy::get_current_horizon(get_task_manager()); - if(most_recently_generated_task_horizon != most_recently_built_task_horizon) { - most_recently_built_task_horizon = most_recently_generated_task_horizon; - if(most_recently_built_task_horizon) { + if(most_recently_generated_task_horizon != m_most_recently_built_task_horizon) { + m_most_recently_built_task_horizon = most_recently_generated_task_horizon; + if(m_most_recently_built_task_horizon) { // naive_split does not really do anything for horizons, but this mirrors the behavior of scheduler::schedule exactly. - detail::naive_split_transformer naive_split(num_nodes, num_nodes); - get_graph_generator().build_task(*tm->get_task(*most_recently_built_task_horizon), {&naive_split}); - return *most_recently_built_task_horizon; + detail::naive_split_transformer naive_split(m_num_nodes, m_num_nodes); + get_graph_generator().build_task(*m_tm->get_task(*m_most_recently_built_task_horizon), {&naive_split}); + return *m_most_recently_built_task_horizon; } } return 0; } private: - std::unique_ptr rm; - std::unique_ptr tm; - std::unique_ptr cdag; - std::unique_ptr ggen; - cdag_inspector inspector; - std::unique_ptr gsrlzr; - size_t num_nodes; - std::optional most_recently_built_task_horizon; + std::unique_ptr m_rm; + std::unique_ptr m_tm; + std::unique_ptr m_cdag; + std::unique_ptr m_ggen; + cdag_inspector m_inspector; + std::unique_ptr m_gsrlzr; + size_t m_num_nodes; + std::optional m_most_recently_built_task_horizon; }; class mock_buffer_factory { public: - explicit mock_buffer_factory(detail::task_manager* tm = nullptr, detail::graph_generator* ggen = nullptr) : task_mngr(tm), ggen(ggen) {} - explicit mock_buffer_factory(cdag_test_context& ctx) : task_mngr(&ctx.get_task_manager()), ggen(&ctx.get_graph_generator()) {} + explicit mock_buffer_factory(detail::task_manager* tm = nullptr, detail::graph_generator* ggen = nullptr) : m_task_mngr(tm), m_ggen(ggen) {} + explicit mock_buffer_factory(cdag_test_context& ctx) : m_task_mngr(&ctx.get_task_manager()), m_ggen(&ctx.get_graph_generator()) {} template mock_buffer create_buffer(cl::sycl::range size, bool mark_as_host_initialized = false) { - const detail::buffer_id bid = next_buffer_id++; + const detail::buffer_id bid = m_next_buffer_id++; const auto buf = mock_buffer(bid, size); - if(task_mngr != nullptr) { task_mngr->add_buffer(bid, detail::range_cast<3>(size), mark_as_host_initialized); } - if(ggen != nullptr) { ggen->add_buffer(bid, detail::range_cast<3>(size)); } + if(m_task_mngr != nullptr) { m_task_mngr->add_buffer(bid, detail::range_cast<3>(size), mark_as_host_initialized); } + if(m_ggen != nullptr) { m_ggen->add_buffer(bid, detail::range_cast<3>(size)); } return buf; } private: - detail::task_manager* task_mngr; - detail::graph_generator* ggen; - detail::buffer_id next_buffer_id = 0; + detail::task_manager* m_task_mngr; + detail::graph_generator* m_ggen; + detail::buffer_id m_next_buffer_id = 0; }; class mock_host_object_factory { public: - mock_host_object create_host_object() { return mock_host_object{next_id++}; } + mock_host_object create_host_object() { return mock_host_object{m_next_id++}; } private: - detail::host_object_id next_id = 0; + detail::host_object_id m_next_id = 0; }; template @@ -388,17 +388,17 @@ namespace test_utils { ~device_queue_fixture() { get_device_queue().get_sycl_queue().wait_and_throw(); } detail::device_queue& get_device_queue() { - if(!dq) { - cfg = std::make_unique(nullptr, nullptr); - dq = std::make_unique(); - dq->init(*cfg, detail::auto_select_device{}); + if(!m_dq) { + m_cfg = std::make_unique(nullptr, nullptr); + m_dq = std::make_unique(); + m_dq->init(*m_cfg, detail::auto_select_device{}); } - return *dq; + return *m_dq; } private: - std::unique_ptr cfg; - std::unique_ptr dq; + std::unique_ptr m_cfg; + std::unique_ptr m_dq; }; // Printing of graphs can be enabled using the "--print-graphs" command line flag