Skip to content

Commit 4defa02

Browse files
committed
Precommit reformatting.
1 parent 250d755 commit 4defa02

18 files changed

+145
-214
lines changed

examples/custom_iteration_spaces.cu

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,15 @@ void copy_sweep_grid_shape(nvbench::state &state)
4848
thrust::device_vector<nvbench::int32_t> in(num_values, 0);
4949
thrust::device_vector<nvbench::int32_t> out(num_values, 0);
5050

51-
state.exec(
52-
[block_size,
53-
num_blocks,
54-
num_values,
55-
in_ptr = thrust::raw_pointer_cast(in.data()),
56-
out_ptr = thrust::raw_pointer_cast(out.data())](nvbench::launch &launch) {
57-
nvbench::copy_kernel<<<num_blocks, block_size, 0, launch.get_stream()>>>(
58-
in_ptr,
59-
out_ptr,
60-
num_values);
61-
});
51+
state.exec([block_size,
52+
num_blocks,
53+
num_values,
54+
in_ptr = thrust::raw_pointer_cast(in.data()),
55+
out_ptr = thrust::raw_pointer_cast(out.data())](nvbench::launch &launch) {
56+
nvbench::copy_kernel<<<num_blocks, block_size, 0, launch.get_stream()>>>(in_ptr,
57+
out_ptr,
58+
num_values);
59+
});
6260
}
6361

6462
//==============================================================================
@@ -100,8 +98,7 @@ struct under_diag final : nvbench::user_axis_space
10098
nvbench::detail::axis_space_iterator do_get_iterator(axes_info info) const
10199
{
102100
// generate our increment function
103-
auto adv_func = [&, info](std::size_t &inc_index,
104-
std::size_t /*len*/) -> bool {
101+
auto adv_func = [&, info](std::size_t &inc_index, std::size_t /*len*/) -> bool {
105102
inc_index++;
106103
x_pos++;
107104
if (x_pos == info[0].size)
@@ -114,19 +111,15 @@ struct under_diag final : nvbench::user_axis_space
114111
};
115112

116113
// our update function
117-
auto diag_under =
118-
[&, info](std::size_t,
119-
std::vector<nvbench::detail::axis_index>::iterator start,
120-
std::vector<nvbench::detail::axis_index>::iterator end) {
121-
start->index = x_pos;
122-
end->index = y_pos;
123-
};
114+
auto diag_under = [&, info](std::size_t,
115+
std::vector<nvbench::detail::axis_index>::iterator start,
116+
std::vector<nvbench::detail::axis_index>::iterator end) {
117+
start->index = x_pos;
118+
end->index = y_pos;
119+
};
124120

125121
const size_t iteration_length = ((info[0].size * (info[1].size + 1)) / 2);
126-
return nvbench::detail::axis_space_iterator(info,
127-
iteration_length,
128-
adv_func,
129-
diag_under);
122+
return nvbench::detail::axis_space_iterator(info, iteration_length, adv_func, diag_under);
130123
}
131124

132125
std::size_t do_get_size(const axes_info &info) const
@@ -184,29 +177,20 @@ struct gauss final : nvbench::user_axis_space
184177
}
185178

186179
// our update function
187-
auto gauss_func =
188-
[=](std::size_t index,
189-
std::vector<nvbench::detail::axis_index>::iterator start,
190-
std::vector<nvbench::detail::axis_index>::iterator) {
191-
start->index = gauss_indices[index];
192-
};
193-
194-
return nvbench::detail::axis_space_iterator(info,
195-
iteration_length,
196-
gauss_func);
180+
auto gauss_func = [=](std::size_t index,
181+
std::vector<nvbench::detail::axis_index>::iterator start,
182+
std::vector<nvbench::detail::axis_index>::iterator) {
183+
start->index = gauss_indices[index];
184+
};
185+
186+
return nvbench::detail::axis_space_iterator(info, iteration_length, gauss_func);
197187
}
198188

199189
std::size_t do_get_size(const axes_info &info) const { return info[0].size; }
200190

