Skip to content

Commit b055e47

Browse files
committed
Remove min-time/max-noise API.
These are now owned by the stdrel stopping criterion, and should not be exposed directly in the benchmark/state/etc APIs. There's a small chance this may affect users that are calling `NVBENCH_BENCH(...).set_min_time(...)` or NVBENCH_BENCH(...).set_max_noise(...)`. These can be updated to `NVBENCH_BENCH(...).set_criterion_param_float64(["min-time"|"max-noise"], ....)`.
1 parent a36e15f commit b055e47

File tree

12 files changed

+17
-142
lines changed

12 files changed

+17
-142
lines changed

nvbench/benchmark_base.cuh

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ struct benchmark_base
5252
template <typename TypeAxes>
5353
explicit benchmark_base(TypeAxes type_axes)
5454
: m_axes(type_axes)
55-
{}
55+
{
56+
this->set_stopping_criterion(nvbench::detail::default_stopping_criterion());
57+
}
5658

5759
virtual ~benchmark_base();
5860

@@ -190,34 +192,6 @@ struct benchmark_base
190192
}
191193
/// @}
192194

193-
/// Accumulate at least this many seconds of timing data per measurement.
194-
/// Only applies to `stdrel` stopping criterion. @{
195-
[[nodiscard]] nvbench::float64_t get_min_time() const
196-
{
197-
return m_criterion_params.get_float64("min-time");
198-
}
199-
benchmark_base &set_min_time(nvbench::float64_t min_time)
200-
{
201-
m_criterion_params.set_float64("min-time", min_time);
202-
return *this;
203-
}
204-
/// @}
205-
206-
/// Specify the maximum amount of noise if a measurement supports noise.
207-
/// Noise is the relative standard deviation:
208-
/// `noise = stdev / mean_time`.
209-
/// Only applies to `stdrel` stopping criterion. @{
210-
[[nodiscard]] nvbench::float64_t get_max_noise() const
211-
{
212-
return m_criterion_params.get_float64("max-noise");
213-
}
214-
benchmark_base &set_max_noise(nvbench::float64_t max_noise)
215-
{
216-
m_criterion_params.set_float64("max-noise", max_noise);
217-
return *this;
218-
}
219-
/// @}
220-
221195
/// If a warmup run finishes in less than `skip_time`, the measurement will
222196
/// be skipped.
223197
/// Extremely fast kernels (< 5000 ns) often timeout before they can
@@ -339,7 +313,7 @@ protected:
339313
nvbench::float32_t m_throttle_recovery_delay{0.05f}; // [seconds]
340314

341315
nvbench::criterion_params m_criterion_params;
342-
std::string m_stopping_criterion{"stdrel"};
316+
std::string m_stopping_criterion{};
343317

344318
private:
345319
// route these through virtuals so the templated subclass can inject type info

nvbench/detail/measure_hot.cu

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ measure_hot_base::measure_hot_base(state &exec_state)
3838
: m_state{exec_state}
3939
, m_launch{exec_state.get_cuda_stream()}
4040
, m_min_samples{exec_state.get_min_samples()}
41-
, m_min_time{exec_state.get_min_time()}
41+
, m_min_time{exec_state.get_criterion_params().has_value("min-time")
42+
? exec_state.get_criterion_params().get_float64("min-time")
43+
: 0.5}
4244
, m_skip_time{exec_state.get_skip_time()}
4345
, m_timeout{exec_state.get_timeout()}
4446
{

nvbench/detail/stdrel_criterion.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ namespace nvbench::detail
2323

2424
stdrel_criterion::stdrel_criterion()
2525
: stopping_criterion_base{"stdrel",
26-
{{"max-noise", nvbench::detail::compat_max_noise()},
27-
{"min-time", nvbench::detail::compat_min_time()}}}
26+
{{"max-noise", 0.005}, // 0.5% stdrel
27+
{"min-time", 0.5}}} // 0.5 seconds
2828
{}
2929

3030
void stdrel_criterion::do_initialize()

nvbench/json_printer.cu

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,6 @@ void json_printer::do_print_benchmark_results(const benchmark_vector &benches)
311311
bench["index"] = bench_index;
312312

313313
bench["min_samples"] = bench_ptr->get_min_samples();
314-
bench["min_time"] = bench_ptr->get_min_time();
315-
bench["max_noise"] = bench_ptr->get_max_noise();
316314
bench["skip_time"] = bench_ptr->get_skip_time();
317315
bench["timeout"] = bench_ptr->get_timeout();
318316

@@ -370,8 +368,6 @@ void json_printer::do_print_benchmark_results(const benchmark_vector &benches)
370368
st["name"] = exec_state.get_axis_values_as_string();
371369

372370
st["min_samples"] = exec_state.get_min_samples();
373-
st["min_time"] = exec_state.get_min_time();
374-
st["max_noise"] = exec_state.get_max_noise();
375371
st["skip_time"] = exec_state.get_skip_time();
376372
st["timeout"] = exec_state.get_timeout();
377373

