Skip to content

Commit

Permalink
remove need for make_space_iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmaynard committed Aug 31, 2022
1 parent dc7e2b7 commit 0ade18a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 16 deletions.
36 changes: 25 additions & 11 deletions nvbench/detail/axes_iterator.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@ struct axis_space_iterator
using UpdateSignature = void(std::size_t index,
std::vector<axis_index> &indices);

axis_space_iterator(
std::size_t axes_count,
std::size_t iter_count,
std::function<axis_space_iterator::AdvanceSignature> &&advance,
std::function<axis_space_iterator::UpdateSignature> &&update)
: m_number_of_axes(axes_count)
, m_iteration_size(iter_count)
, m_advance(std::move(advance))
, m_update(std::move(update))
{}

axis_space_iterator(
std::size_t axes_count,
std::size_t iter_count,
std::function<axis_space_iterator::UpdateSignature> &&update)
: m_number_of_axes(axes_count)
, m_iteration_size(iter_count)
, m_update(std::move(update))
{}

[[nodiscard]] bool inc()
{
return this->m_advance(m_current_index, m_iteration_size);
Expand Down Expand Up @@ -89,24 +109,18 @@ inline axis_space_iterator make_space_iterator(
std::function<axis_space_iterator::AdvanceSignature> &&advance,
std::function<axis_space_iterator::UpdateSignature> &&update)
{
axis_space_iterator iter;
iter.m_number_of_axes = axes_count;
iter.m_iteration_size = iter_count;
iter.m_advance = std::move(advance);
iter.m_update = std::move(update);
return iter;
return axis_space_iterator(axes_count,
iter_count,
std::move(advance),
std::move(update));
}

inline axis_space_iterator make_space_iterator(
std::size_t axes_count,
std::size_t iter_count,
std::function<axis_space_iterator::UpdateSignature> &&update)
{
axis_space_iterator iter;
iter.m_number_of_axes = axes_count;
iter.m_iteration_size = iter_count;
iter.m_update = std::move(update);
return iter;
return axis_space_iterator(axes_count, iter_count, std::move(update));
}

} // namespace detail
Expand Down
4 changes: 2 additions & 2 deletions nvbench/linear_axis_space.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ linear_axis_space::~linear_axis_space() = default;

detail::axis_space_iterator linear_axis_space::do_get_iterator(axes_info info) const
{
std::size_t loc(m_output_indices[0]);
std::size_t loc{m_output_indices[0]};
auto update_func = [=](std::size_t inc_index,
std::vector<detail::axis_index> &indices) {
indices[loc] = info[0];
indices[loc].index = inc_index;
};

return detail::make_space_iterator(1, info[0].size, update_func);
return detail::axis_space_iterator(1, info[0].size, update_func);
}

std::size_t linear_axis_space::do_get_size(const axes_info &info) const
Expand Down
2 changes: 1 addition & 1 deletion nvbench/user_axis_space.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace nvbench
* indices[locs[i]] = temp;
* }
* };
* return detail::make_space_iterator(locs.size(), (info[0].size/3), adv_func, update_func);
* return detail::axis_space_iterator(locs.size(), (info[0].size/3), adv_func, update_func);
* }
*
* std::size_t do_get_size(const axes_info &info) const { return (info[0].size/3); }
Expand Down
2 changes: 1 addition & 1 deletion nvbench/zip_axis_space.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ detail::axis_space_iterator zip_axis_space::do_get_iterator(axes_info info) cons
}
};

return detail::make_space_iterator(locs.size(), info[0].size, update_func);
return detail::axis_space_iterator(locs.size(), info[0].size, update_func);
}

std::size_t zip_axis_space::do_get_size(const axes_info &info) const
Expand Down
2 changes: 1 addition & 1 deletion testing/axes_iteration_space.cu
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ struct under_diag final : nvbench::user_axis_space
};

const size_t iteration_length = ((info[0].size * (info[1].size + 1)) / 2);
return nvbench::detail::make_space_iterator(2,
return nvbench::detail::axis_space_iterator(2,
iteration_length,
adv_func,
diag_under);
Expand Down

0 comments on commit 0ade18a

Please sign in to comment.