201-
std::size_t do_get_active_count(const axes_info &info) const
202-
{
203-
return info[0].size;
204-
}
191+
std::size_t do_get_active_count(const axes_info &info) const { return info[0].size; }
205192

206-
std::unique_ptr<iteration_space_base> do_clone() const
207-
{
208-
return std::make_unique<gauss>(*this);
209-
}
193+
std::unique_ptr<iteration_space_base> do_clone() const { return std::make_unique<gauss>(*this); }
210194
};
211195
//==============================================================================
212196
// Dual parameter sweep:
@@ -216,8 +200,7 @@ void dual_float64_axis(nvbench::state &state)
216200
const auto duration_B = state.get_float64("Duration_B");
217201

218202
state.exec([duration_A, duration_B](nvbench::launch &launch) {
219-
nvbench::sleep_kernel<<<1, 1, 0, launch.get_stream()>>>(duration_A +
220-
duration_B);
203+
nvbench::sleep_kernel<<<1, 1, 0, launch.get_stream()>>>(duration_A + duration_B);
221204
});
222205
}
223206
NVBENCH_BENCH(dual_float64_axis)

nvbench/axes_metadata.cuh

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ namespace nvbench
4141
// Holds dynamic axes information.
4242
struct axes_metadata
4343
{
44-
using axes_type = std::vector<std::unique_ptr<nvbench::axis_base>>;
45-
using iteration_space_type =
46-
std::vector<std::unique_ptr<nvbench::iteration_space_base>>;
44+
using axes_type = std::vector<std::unique_ptr<nvbench::axis_base>>;
45+
using iteration_space_type = std::vector<std::unique_ptr<nvbench::iteration_space_base>>;
4746

4847
template <typename... TypeAxes>
4948
explicit axes_metadata(nvbench::type_list<TypeAxes...>);
@@ -78,9 +77,8 @@ struct axes_metadata
7877
}
7978

8079
template <typename... Args>
81-
void add_user_iteration_axes(
82-
std::function<nvbench::make_user_space_signature> make,
83-
Args &&...args)
80+
void add_user_iteration_axes(std::function<nvbench::make_user_space_signature> make,
81+
Args &&...args)
8482
{
8583
const std::size_t start = this->m_axes.size();
8684
const std::size_t count = sizeof...(Args);
@@ -132,10 +130,9 @@ private:
132130
iteration_space_type m_value_space;
133131

134132
void add_zip_space(std::size_t first_index, std::size_t count);
135-
void add_user_iteration_space(
136-
std::function<nvbench::make_user_space_signature> make,
137-
std::size_t first_index,
138-
std::size_t count);
133+
void add_user_iteration_space(std::function<nvbench::make_user_space_signature> make,
134+
std::size_t first_index,
135+
std::size_t count);
139136
};
140137

141138
template <typename... TypeAxes>
@@ -148,14 +145,12 @@ axes_metadata::axes_metadata(nvbench::type_list<TypeAxes...>)
148145

