mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-03-14 20:27:24 +00:00
Rename some space -> spaces for clarity.
This commit is contained in:
@@ -41,8 +41,8 @@ namespace nvbench
|
||||
// Holds dynamic axes information.
|
||||
struct axes_metadata
|
||||
{
|
||||
using axes_type = std::vector<std::unique_ptr<nvbench::axis_base>>;
|
||||
using iteration_space_type = std::vector<std::unique_ptr<nvbench::iteration_space_base>>;
|
||||
using axes_type = std::vector<std::unique_ptr<nvbench::axis_base>>;
|
||||
using iteration_spaces_type = std::vector<std::unique_ptr<nvbench::iteration_space_base>>;
|
||||
|
||||
template <typename... TypeAxes>
|
||||
explicit axes_metadata(nvbench::type_list<TypeAxes...>);
|
||||
@@ -71,7 +71,6 @@ struct axes_metadata
|
||||
{
|
||||
const std::size_t start = this->m_axes.size();
|
||||
const std::size_t count = sizeof...(Args);
|
||||
// (this->add_axis(std::forward<Args>(args)), ...);
|
||||
(m_axes.push_back(args.clone()), ...);
|
||||
this->add_zip_space(start, count);
|
||||
}
|
||||
@@ -86,13 +85,13 @@ struct axes_metadata
|
||||
this->add_user_iteration_space(std::move(make), start, count);
|
||||
}
|
||||
|
||||
[[nodiscard]] const iteration_space_type &get_type_iteration_space() const
|
||||
[[nodiscard]] const iteration_spaces_type &get_type_iteration_spaces() const
|
||||
{
|
||||
return m_type_space;
|
||||
return m_type_iteration_spaces;
|
||||
}
|
||||
[[nodiscard]] const iteration_space_type &get_value_iteration_space() const
|
||||
[[nodiscard]] const iteration_spaces_type &get_value_iteration_spaces() const
|
||||
{
|
||||
return m_value_space;
|
||||
return m_value_iteration_spaces;
|
||||
}
|
||||
|
||||
[[nodiscard]] const nvbench::int64_axis &get_int64_axis(std::string_view name) const;
|
||||
@@ -126,8 +125,8 @@ struct axes_metadata
|
||||
private:
|
||||
axes_type m_axes;
|
||||
std::size_t m_type_axe_count = 0;
|
||||
iteration_space_type m_type_space;
|
||||
iteration_space_type m_value_space;
|
||||
iteration_spaces_type m_type_iteration_spaces;
|
||||
iteration_spaces_type m_value_iteration_spaces;
|
||||
|
||||
void add_zip_space(std::size_t first_index, std::size_t count);
|
||||
void add_user_iteration_space(std::function<nvbench::make_user_space_signature> make,
|
||||
@@ -144,22 +143,23 @@ axes_metadata::axes_metadata(nvbench::type_list<TypeAxes...>)
|
||||
auto names = axes_metadata::generate_default_type_axis_names(num_type_axes);
|
||||
|
||||
auto names_iter = names.begin(); // contents will be moved from
|
||||
nvbench::tl::foreach<type_axes_list>(
|
||||
[&axes = m_axes, &spaces = m_type_space, &names_iter]([[maybe_unused]] auto wrapped_type) {
|
||||
// This is always called before other axes are added, so the length of the
|
||||
// axes vector will be the type axis index:
|
||||
const std::size_t type_axis_index = axes.size();
|
||||
nvbench::tl::foreach<type_axes_list>([&axes = m_axes,
|
||||
&spaces = m_type_iteration_spaces,
|
||||
&names_iter]([[maybe_unused]] auto wrapped_type) {
|
||||
// This is always called before other axes are added, so the length of the
|
||||
// axes vector will be the type axis index:
|
||||
const std::size_t type_axis_index = axes.size();
|
||||
|
||||
spaces.push_back(std::make_unique<linear_axis_space>(type_axis_index));
|
||||
spaces.push_back(std::make_unique<linear_axis_space>(type_axis_index));
|
||||
|
||||
// Note:
|
||||
// The word "type" appears 6 times in the next line.
|
||||
// Every. Single. Token.
|
||||
typedef typename decltype(wrapped_type)::type type_list;
|
||||
auto axis = std::make_unique<nvbench::type_axis>(std::move(*names_iter++), type_axis_index);
|
||||
axis->template set_inputs<type_list>();
|
||||
axes.push_back(std::move(axis));
|
||||
});
|
||||
// Note:
|
||||
// The word "type" appears 6 times in the next line.
|
||||
// Every. Single. Token.
|
||||
typedef typename decltype(wrapped_type)::type type_list;
|
||||
auto axis = std::make_unique<nvbench::type_axis>(std::move(*names_iter++), type_axis_index);
|
||||
axis->template set_inputs<type_list>();
|
||||
axes.push_back(std::move(axis));
|
||||
});
|
||||
m_type_axe_count = m_axes.size();
|
||||
}
|
||||
|
||||
|
||||
@@ -41,16 +41,16 @@ axes_metadata::axes_metadata(const axes_metadata &other)
|
||||
}
|
||||
|
||||
m_type_axe_count = other.m_type_axe_count;
|
||||
m_type_space.reserve(other.m_type_space.size());
|
||||
for (const auto &iter : other.m_type_space)
|
||||
m_type_iteration_spaces.reserve(other.m_type_iteration_spaces.size());
|
||||
for (const auto &iter : other.m_type_iteration_spaces)
|
||||
{
|
||||
m_type_space.push_back(iter->clone());
|
||||
m_type_iteration_spaces.push_back(iter->clone());
|
||||
}
|
||||
|
||||
m_value_space.reserve(other.m_value_space.size());
|
||||
for (const auto &iter : other.m_value_space)
|
||||
m_value_iteration_spaces.reserve(other.m_value_iteration_spaces.size());
|
||||
for (const auto &iter : other.m_value_iteration_spaces)
|
||||
{
|
||||
m_value_space.push_back(iter->clone());
|
||||
m_value_iteration_spaces.push_back(iter->clone());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,18 +65,18 @@ axes_metadata &axes_metadata::operator=(const axes_metadata &other)
|
||||
|
||||
m_type_axe_count = other.m_type_axe_count;
|
||||
|
||||
m_type_space.clear();
|
||||
m_type_space.reserve(other.m_type_space.size());
|
||||
for (const auto &iter : other.m_type_space)
|
||||
m_type_iteration_spaces.clear();
|
||||
m_type_iteration_spaces.reserve(other.m_type_iteration_spaces.size());
|
||||
for (const auto &iter : other.m_type_iteration_spaces)
|
||||
{
|
||||
m_type_space.push_back(iter->clone());
|
||||
m_type_iteration_spaces.push_back(iter->clone());
|
||||
}
|
||||
|
||||
m_value_space.clear();
|
||||
m_value_space.reserve(other.m_value_space.size());
|
||||
for (const auto &iter : other.m_value_space)
|
||||
m_value_iteration_spaces.clear();
|
||||
m_value_iteration_spaces.reserve(other.m_value_iteration_spaces.size());
|
||||
for (const auto &iter : other.m_value_iteration_spaces)
|
||||
{
|
||||
m_value_space.push_back(iter->clone());
|
||||
m_value_iteration_spaces.push_back(iter->clone());
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -128,7 +128,7 @@ void axes_metadata::add_string_axis(std::string name, std::vector<std::string> d
|
||||
|
||||
void axes_metadata::add_axis(const axis_base &axis)
|
||||
{
|
||||
m_value_space.push_back(std::make_unique<linear_axis_space>(m_axes.size()));
|
||||
m_value_iteration_spaces.push_back(std::make_unique<linear_axis_space>(m_axes.size()));
|
||||
m_axes.push_back(axis.clone());
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ void axes_metadata::add_zip_space(std::size_t first_index, std::size_t count)
|
||||
|
||||
// add the new tied iteration space
|
||||
auto tied = std::make_unique<zip_axis_space>(std::move(input_indices));
|
||||
m_value_space.push_back(std::move(tied));
|
||||
m_value_iteration_spaces.push_back(std::move(tied));
|
||||
}
|
||||
|
||||
void axes_metadata::add_user_iteration_space(std::function<nvbench::make_user_space_signature> make,
|
||||
@@ -182,7 +182,7 @@ void axes_metadata::add_user_iteration_space(std::function<nvbench::make_user_sp
|
||||
}
|
||||
|
||||
auto user_func = make(std::move(input_indices));
|
||||
m_value_space.push_back(std::move(user_func));
|
||||
m_value_iteration_spaces.push_back(std::move(user_func));
|
||||
}
|
||||
|
||||
const int64_axis &axes_metadata::get_int64_axis(std::string_view name) const
|
||||
|
||||
@@ -77,15 +77,15 @@ std::size_t benchmark_base::get_config_count() const
|
||||
{
|
||||
const auto &axes = m_axes.get_axes();
|
||||
const std::size_t value_count =
|
||||
nvbench::detail::transform_reduce(m_axes.get_value_iteration_space().cbegin(),
|
||||
m_axes.get_value_iteration_space().cend(),
|
||||
nvbench::detail::transform_reduce(m_axes.get_value_iteration_spaces().cbegin(),
|
||||
m_axes.get_value_iteration_spaces().cend(),
|
||||
std::size_t{1},
|
||||
std::multiplies<>{},
|
||||
[&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(),
|
||||
m_axes.get_type_iteration_spaces().cbegin(),
|
||||
m_axes.get_type_iteration_spaces().cend(),
|
||||
std::size_t{1},
|
||||
std::multiplies<>{},
|
||||
[&axes](const auto &space) { return space->get_active_count(axes); });
|
||||
|
||||
@@ -92,8 +92,8 @@ state_generator::state_generator(const benchmark_base &bench)
|
||||
void state_generator::build_axis_configs()
|
||||
{
|
||||
const axes_metadata &axes = m_benchmark.get_axes();
|
||||
const auto &type_space = axes.get_type_iteration_space();
|
||||
const auto &value_space = axes.get_value_iteration_space();
|
||||
const auto &type_spaces = axes.get_type_iteration_spaces();
|
||||
const auto &value_spaces = axes.get_value_iteration_spaces();
|
||||
|
||||
state_iterator ti;
|
||||
state_iterator vi;
|
||||
@@ -105,12 +105,16 @@ void state_generator::build_axis_configs()
|
||||
// instantiations.
|
||||
{
|
||||
const auto &axes_vec = axes.get_axes();
|
||||
std::for_each(type_space.crbegin(), type_space.crend(), [&ti, &axes_vec](const auto &space) {
|
||||
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->get_iterator(axes_vec));
|
||||
});
|
||||
std::for_each(type_spaces.crbegin(), //
|
||||
type_spaces.crend(),
|
||||
[&ti, &axes_vec](const auto &space) {
|
||||
ti.add_iteration_space(space->get_iterator(axes_vec));
|
||||
});
|
||||
std::for_each(value_spaces.begin(), //
|
||||
value_spaces.end(),
|
||||
[&vi, &axes_vec](const auto &space) {
|
||||
vi.add_iteration_space(space->get_iterator(axes_vec));
|
||||
});
|
||||
}
|
||||
|
||||
m_type_axis_configs.clear();
|
||||
|
||||
Reference in New Issue
Block a user