1818
1919#include < nvbench/benchmark.cuh>
2020#include < nvbench/callable.cuh>
21+ #include < nvbench/device_manager.cuh>
2122#include < nvbench/named_values.cuh>
2223#include < nvbench/state.cuh>
2324#include < nvbench/type_list.cuh>
2728#include < fmt/format.h>
2829
2930#include < algorithm>
31+ #include < cstdint>
3032#include < utility>
3133#include < variant>
3234#include < vector>
@@ -279,6 +281,7 @@ void test_clone()
279281void test_get_config_count ()
280282{
281283 lots_of_types_bench bench;
284+ bench.set_devices (nvbench::device_manager::get ().get_device_ids ());
282285 bench.set_type_axes_names ({" Integer" , " Float" , " Other" });
283286 bench.get_axes ().get_type_axis (0 ).set_active_inputs ({" I16" , " I32" }); // 2, 2
284287 bench.get_axes ().get_type_axis (1 ).set_active_inputs ({" F32" , " F64" }); // 2, 4
@@ -288,9 +291,17 @@ void test_get_config_count()
288291 bench.add_string_axis (" baz" , {" str" , " ing" }); // 2, 72
289292 bench.add_string_axis (" baz" , {" single" }); // 1, 72
290293
291- auto const num_devices = bench.get_devices ().size ();
294+ auto const num_devices = std::max (std::size_t (1 ), bench.get_devices ().size ());
295+
296+ printf (" %d devices: %d configs\n " ,
297+ static_cast <int >(num_devices),
298+ static_cast <int >(bench.get_config_count ()));
292299
293300 ASSERT_MSG (bench.get_config_count () == 72 * num_devices, " Got {}" , bench.get_config_count ());
301+
302+ // Check that zero devices (e.g. CPU-only) is the same as a single device:
303+ bench.set_devices (std::vector<int >{});
304+ ASSERT_MSG (bench.get_config_count () == 72 , " Got {}" , bench.get_config_count ());
294305}
295306
296307int main ()
0 commit comments