149146
auto names_iter = names.begin(); // contents will be moved from
150147
nvbench::tl::foreach<type_axes_list>(
151-
[&axes = m_axes, &spaces = m_type_space, &names_iter](
152-
[[maybe_unused]] auto wrapped_type) {
148+
[&axes = m_axes, &spaces = m_type_space, &names_iter]([[maybe_unused]] auto wrapped_type) {
153149
// This is always called before other axes are added, so the length of the
154150
// axes vector will be the type axis index:
155151
const std::size_t type_axis_index = axes.size();
156152

157-
spaces.push_back(
158-
std::make_unique<linear_axis_space>(type_axis_index));
153+
spaces.push_back(std::make_unique<linear_axis_space>(type_axis_index));
159154

160155
// Note:
161156
// The word "type" appears 6 times in the next line.

nvbench/axes_metadata.cxx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@
2424

2525
#include <algorithm>
2626
#include <cassert>
27+
#include <iostream>
2728
#include <numeric>
2829
#include <stdexcept>
2930
#include <unordered_set>
3031

31-
#include <iostream>
32-
3332
namespace nvbench
3433
{
3534

@@ -129,16 +128,15 @@ void axes_metadata::add_string_axis(std::string name, std::vector<std::string> d
129128

130129
void axes_metadata::add_axis(const axis_base &axis)
131130
{
132-
m_value_space.push_back(
133-
std::make_unique<linear_axis_space>(m_axes.size()));
131+
m_value_space.push_back(std::make_unique<linear_axis_space>(m_axes.size()));
134132
m_axes.push_back(axis.clone());
135133
}
136134

137135
void axes_metadata::add_zip_space(std::size_t first_index, std::size_t count)
138136
{
139137
NVBENCH_THROW_IF((count < 2),
140138
std::runtime_error,
141-
"At least two axi ( {} provided ) need to be provided "
139+
"At least two axes ( {} provided ) need to be provided "
142140
"when using zip_axes.",
143141
count);
144142

@@ -151,13 +149,13 @@ void axes_metadata::add_zip_space(std::size_t first_index, std::size_t count)
151149
{
152150
NVBENCH_THROW_IF((m_axes[i]->get_type() == nvbench::axis_type::type),
153151
std::runtime_error,
154-
"Currently no support for tieing type axis ( {} ).",
152+
"Currently no support for zipping type axis ( {} ).",
155153
m_axes[i]->get_name());
156154

157155
NVBENCH_THROW_IF((m_axes[i]->get_size() < expected_size),
158156
std::runtime_error,
159-
"All axes that are tied together must be atleast as long "
160-
"the first axi provided ( {} ).",
157+
"All axes that are zipped together must be at least as long "
158+
"as the first axis provided ( {} ).",
161159
expected_size);
162160
}
163161

@@ -166,10 +164,9 @@ void axes_metadata::add_zip_space(std::size_t first_index, std::size_t count)
166164
m_value_space.push_back(std::move(tied));
167165
}
168166

169-
void axes_metadata::add_user_iteration_space(
170-
std::function<nvbench::make_user_space_signature> make,
171-
std::size_t first_index,
172-
std::size_t count)
167+
void axes_metadata::add_user_iteration_space(std::function<nvbench::make_user_space_signature> make,
168+
std::size_t first_index,
169+
std::size_t count)
173170
{
174171
// compute the numeric indice for each name we have
175172
std::vector<std::size_t> input_indices(count);

nvbench/benchmark_base.cuh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ struct benchmark_base
116116
/// @param[axes] a set of axis_base to be added to the benchmark
117117
/// and zipped together
118118
///
119-
template<typename... Axes>
120-
benchmark_base &add_zip_axes(Axes&&... axes)
119+
template <typename... Axes>
120+
benchmark_base &add_zip_axes(Axes &&...axes)
121121
{
122122
m_axes.add_zip_axes(std::forward<Axes>(axes)...);
123123
return *this;
@@ -135,8 +135,8 @@ struct benchmark_base
135135
/// which constructs the user iteration space, and the reseet are axis_base to be
136136
/// added to the benchmark and iterated using the user iteration space
137137
///
138-
template<typename... ConstructorAndAxes>
139-
benchmark_base &add_user_iteration_axes(ConstructorAndAxes&&... args)
138+
template <typename... ConstructorAndAxes>
139+
benchmark_base &add_user_iteration_axes(ConstructorAndAxes &&...args)
140140
{
141141
m_axes.add_user_iteration_axes(std::forward<ConstructorAndAxes>(args)...);
142142
return *this;

nvbench/benchmark_base.cxx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ benchmark_base &benchmark_base::add_device(int device_id)
7575

7676
std::size_t benchmark_base::get_config_count() const
7777
{
78-
const auto& axes = m_axes.get_axes();
79-
const std::size_t value_count = nvbench::detail::transform_reduce(
80-
m_axes.get_value_iteration_space().cbegin(),
81-
m_axes.get_value_iteration_space().cend(),
82-
std::size_t{1},
83-
std::multiplies<>{},
84-
[&axes](const auto &space) { return space->get_size(axes); });
78+
const auto &axes = m_axes.get_axes();
79+
const std::size_t value_count =
80+
nvbench::detail::transform_reduce(m_axes.get_value_iteration_space().cbegin(),
81+
m_axes.get_value_iteration_space().cend(),
82+
std::size_t{1},
83+
std::multiplies<>{},
84+
[&axes](const auto &space) { return space->get_size(axes); });
8585

8686
const std::size_t type_count = nvbench::detail::transform_reduce(
8787
m_axes.get_type_iteration_space().cbegin(),

nvbench/detail/axes_iterator.cuh

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,16 @@ struct axis_index
3434
{
3535
axis_index() = default;
3636

37-
explicit axis_index(const axis_base *axi)
37+
explicit axis_index(const axis_base *axis)
3838
: index(0)
39-
, name(axi->get_name())
40-
, type(axi->get_type())
41-
, size(axi->get_size())
42-
, active_size(axi->get_size())
39+
, name(axis->get_name())
40+
, type(axis->get_type())
41+
, size(axis->get_size())
42+
, active_size(axis->get_size())
4343
{
4444
if (type == nvbench::axis_type::type)
4545
{
46-
active_size =
47-
static_cast<const nvbench::type_axis *>(axi)->get_active_count();
46+
active_size = static_cast<const nvbench::type_axis *>(axis)->get_active_count();
4847
}
4948
}
5049
std::size_t index;
@@ -62,30 +61,25 @@ struct axis_space_iterator
6261
axes_info::iterator start,
6362
axes_info::iterator end);
6463

65-
axis_space_iterator(
66-
std::vector<detail::axis_index> info,
67-
std::size_t iter_count,
68-
std::function<axis_space_iterator::AdvanceSignature> &&advance,
69-
std::function<axis_space_iterator::UpdateSignature> &&update)
64+
axis_space_iterator(std::vector<detail::axis_index> info,
65+
std::size_t iter_count,
66+
std::function<axis_space_iterator::AdvanceSignature> &&advance,
67+
std::function<axis_space_iterator::UpdateSignature> &&update)
7068
: m_info(info)
7169
, m_iteration_size(iter_count)
7270
, m_advance(std::move(advance))
7371
, m_update(std::move(update))
7472
{}
7573

76-
axis_space_iterator(
77-
std::vector<detail::axis_index> info,
78-
std::size_t iter_count,
79-
std::function<axis_space_iterator::UpdateSignature> &&update)
74+
axis_space_iterator(std::vector<detail::axis_index> info,
75+
std::size_t iter_count,
76+
std::function<axis_space_iterator::UpdateSignature> &&update)
8077
: m_info(info)
8178
, m_iteration_size(iter_count)
8279
, m_update(std::move(update))
8380
{}
8481

85-
[[nodiscard]] bool next()
86-
{
87-
return this->m_advance(m_current_index, m_iteration_size);
88-
}
82+
[[nodiscard]] bool next() { return this->m_advance(m_current_index, m_iteration_size); }
8983

9084
void update_indices(std::vector<axis_index> &indices) const
9185
{
@@ -97,8 +91,7 @@ struct axis_space_iterator
9791

9892
axes_info m_info;
9993
std::size_t m_iteration_size = 1;
100-
std::function<AdvanceSignature> m_advance = [](std::size_t &current_index,
101-
std::size_t length) {
94+
std::function<AdvanceSignature> m_advance = [](std::size_t &current_index, std::size_t length) {
10295
(current_index + 1 == length) ? current_index = 0 : current_index++;
10396
return (current_index == 0); // we rolled over
10497
};

nvbench/detail/state_generator.cuh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ struct state_iterator
8383
void next();
8484

8585
std::vector<axis_space_iterator> m_space;
86-
std::size_t m_axes_count = 0;
86+
std::size_t m_axes_count = 0;
8787
std::size_t m_current_space = 0;
8888
std::size_t m_current_iteration = 0;
8989
std::size_t m_max_iteration = 1;

0 commit comments

Comments
 (0)