mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-04-29 19:21:14 +00:00
Replace main_arg_run_benchmarks with run_interriptible
This loop uses benchmark.run_or_skip to resolve #284 even for scripts that contain more than one benchmark, or when a script with a single benchmark is executed when more than one device is available.
This commit is contained in:
@@ -119,6 +119,29 @@ struct nvbench_run_error : std::runtime_error
|
|||||||
};
|
};
|
||||||
py::handle benchmark_exc{};
|
py::handle benchmark_exc{};
|
||||||
|
|
||||||
|
void run_interruptible(nvbench::option_parser &parser)
|
||||||
|
{
|
||||||
|
auto &printer = parser.get_printer();
|
||||||
|
auto &benchmarks = parser.get_benchmarks();
|
||||||
|
|
||||||
|
std::size_t total_states = 0;
|
||||||
|
for (auto &bench_ptr : benchmarks)
|
||||||
|
{
|
||||||
|
total_states += bench_ptr->get_config_count();
|
||||||
|
}
|
||||||
|
|
||||||
|
printer.set_completed_state_count(0);
|
||||||
|
printer.set_total_state_count(total_states);
|
||||||
|
|
||||||
|
bool skip_remaining_flag = false;
|
||||||
|
for (auto &bench_ptr : benchmarks)
|
||||||
|
{
|
||||||
|
bench_ptr->set_printer(printer);
|
||||||
|
bench_ptr->run_or_skip(skip_remaining_flag);
|
||||||
|
bench_ptr->clear_printer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class GlobalBenchmarkRegistry
|
class GlobalBenchmarkRegistry
|
||||||
{
|
{
|
||||||
bool m_finalized;
|
bool m_finalized;
|
||||||
@@ -185,7 +208,7 @@ public:
|
|||||||
parser.parse(argv);
|
parser.parse(argv);
|
||||||
|
|
||||||
NVBENCH_MAIN_PRINT_PREAMBLE(parser);
|
NVBENCH_MAIN_PRINT_PREAMBLE(parser);
|
||||||
NVBENCH_MAIN_RUN_BENCHMARKS(parser);
|
run_interruptible(parser);
|
||||||
NVBENCH_MAIN_PRINT_EPILOGUE(parser);
|
NVBENCH_MAIN_PRINT_EPILOGUE(parser);
|
||||||
|
|
||||||
NVBENCH_MAIN_PRINT_RESULTS(parser);
|
NVBENCH_MAIN_PRINT_RESULTS(parser);
|
||||||
|
|||||||
Reference in New Issue
Block a user