nvbench/option_parser.cu

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,10 @@ try
10231023
{
10241024
// Any global params must either belong to the default criterion or follow a
10251025
// `--stopping-criterion` arg:
1026-
nvbench::criterion_params params;
1026+
nvbench::criterion_params params =
1027+
criterion_manager::get()
1028+
.get_criterion(nvbench::detail::default_stopping_criterion())
1029+
.get_params();
10271030
if (!params.has_value(name) &&
10281031
std::find(m_global_benchmark_args.cbegin(),
10291032
m_global_benchmark_args.cend(),

nvbench/state.cuh

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -170,40 +170,6 @@ struct state
170170
void set_disable_blocking_kernel(bool v) { m_disable_blocking_kernel = v; }
171171
/// @}
172172

173-
/// Accumulate at least this many seconds of timing data per measurement.
174-
/// Only applies to `stdrel` stopping criterion. @{
175-
[[nodiscard]] nvbench::float64_t get_min_time() const
176-
{
177-
if (m_criterion_params.has_value("min-time"))
178-
{
179-
return m_criterion_params.get_float64("min-time");
180-
}
181-
return 0.;
182-
}
183-
void set_min_time(nvbench::float64_t min_time)
184-
{
185-
m_criterion_params.set_float64("min-time", min_time);
186-
}
187-
/// @}
188-
189-
/// Specify the maximum amount of noise if a measurement supports noise.
190-
/// Noise is the relative standard deviation:
191-
/// `noise = stdev / mean_time`.
192-
/// Only applies to `stdrel` stopping criterion. @{
193-
[[nodiscard]] nvbench::float64_t get_max_noise() const
194-
{
195-
if (m_criterion_params.has_value("max-noise"))
196-
{
197-
return m_criterion_params.get_float64("max-noise");
198-
}
199-
return 1.;
200-
}
201-
void set_max_noise(nvbench::float64_t max_noise)
202-
{
203-
m_criterion_params.set_float64("max-noise", max_noise);
204-
}
205-
/// @}
206-
207173
/// If a warmup run finishes in less than `skip_time`, the measurement will
208174
/// be skipped.
209175
/// Extremely fast kernels (< 5000 ns) often timeout before they can

nvbench/stopping_criterion.cuh

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,7 @@ namespace nvbench
3030

3131
namespace detail
3232
{
33-
34-
constexpr nvbench::float64_t compat_min_time() { return 0.5; } // 0.5 seconds
35-
constexpr nvbench::float64_t compat_max_noise()
36-
{
37-
return 0.005;
38-
} // 0.5% relative standard deviation
39-
33+
inline std::string default_stopping_criterion() { return "stdrel"; }
4034
} // namespace detail
4135

4236
/**
@@ -47,7 +41,7 @@ class criterion_params
4741
nvbench::named_values m_named_values;
4842

4943
public:
50-
criterion_params();
44+
criterion_params() = default;
5145
criterion_params(std::initializer_list<std::pair<std::string, nvbench::named_values::value_type>>);
5246

5347
/**

nvbench/stopping_criterion.cxx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@
2222
namespace nvbench
2323
{
2424

25-
// Default constructor for compatibility with old code
26-
criterion_params::criterion_params()
27-
: criterion_params{{"max-noise", nvbench::detail::compat_max_noise()},
28-
{"min-time", nvbench::detail::compat_min_time()}}
29-
{}
30-
3125
criterion_params::criterion_params(
3226
std::initializer_list<std::pair<std::string, nvbench::named_values::value_type>> list)
3327
{

testing/criterion_params.cu

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,6 @@
2121

2222
#include "test_asserts.cuh"
2323

24-
void test_compat_parameters()
25-
{
26-
nvbench::criterion_params params;
27-
28-
ASSERT(params.has_value("max-noise"));
29-
ASSERT(params.has_value("min-time"));
30-
31-
ASSERT(params.get_float64("max-noise") == nvbench::detail::compat_max_noise());
32-
ASSERT(params.get_float64("min-time") == nvbench::detail::compat_min_time());
33-
}
34-
35-
void test_compat_overwrite()
36-
{
37-
nvbench::criterion_params params;
38-
params.set_float64("max-noise", 40000.0);
39-
params.set_float64("min-time", 42000.0);
40-
41-
ASSERT(params.get_float64("max-noise") == 40000.0);
42-
ASSERT(params.get_float64("min-time") == 42000.0);
43-
}
44-
4524
void test_overwrite()
4625
{
4726
nvbench::criterion_params params;
@@ -54,9 +33,4 @@ void test_overwrite()
5433
ASSERT(params.get_float64("custom") == 4.2);
5534
}
5635

57-
int main()
58-
{
59-
test_compat_parameters();
60-
test_compat_overwrite();
61-
test_overwrite();
62-
}
36+
int main() { test_overwrite(); }

testing/device/noisy_bench.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,4 @@ NVBENCH_BENCH(noisy_bench)
140140
.add_float64_axis("Noise", {0.1, 5., 25.}) // %
141141
// disable this; we want to test that the benchmarking loop will still exit
142142
// when max_noise is never reached:
143-
.set_max_noise(0.0000001);
143+
.set_criterion_param_float64("max-noise", 0.0000001);

0 commit comments

Comments
 (0)