mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-04-30 03:31:13 +00:00
Store percentages as ratios.
Human-readable outputs (md) and CLI inputs still use percentages. In-memory and machine-readable outputs (csv, json) use ratios. This is the convention that spreadsheet apps expect. Fixes #2.
This commit is contained in:
@@ -68,8 +68,8 @@
|
|||||||
|
|
||||||
* `--max-noise <value>`
|
* `--max-noise <value>`
|
||||||
* Gather samples until the error in the measurement drops below `<value>`.
|
* Gather samples until the error in the measurement drops below `<value>`.
|
||||||
* Noise is computed as the percent relative standard deviation.
|
* Noise is specified as the percent relative standard deviation.
|
||||||
* Default is 0.5%.
|
* Default is 0.5% (`--max-noise 0.5`)
|
||||||
* Only applies to Cold measurements.
|
* Only applies to Cold measurements.
|
||||||
* If both GPU and CPU times are gathered, this applies to GPU noise only.
|
* If both GPU and CPU times are gathered, this applies to GPU noise only.
|
||||||
* Applies to the most recent `--benchmark`, or all benchmarks if specified
|
* Applies to the most recent `--benchmark`, or all benchmarks if specified
|
||||||
|
|||||||
@@ -185,8 +185,8 @@ struct benchmark_base
|
|||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// Specify the maximum amount of noise if a measurement supports noise.
|
/// Specify the maximum amount of noise if a measurement supports noise.
|
||||||
/// Noise is the relative standard deviation expressed as a percentage:
|
/// Noise is the relative standard deviation:
|
||||||
/// `noise = 100 * (stdev / mean_time)`. @{
|
/// `noise = stdev / mean_time`. @{
|
||||||
[[nodiscard]] nvbench::float64_t get_max_noise() const { return m_max_noise; }
|
[[nodiscard]] nvbench::float64_t get_max_noise() const { return m_max_noise; }
|
||||||
benchmark_base &set_max_noise(nvbench::float64_t max_noise)
|
benchmark_base &set_max_noise(nvbench::float64_t max_noise)
|
||||||
{
|
{
|
||||||
@@ -239,7 +239,7 @@ protected:
|
|||||||
|
|
||||||
nvbench::int64_t m_min_samples{10};
|
nvbench::int64_t m_min_samples{10};
|
||||||
nvbench::float64_t m_min_time{0.5};
|
nvbench::float64_t m_min_time{0.5};
|
||||||
nvbench::float64_t m_max_noise{0.5}; // 0.5% relative standard deviation
|
nvbench::float64_t m_max_noise{0.005}; // 0.5% relative standard deviation
|
||||||
|
|
||||||
nvbench::float64_t m_skip_time{-1.};
|
nvbench::float64_t m_skip_time{-1.};
|
||||||
nvbench::float64_t m_timeout{15.};
|
nvbench::float64_t m_timeout{15.};
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ void csv_printer::do_print_benchmark_results(const benchmark_vector &benches)
|
|||||||
}
|
}
|
||||||
else if (hint == "percentage")
|
else if (hint == "percentage")
|
||||||
{
|
{
|
||||||
table.add_cell(row, key, header + " (%)", std::move(value));
|
table.add_cell(row, key, header, std::move(value));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ void measure_cold_base::generate_summaries()
|
|||||||
summ.set_string("description",
|
summ.set_string("description",
|
||||||
"Global device memory throughput as a percentage of the "
|
"Global device memory throughput as a percentage of the "
|
||||||
"device's peak bandwidth.");
|
"device's peak bandwidth.");
|
||||||
summ.set_float64("value", avg_used_gmem_bw / peak_gmem_bw * 100.);
|
summ.set_float64("value", avg_used_gmem_bw / peak_gmem_bw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,8 +170,8 @@ void measure_cold_base::generate_summaries()
|
|||||||
"while over noise threshold ({:0.2f}% > "
|
"while over noise threshold ({:0.2f}% > "
|
||||||
"{:0.2f}%)",
|
"{:0.2f}%)",
|
||||||
timeout,
|
timeout,
|
||||||
m_cuda_noise,
|
m_cuda_noise * 100,
|
||||||
m_max_noise));
|
m_max_noise * 100));
|
||||||
}
|
}
|
||||||
if (m_total_samples < m_min_samples)
|
if (m_total_samples < m_min_samples)
|
||||||
{
|
{
|
||||||
@@ -221,8 +221,7 @@ void measure_cold_base::check_skip_time(nvbench::float64_t warmup_time)
|
|||||||
|
|
||||||
void measure_cold_base::block_stream()
|
void measure_cold_base::block_stream()
|
||||||
{
|
{
|
||||||
m_blocker.block(m_launch.get_stream(),
|
m_blocker.block(m_launch.get_stream(), m_state.get_blocking_kernel_timeout());
|
||||||
m_state.get_blocking_kernel_timeout());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace nvbench::detail
|
} // namespace nvbench::detail
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ protected:
|
|||||||
nvbench::blocking_kernel m_blocker;
|
nvbench::blocking_kernel m_blocker;
|
||||||
|
|
||||||
nvbench::int64_t m_min_samples{};
|
nvbench::int64_t m_min_samples{};
|
||||||
nvbench::float64_t m_max_noise{}; // % rel stdev
|
nvbench::float64_t m_max_noise{}; // rel stdev
|
||||||
nvbench::float64_t m_min_time{};
|
nvbench::float64_t m_min_time{};
|
||||||
|
|
||||||
nvbench::float64_t m_skip_time{};
|
nvbench::float64_t m_skip_time{};
|
||||||
@@ -108,8 +108,8 @@ protected:
|
|||||||
nvbench::int64_t m_total_samples{};
|
nvbench::int64_t m_total_samples{};
|
||||||
nvbench::float64_t m_total_cuda_time{};
|
nvbench::float64_t m_total_cuda_time{};
|
||||||
nvbench::float64_t m_total_cpu_time{};
|
nvbench::float64_t m_total_cpu_time{};
|
||||||
nvbench::float64_t m_cuda_noise{}; // % rel stdev
|
nvbench::float64_t m_cuda_noise{}; // rel stdev
|
||||||
nvbench::float64_t m_cpu_noise{}; // % rel stdev
|
nvbench::float64_t m_cpu_noise{}; // rel stdev
|
||||||
|
|
||||||
std::vector<nvbench::float64_t> m_cuda_times;
|
std::vector<nvbench::float64_t> m_cuda_times;
|
||||||
std::vector<nvbench::float64_t> m_cpu_times;
|
std::vector<nvbench::float64_t> m_cpu_times;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace nvbench::detail
|
|||||||
* vector, return a measure of the noise in the samples.
|
* vector, return a measure of the noise in the samples.
|
||||||
*
|
*
|
||||||
* The noise metric is the relative unbiased sample standard deviation
|
* The noise metric is the relative unbiased sample standard deviation
|
||||||
* expressed as a percentage: (std_dev / mean) * 100.
|
* (std_dev / mean).
|
||||||
*/
|
*/
|
||||||
inline nvbench::float64_t
|
inline nvbench::float64_t
|
||||||
compute_noise(const std::vector<nvbench::float64_t> &data,
|
compute_noise(const std::vector<nvbench::float64_t> &data,
|
||||||
@@ -58,8 +58,7 @@ compute_noise(const std::vector<nvbench::float64_t> &data,
|
|||||||
}) /
|
}) /
|
||||||
(num - 1);
|
(num - 1);
|
||||||
const auto abs_stdev = std::sqrt(variance);
|
const auto abs_stdev = std::sqrt(variance);
|
||||||
const auto rel_stdev = abs_stdev / mean;
|
return abs_stdev / mean;
|
||||||
return rel_stdev * 100.;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace nvbench::detail
|
} // namespace nvbench::detail
|
||||||
|
|||||||
@@ -459,7 +459,7 @@ std::string markdown_printer::do_format_sample_size(const summary &data)
|
|||||||
std::string markdown_printer::do_format_percentage(const summary &data)
|
std::string markdown_printer::do_format_percentage(const summary &data)
|
||||||
{
|
{
|
||||||
const auto percentage = data.get_float64("value");
|
const auto percentage = data.get_float64("value");
|
||||||
return fmt::format("{:.2f}%", percentage);
|
return fmt::format("{:.2f}%", percentage * 100.);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace nvbench
|
} // namespace nvbench
|
||||||
|
|||||||
@@ -807,8 +807,8 @@ try
|
|||||||
bench.set_min_time(value);
|
bench.set_min_time(value);
|
||||||
}
|
}
|
||||||
else if (prop_arg == "--max-noise")
|
else if (prop_arg == "--max-noise")
|
||||||
{
|
{ // Specified as percentage, stored as ratio:
|
||||||
bench.set_max_noise(value);
|
bench.set_max_noise(value / 100.);
|
||||||
}
|
}
|
||||||
else if (prop_arg == "--skip-time")
|
else if (prop_arg == "--skip-time")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -151,8 +151,8 @@ struct state
|
|||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// Specify the maximum amount of noise if a measurement supports noise.
|
/// Specify the maximum amount of noise if a measurement supports noise.
|
||||||
/// Noise is the relative standard deviation expressed as a percentage:
|
/// Noise is the relative standard deviation:
|
||||||
/// `noise = 100 * (stdev / mean_time)`. @{
|
/// `noise = stdev / mean_time`. @{
|
||||||
[[nodiscard]] nvbench::float64_t get_max_noise() const { return m_max_noise; }
|
[[nodiscard]] nvbench::float64_t get_max_noise() const { return m_max_noise; }
|
||||||
void set_max_noise(nvbench::float64_t max_noise) { m_max_noise = max_noise; }
|
void set_max_noise(nvbench::float64_t max_noise) { m_max_noise = max_noise; }
|
||||||
/// @}
|
/// @}
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ namespace nvbench
|
|||||||
* - "bytes": "value" is an int64_t number of bytes.
|
* - "bytes": "value" is an int64_t number of bytes.
|
||||||
* - "byte_rate": "value" is a float64_t byte rate in bytes / second.
|
* - "byte_rate": "value" is a float64_t byte rate in bytes / second.
|
||||||
* - "sample_size": "value" is an int64_t number of samples in a measurement.
|
* - "sample_size": "value" is an int64_t number of samples in a measurement.
|
||||||
* - "percentage": "value" is a float64_t percentage.
|
* - "percentage": "value" is a float64_t percentage (stored as a ratio, 1. =
|
||||||
|
* 100%).
|
||||||
*
|
*
|
||||||
* The key/value pair functionality is implemented by the
|
* The key/value pair functionality is implemented by the
|
||||||
* `nvbench::named_values` base class.
|
* `nvbench::named_values` base class.
|
||||||
|
|||||||
@@ -1200,11 +1200,11 @@ void test_max_noise()
|
|||||||
{
|
{
|
||||||
nvbench::option_parser parser;
|
nvbench::option_parser parser;
|
||||||
parser.parse(
|
parser.parse(
|
||||||
{"--benchmark", "DummyBench", "--max-noise", "12345e2"});
|
{"--benchmark", "DummyBench", "--max-noise", "50.3"});
|
||||||
const auto& states = parser_to_states(parser);
|
const auto& states = parser_to_states(parser);
|
||||||
|
|
||||||
ASSERT(states.size() == 1);
|
ASSERT(states.size() == 1);
|
||||||
ASSERT(std::abs(states[0].get_max_noise() - 12345e2) < 1.);
|
ASSERT(std::abs(states[0].get_max_noise() - 0.503) < 1.-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_skip_time()
|
void test_skip_time()
|
||||||
|
|||||||
Reference in New Issue
Block a user