NVIDIA / nvbench

CUDA Kernel Benchmarking Library
Apache License 2.0
474 stars 63 forks source link

[QST] How can I choose `enum_type_list` axis values at runtime? #137

Closed GregoryKimball closed 1 year ago

GregoryKimball commented 1 year ago

We have several cuDF benchmarks for which I would like to run one value of an nvbench enum_type_list by default, and also be able to access the other values at runtime.

In this case for parquet_reader_input, how can I write BM_parquet_read_data so that it only runs cudf::io::io_type::DEVICE_BUFFER by default and also --axis io=HOST_BUFFER would work at runtime?

I see the nvbench example in enums.cu - is the recommendation to convert the NVBENCH_TYPE_AXES into a string_axis?

gevtushenko commented 1 year ago

Hello @GregoryKimball!

I'm using a string axis for enums and then converting the string to enum value. This is needed because the benchmark accepts many enum values. For your case, there might be only two values, so using an integer axis might be preferable:

void bench(nvbench::state &state)
{
  cuio_source_sink_pair(state.get_int64("IsDeviceBuffer") ? io_type::DEVICE_BUFFER
                                                          : io_type::HOST_BUFFER);
  // ...
}
NVBENCH_BENCH(bench)
  .add_int64_axis("IsDeviceBuffer", {1});
GregoryKimball commented 1 year ago

Thank you @senior-zero, we will consider switching to string axes for our cuIO benchmarks. I'll close this issue, but if anyone else has thoughts on this topic - I would love to learn from your response as well!