From ba8356f8111bcbe748a4bfa34084f9d1dc513c2d Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 12 Apr 2022 11:36:44 -0400 Subject: [PATCH] Refactor names --- examples/custom_iteration_spaces.cu | 22 ++++++------ nvbench/axes_metadata.cuh | 12 +++---- nvbench/axes_metadata.cxx | 6 ++-- nvbench/axis_iteration_space.cuh | 48 ++++++++++++------------- nvbench/axis_iteration_space.cxx | 54 ++++++++++++++--------------- nvbench/benchmark_base.cxx | 4 +-- nvbench/detail/state_generator.cxx | 4 +-- testing/axes_iteration_space.cu | 10 +++--- testing/state_generator.cu | 10 +++--- 9 files changed, 85 insertions(+), 85 deletions(-) diff --git a/examples/custom_iteration_spaces.cu b/examples/custom_iteration_spaces.cu index 8963260..26be761 100644 --- a/examples/custom_iteration_spaces.cu +++ b/examples/custom_iteration_spaces.cu @@ -99,7 +99,7 @@ struct under_diag final : nvbench::user_axis_space mutable std::size_t y_pos = 0; mutable std::size_t x_start = 0; - nvbench::detail::axis_space_iterator do_iter(axes_info info) const + nvbench::detail::axis_space_iterator do_get_iterator(axes_info info) const { // generate our increment function auto adv_func = [&, info](std::size_t &inc_index, @@ -136,17 +136,17 @@ struct under_diag final : nvbench::user_axis_space diag_under); } - std::size_t do_size(const axes_info &info) const + std::size_t do_get_size(const axes_info &info) const { return ((info[0].size * (info[1].size + 1)) / 2); } - std::size_t do_valid_count(const axes_info &info) const + std::size_t do_get_active_count(const axes_info &info) const { return ((info[0].size * (info[1].size + 1)) / 2); } - std::unique_ptr do_clone() const + std::unique_ptr do_clone() const { return std::make_unique(*this); } @@ -155,7 +155,7 @@ struct under_diag final : nvbench::user_axis_space NVBENCH_BENCH(copy_sweep_grid_shape) .set_name("user_copy_sweep_grid_shape") .add_user_iteration_axes( - [](auto... args) -> std::unique_ptr { + [](auto... args) -> std::unique_ptr { return std::make_unique(args...); }, nvbench::int64_axis("BlockSize", {64, 128, 256, 512, 1024}), @@ -175,7 +175,7 @@ struct gauss final : nvbench::user_axis_space std::move(output_indices)) {} - nvbench::detail::axis_space_iterator do_iter(axes_info info) const + nvbench::detail::axis_space_iterator do_get_iterator(axes_info info) const { const double mid_point = static_cast((info[0].size / 2)); @@ -206,14 +206,14 @@ struct gauss final : nvbench::user_axis_space gauss_func); } - std::size_t do_size(const axes_info &info) const { return info[0].size; } + std::size_t do_get_size(const axes_info &info) const { return info[0].size; } - std::size_t do_valid_count(const axes_info &info) const + std::size_t do_get_active_count(const axes_info &info) const { return info[0].size; } - std::unique_ptr do_clone() const + std::unique_ptr do_clone() const { return std::make_unique(*this); } @@ -232,12 +232,12 @@ void dual_float64_axis(nvbench::state &state) } NVBENCH_BENCH(dual_float64_axis) .add_user_iteration_axes( - [](auto... args) -> std::unique_ptr { + [](auto... args) -> std::unique_ptr { return std::make_unique(args...); }, nvbench::float64_axis("Duration_A", nvbench::range(0., 1e-4, 1e-5))) .add_user_iteration_axes( - [](auto... args) -> std::unique_ptr { + [](auto... args) -> std::unique_ptr { return std::make_unique(args...); }, nvbench::float64_axis("Duration_B", nvbench::range(0., 1e-4, 1e-5))); diff --git a/nvbench/axes_metadata.cuh b/nvbench/axes_metadata.cuh index 36dc594..9454b52 100644 --- a/nvbench/axes_metadata.cuh +++ b/nvbench/axes_metadata.cuh @@ -39,8 +39,8 @@ namespace nvbench struct axes_metadata { using axes_type = std::vector>; - using axes_iteration_space = - std::vector>; + using iteration_space_type = + std::vector>; template explicit axes_metadata(nvbench::type_list); @@ -86,11 +86,11 @@ struct axes_metadata user_iteration_axes(std::function make, std::vector names); - [[nodiscard]] const axes_iteration_space &get_type_iteration_space() const + [[nodiscard]] const iteration_space_type &get_type_iteration_space() const { return m_type_space; } - [[nodiscard]] const axes_iteration_space &get_value_iteration_space() const + [[nodiscard]] const iteration_space_type &get_value_iteration_space() const { return m_value_space; } @@ -131,8 +131,8 @@ struct axes_metadata private: axes_type m_axes; std::size_t m_type_axe_count = 0; - axes_iteration_space m_type_space; - axes_iteration_space m_value_space; + iteration_space_type m_type_space; + iteration_space_type m_value_space; }; template diff --git a/nvbench/axes_metadata.cxx b/nvbench/axes_metadata.cxx index 5a803aa..f78c478 100644 --- a/nvbench/axes_metadata.cxx +++ b/nvbench/axes_metadata.cxx @@ -177,12 +177,12 @@ get_axes_indices(std::size_t type_axe_count, } void reset_iteration_space( - nvbench::axes_metadata::axes_iteration_space &all_spaces, + nvbench::axes_metadata::iteration_space_type &all_spaces, const std::vector &indices_to_remove) { // 1. Find all spaces indices that - nvbench::axes_metadata::axes_iteration_space reset_space; - nvbench::axes_metadata::axes_iteration_space to_filter; + nvbench::axes_metadata::iteration_space_type reset_space; + nvbench::axes_metadata::iteration_space_type to_filter; for (auto &space : all_spaces) { bool added = false; diff --git a/nvbench/axis_iteration_space.cuh b/nvbench/axis_iteration_space.cuh index 9fd9a99..913e5df 100644 --- a/nvbench/axis_iteration_space.cuh +++ b/nvbench/axis_iteration_space.cuh @@ -23,7 +23,7 @@ namespace nvbench { -struct axis_space_base +struct iteration_space_base { using axes_type = std::vector>; using axes_info = std::vector; @@ -32,17 +32,17 @@ struct axis_space_base nvbench::detail::axis_space_iterator::AdvanceSignature; using UpdateSignature = nvbench::detail::axis_space_iterator::UpdateSignature; - axis_space_base(std::vector input_indices, + iteration_space_base(std::vector input_indices, std::vector output_indices); - virtual ~axis_space_base(); + virtual ~iteration_space_base(); - [[nodiscard]] std::unique_ptr clone() const; - [[nodiscard]] std::vector> + [[nodiscard]] std::unique_ptr clone() const; + [[nodiscard]] std::vector> clone_as_linear() const; - [[nodiscard]] detail::axis_space_iterator iter(const axes_type &axes) const; - [[nodiscard]] std::size_t size(const axes_type &axes) const; - [[nodiscard]] std::size_t valid_count(const axes_type &axes) const; + [[nodiscard]] detail::axis_space_iterator get_iterator(const axes_type &axes) const; + [[nodiscard]] std::size_t get_size(const axes_type &axes) const; + [[nodiscard]] std::size_t get_active_count(const axes_type &axes) const; [[nodiscard]] bool contains(std::size_t input_index) const; @@ -50,36 +50,36 @@ protected: std::vector m_input_indices; std::vector m_output_indices; - virtual std::unique_ptr do_clone() const = 0; - virtual detail::axis_space_iterator do_iter(axes_info info) const = 0; - virtual std::size_t do_size(const axes_info &info) const = 0; - virtual std::size_t do_valid_count(const axes_info &info) const = 0; + virtual std::unique_ptr do_clone() const = 0; + virtual detail::axis_space_iterator do_get_iterator(axes_info info) const = 0; + virtual std::size_t do_get_size(const axes_info &info) const = 0; + virtual std::size_t do_get_active_count(const axes_info &info) const = 0; }; -struct linear_axis_space final : axis_space_base +struct linear_axis_space final : iteration_space_base { linear_axis_space(std::size_t in, std::size_t out); ~linear_axis_space(); - std::unique_ptr do_clone() const override; - detail::axis_space_iterator do_iter(axes_info info) const override; - std::size_t do_size(const axes_info &info) const override; - std::size_t do_valid_count(const axes_info &info) const override; + std::unique_ptr do_clone() const override; + detail::axis_space_iterator do_get_iterator(axes_info info) const override; + std::size_t do_get_size(const axes_info &info) const override; + std::size_t do_get_active_count(const axes_info &info) const override; }; -struct zip_axis_space final : axis_space_base +struct zip_axis_space final : iteration_space_base { zip_axis_space(std::vector input_indices, std::vector output_indices); ~zip_axis_space(); - std::unique_ptr do_clone() const override; - detail::axis_space_iterator do_iter(axes_info info) const override; - std::size_t do_size(const axes_info &info) const override; - std::size_t do_valid_count(const axes_info &info) const override; + std::unique_ptr do_clone() const override; + detail::axis_space_iterator do_get_iterator(axes_info info) const override; + std::size_t do_get_size(const axes_info &info) const override; + std::size_t do_get_active_count(const axes_info &info) const override; }; -struct user_axis_space : axis_space_base +struct user_axis_space : iteration_space_base { user_axis_space(std::vector input_indices, std::vector output_indices); @@ -87,7 +87,7 @@ struct user_axis_space : axis_space_base }; using make_user_space_signature = - std::unique_ptr(std::vector input_indices, + std::unique_ptr(std::vector input_indices, std::vector output_indices); } // namespace nvbench diff --git a/nvbench/axis_iteration_space.cxx b/nvbench/axis_iteration_space.cxx index b7aee8e..c8a158a 100644 --- a/nvbench/axis_iteration_space.cxx +++ b/nvbench/axis_iteration_space.cxx @@ -23,24 +23,24 @@ namespace nvbench { -axis_space_base::axis_space_base(std::vector input_indices, +iteration_space_base::iteration_space_base(std::vector input_indices, std::vector output_indices) : m_input_indices(std::move(input_indices)) , m_output_indices(std::move(output_indices)) {} -axis_space_base::~axis_space_base() = default; +iteration_space_base::~iteration_space_base() = default; -std::unique_ptr axis_space_base::clone() const +std::unique_ptr iteration_space_base::clone() const { auto clone = this->do_clone(); return clone; } -std::vector> -axis_space_base::clone_as_linear() const +std::vector> +iteration_space_base::clone_as_linear() const { - std::vector> clones; + std::vector> clones; clones.reserve(m_input_indices.size()); for (std::size_t i = 0; i < m_input_indices.size(); ++i) @@ -55,11 +55,11 @@ axis_space_base::clone_as_linear() const namespace { -nvbench::axis_space_base::axes_info -get_axes_info(const nvbench::axis_space_base::axes_type &axes, +nvbench::iteration_space_base::axes_info +get_axes_info(const nvbench::iteration_space_base::axes_type &axes, const std::vector &indices) { - nvbench::axis_space_base::axes_info info; + nvbench::iteration_space_base::axes_info info; info.reserve(indices.size()); for (auto &n : indices) { @@ -69,22 +69,22 @@ get_axes_info(const nvbench::axis_space_base::axes_type &axes, } } // namespace -detail::axis_space_iterator axis_space_base::iter(const axes_type &axes) const +detail::axis_space_iterator iteration_space_base::get_iterator(const axes_type &axes) const { - return this->do_iter(get_axes_info(axes, m_input_indices)); + return this->do_get_iterator(get_axes_info(axes, m_input_indices)); } -std::size_t axis_space_base::size(const axes_type &axes) const +std::size_t iteration_space_base::get_size(const axes_type &axes) const { - return this->do_size(get_axes_info(axes, m_input_indices)); + return this->do_get_size(get_axes_info(axes, m_input_indices)); } -std::size_t axis_space_base::valid_count(const axes_type &axes) const +std::size_t iteration_space_base::get_active_count(const axes_type &axes) const { - return this->do_valid_count(get_axes_info(axes, m_input_indices)); + return this->do_get_active_count(get_axes_info(axes, m_input_indices)); } -bool axis_space_base::contains(std::size_t in_index) const +bool iteration_space_base::contains(std::size_t in_index) const { auto iter = std::find_if(m_input_indices.cbegin(), @@ -95,12 +95,12 @@ bool axis_space_base::contains(std::size_t in_index) const linear_axis_space::linear_axis_space(std::size_t in_index, std::size_t out_index) - : axis_space_base({in_index}, {out_index}) + : iteration_space_base({in_index}, {out_index}) {} linear_axis_space::~linear_axis_space() = default; -detail::axis_space_iterator linear_axis_space::do_iter(axes_info info) const +detail::axis_space_iterator linear_axis_space::do_get_iterator(axes_info info) const { std::size_t loc(m_output_indices[0]); auto update_func = [=](std::size_t inc_index, @@ -112,29 +112,29 @@ detail::axis_space_iterator linear_axis_space::do_iter(axes_info info) const return detail::make_space_iterator(1, info[0].size, update_func); } -std::size_t linear_axis_space::do_size(const axes_info &info) const +std::size_t linear_axis_space::do_get_size(const axes_info &info) const { return info[0].size; } -std::size_t linear_axis_space::do_valid_count(const axes_info &info) const +std::size_t linear_axis_space::do_get_active_count(const axes_info &info) const { return info[0].active_size; } -std::unique_ptr linear_axis_space::do_clone() const +std::unique_ptr linear_axis_space::do_clone() const { return std::make_unique(*this); } zip_axis_space::zip_axis_space(std::vector input_indices, std::vector output_indices) - : axis_space_base(std::move(input_indices), std::move(output_indices)) + : iteration_space_base(std::move(input_indices), std::move(output_indices)) {} zip_axis_space::~zip_axis_space() = default; -detail::axis_space_iterator zip_axis_space::do_iter(axes_info info) const +detail::axis_space_iterator zip_axis_space::do_get_iterator(axes_info info) const { std::vector locs = m_output_indices; auto update_func = [=](std::size_t inc_index, @@ -150,24 +150,24 @@ detail::axis_space_iterator zip_axis_space::do_iter(axes_info info) const return detail::make_space_iterator(locs.size(), info[0].size, update_func); } -std::size_t zip_axis_space::do_size(const axes_info &info) const +std::size_t zip_axis_space::do_get_size(const axes_info &info) const { return info[0].size; } -std::size_t zip_axis_space::do_valid_count(const axes_info &info) const +std::size_t zip_axis_space::do_get_active_count(const axes_info &info) const { return info[0].active_size; } -std::unique_ptr zip_axis_space::do_clone() const +std::unique_ptr zip_axis_space::do_clone() const { return std::make_unique(*this); } user_axis_space::user_axis_space(std::vector input_indices, std::vector output_indices) - : axis_space_base(std::move(input_indices), std::move(output_indices)) + : iteration_space_base(std::move(input_indices), std::move(output_indices)) {} user_axis_space::~user_axis_space() = default; diff --git a/nvbench/benchmark_base.cxx b/nvbench/benchmark_base.cxx index 296cf6c..0a736a9 100644 --- a/nvbench/benchmark_base.cxx +++ b/nvbench/benchmark_base.cxx @@ -70,14 +70,14 @@ std::size_t benchmark_base::get_config_count() const m_axes.get_value_iteration_space().cend(), std::size_t{1}, std::multiplies<>{}, - [&axes](const auto &space) { return space->size(axes); }); + [&axes](const auto &space) { return space->get_size(axes); }); const std::size_t type_count = nvbench::detail::transform_reduce( m_axes.get_type_iteration_space().cbegin(), m_axes.get_type_iteration_space().cend(), std::size_t{1}, std::multiplies<>{}, - [&axes](const auto &space) { return space->valid_count(axes); }); + [&axes](const auto &space) { return space->get_active_count(axes); }); return (value_count * type_count) * std::max(1UL, m_devices.size()); } diff --git a/nvbench/detail/state_generator.cxx b/nvbench/detail/state_generator.cxx index 68803ba..404a891 100644 --- a/nvbench/detail/state_generator.cxx +++ b/nvbench/detail/state_generator.cxx @@ -108,12 +108,12 @@ void state_generator::build_axis_configs() std::for_each(type_space.crbegin(), type_space.crend(), [&ti, &axes_vec](const auto &space) { - ti.add_iteration_space(space->iter(axes_vec)); + ti.add_iteration_space(space->get_iterator(axes_vec)); }); std::for_each(value_space.begin(), value_space.end(), [&vi, &axes_vec](const auto &space) { - vi.add_iteration_space(space->iter(axes_vec)); + vi.add_iteration_space(space->get_iterator(axes_vec)); }); } diff --git a/testing/axes_iteration_space.cu b/testing/axes_iteration_space.cu index 8568124..eb50af7 100644 --- a/testing/axes_iteration_space.cu +++ b/testing/axes_iteration_space.cu @@ -279,7 +279,7 @@ struct under_diag final : nvbench::user_axis_space mutable std::size_t y_pos = 0; mutable std::size_t x_start = 0; - nvbench::detail::axis_space_iterator do_iter(axes_info info) const + nvbench::detail::axis_space_iterator do_get_iterator(axes_info info) const { // generate our increment function auto adv_func = [&, info](std::size_t &inc_index, @@ -316,17 +316,17 @@ struct under_diag final : nvbench::user_axis_space diag_under); } - std::size_t do_size(const axes_info &info) const + std::size_t do_get_size(const axes_info &info) const { return ((info[0].size * (info[1].size + 1)) / 2); } - std::size_t do_valid_count(const axes_info &info) const + std::size_t do_get_active_count(const axes_info &info) const { return ((info[0].size * (info[1].size + 1)) / 2); } - std::unique_ptr do_clone() const + std::unique_ptr do_clone() const { return std::make_unique(*this); } @@ -339,7 +339,7 @@ void test_user_axes() bench.add_float64_axis("F64 Axis", {0., .1, .25, .5, 1.}); bench.add_int64_axis("I64 Axis", {1, 3, 2, 4, 5}); bench.user_iteration_axes( - [](auto... args) -> std::unique_ptr { + [](auto... args) -> std::unique_ptr { return std::make_unique(args...); }, {"F64 Axis", "I64 Axis"}); diff --git a/testing/state_generator.cu b/testing/state_generator.cu index 16e442f..26dc0e3 100644 --- a/testing/state_generator.cu +++ b/testing/state_generator.cu @@ -62,7 +62,7 @@ void test_single_state() std::vector> axes; axes.push_back(std::make_unique(si)); - sg.add_iteration_space(nvbench::linear_axis_space{0, 0}.iter(axes)); + sg.add_iteration_space(nvbench::linear_axis_space{0, 0}.get_iterator(axes)); ASSERT(sg.get_number_of_states() == 1); sg.init(); ASSERT(sg.iter_valid()); @@ -96,10 +96,10 @@ void test_basic() axes.emplace_back(std::make_unique(si3)); axes.emplace_back(std::make_unique(si4)); - sg.add_iteration_space(nvbench::linear_axis_space{0, 0}.iter(axes)); - sg.add_iteration_space(nvbench::linear_axis_space{1, 1}.iter(axes)); - sg.add_iteration_space(nvbench::linear_axis_space{2, 2}.iter(axes)); - sg.add_iteration_space(nvbench::linear_axis_space{3, 3}.iter(axes)); + sg.add_iteration_space(nvbench::linear_axis_space{0, 0}.get_iterator(axes)); + sg.add_iteration_space(nvbench::linear_axis_space{1, 1}.get_iterator(axes)); + sg.add_iteration_space(nvbench::linear_axis_space{2, 2}.get_iterator(axes)); + sg.add_iteration_space(nvbench::linear_axis_space{3, 3}.get_iterator(axes)); ASSERT_MSG(sg.get_number_of_states() == (2 * 3 * 3 * 2), "Actual: {} Expected: {}",