Skip to content

Commit 282754b

Browse files
committed
remove need for make_space_iterator
1 parent dc7e2b7 commit 282754b

File tree

6 files changed

+32
-18
lines changed

6 files changed

+32
-18
lines changed

examples/custom_iteration_spaces.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ struct under_diag final : nvbench::user_axis_space
130130
};
131131

132132
const size_t iteration_length = ((info[0].size * (info[1].size + 1)) / 2);
133-
return nvbench::detail::make_space_iterator(2,
133+
return nvbench::detail::axis_space_iterator(2,
134134
iteration_length,
135135
adv_func,
136136
diag_under);
@@ -201,7 +201,7 @@ struct gauss final : nvbench::user_axis_space
201201
indices[locs[0]] = temp;
202202
};
203203

204-
return nvbench::detail::make_space_iterator(1,
204+
return nvbench::detail::axis_space_iterator(1,
205205
iteration_length,
206206
gauss_func);
207207
}

nvbench/detail/axes_iterator.cuh

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@ struct axis_space_iterator
6060
using UpdateSignature = void(std::size_t index,
6161
std::vector<axis_index> &indices);
6262

63+
axis_space_iterator(
64+
std::size_t axes_count,
65+
std::size_t iter_count,
66+
std::function<axis_space_iterator::AdvanceSignature> &&advance,
67+
std::function<axis_space_iterator::UpdateSignature> &&update)
68+
: m_number_of_axes(axes_count)
69+
, m_iteration_size(iter_count)
70+
, m_advance(std::move(advance))
71+
, m_update(std::move(update))
72+
{}
73+
74+
axis_space_iterator(
75+
std::size_t axes_count,
76+
std::size_t iter_count,
77+
std::function<axis_space_iterator::UpdateSignature> &&update)
78+
: m_number_of_axes(axes_count)
79+
, m_iteration_size(iter_count)
80+
, m_update(std::move(update))
81+
{}
82+
6383
[[nodiscard]] bool inc()
6484
{
6585
return this->m_advance(m_current_index, m_iteration_size);
@@ -89,24 +109,18 @@ inline axis_space_iterator make_space_iterator(
89109
std::function<axis_space_iterator::AdvanceSignature> &&advance,
90110
std::function<axis_space_iterator::UpdateSignature> &&update)
91111
{
92-
axis_space_iterator iter;
93-
iter.m_number_of_axes = axes_count;
94-
iter.m_iteration_size = iter_count;
95-
iter.m_advance = std::move(advance);
96-
iter.m_update = std::move(update);
97-
return iter;
112+
return axis_space_iterator(axes_count,
113+
iter_count,
114+
std::move(advance),
115+
std::move(update));
98116
}
99117

100118
inline axis_space_iterator make_space_iterator(
101119
std::size_t axes_count,
102120
std::size_t iter_count,
103121
std::function<axis_space_iterator::UpdateSignature> &&update)
104122
{
105-
axis_space_iterator iter;
106-
iter.m_number_of_axes = axes_count;
107-
iter.m_iteration_size = iter_count;
108-
iter.m_update = std::move(update);
109-
return iter;
123+
return axis_space_iterator(axes_count, iter_count, std::move(update));
110124
}
111125

112126
} // namespace detail

nvbench/linear_axis_space.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ linear_axis_space::~linear_axis_space() = default;
3232

3333
detail::axis_space_iterator linear_axis_space::do_get_iterator(axes_info info) const
3434
{
35-
std::size_t loc(m_output_indices[0]);
35+
std::size_t loc{m_output_indices[0]};
3636
auto update_func = [=](std::size_t inc_index,
3737
std::vector<detail::axis_index> &indices) {
3838
indices[loc] = info[0];
3939
indices[loc].index = inc_index;
4040
};
4141

42-
return detail::make_space_iterator(1, info[0].size, update_func);
42+
return detail::axis_space_iterator(1, info[0].size, update_func);
4343
}
4444

4545
std::size_t linear_axis_space::do_get_size(const axes_info &info) const

nvbench/user_axis_space.cuh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace nvbench
6060
* indices[locs[i]] = temp;
6161
* }
6262
* };
63-
* return detail::make_space_iterator(locs.size(), (info[0].size/3), adv_func, update_func);
63+
* return detail::axis_space_iterator(locs.size(), (info[0].size/3), adv_func, update_func);
6464
* }
6565
*
6666
* std::size_t do_get_size(const axes_info &info) const { return (info[0].size/3); }

nvbench/zip_axis_space.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ detail::axis_space_iterator zip_axis_space::do_get_iterator(axes_info info) cons
4343
}
4444
};
4545

46-
return detail::make_space_iterator(locs.size(), info[0].size, update_func);
46+
return detail::axis_space_iterator(locs.size(), info[0].size, update_func);
4747
}
4848

4949
std::size_t zip_axis_space::do_get_size(const axes_info &info) const

testing/axes_iteration_space.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ struct under_diag final : nvbench::user_axis_space
222222
};
223223

224224
const size_t iteration_length = ((info[0].size * (info[1].size + 1)) / 2);
225-
return nvbench::detail::make_space_iterator(2,
225+
return nvbench::detail::axis_space_iterator(2,
226226
iteration_length,
227227
adv_func,
228228
diag_under);

0 commit comments

Comments
 (0)