diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index b10dccbe2c..998dcc8ad4 100644 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -138,6 +138,25 @@ function(ConfigureNVBench CMAKE_BENCH_NAME) ) endfunction() +function(ConfigureNDSHNVBench CMAKE_BENCH_NAME) + add_executable(${CMAKE_BENCH_NAME} ${ARGN} ndsh/nvbench_main.cpp) + set_target_properties( + ${CMAKE_BENCH_NAME} + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$" + INSTALL_RPATH "\$ORIGIN/../../../lib" + ) + target_link_libraries( + ${CMAKE_BENCH_NAME} PRIVATE cudf_benchmark_common ndsh_data_generator cudf_datagen + nvbench::nvbench $ + ) + install( + TARGETS ${CMAKE_BENCH_NAME} + COMPONENT testing + DESTINATION bin/benchmarks/libcudf + EXCLUDE_FROM_ALL + ) +endfunction() + # ################################################################################################## # * column benchmarks ----------------------------------------------------------------------------- ConfigureBench(COLUMN_CONCAT_BENCH column/concatenate.cpp) @@ -177,11 +196,11 @@ ConfigureBench(TRANSPOSE_BENCH transpose/transpose.cpp) # ################################################################################################## # * nds-h benchmark -------------------------------------------------------------------------------- -ConfigureNVBench(NDSH_Q01_NVBENCH ndsh/q01.cpp ndsh/utilities.cpp) -ConfigureNVBench(NDSH_Q05_NVBENCH ndsh/q05.cpp ndsh/utilities.cpp) -ConfigureNVBench(NDSH_Q06_NVBENCH ndsh/q06.cpp ndsh/utilities.cpp) -ConfigureNVBench(NDSH_Q09_NVBENCH ndsh/q09.cpp ndsh/utilities.cpp) -ConfigureNVBench(NDSH_Q10_NVBENCH ndsh/q10.cpp ndsh/utilities.cpp) +ConfigureNDSHNVBench(NDSH_Q01_NVBENCH ndsh/q01.cpp ndsh/utilities.cpp) +ConfigureNDSHNVBench(NDSH_Q05_NVBENCH ndsh/q05.cpp ndsh/utilities.cpp) +ConfigureNDSHNVBench(NDSH_Q06_NVBENCH ndsh/q06.cpp ndsh/utilities.cpp) +ConfigureNDSHNVBench(NDSH_Q09_NVBENCH ndsh/q09.cpp ndsh/utilities.cpp) +ConfigureNDSHNVBench(NDSH_Q10_NVBENCH ndsh/q10.cpp ndsh/utilities.cpp) # ################################################################################################## # * stream_compaction benchmark ------------------------------------------------------------------- diff --git a/cpp/benchmarks/fixture/nvbench_fixture.hpp b/cpp/benchmarks/fixture/nvbench_fixture.hpp index 63f09285a2..2c09ef1b17 100644 --- a/cpp/benchmarks/fixture/nvbench_fixture.hpp +++ b/cpp/benchmarks/fixture/nvbench_fixture.hpp @@ -95,7 +95,12 @@ struct nvbench_base_fixture { CUDF_FAIL("Unknown cuio_host_mem parameter: " + mode + "\nExpecting: pinned or pinned_pool"); } - nvbench_base_fixture(int argc, char const* const* argv) + void initialize_mr() { + mr = create_memory_resource(rmm_mode); + cudf::set_current_device_resource(mr.get()); + } + + nvbench_base_fixture(int argc, char const* const* argv, bool init_mr= true) { for (int i = 1; i < argc - 1; ++i) { std::string arg = argv[i]; @@ -107,10 +112,10 @@ struct nvbench_base_fixture { cuio_host_mode = argv[i]; } } - - mr = create_memory_resource(rmm_mode); - cudf::set_current_device_resource(mr.get()); - std::cout << "RMM memory resource = " << rmm_mode << "\n"; + if (init_mr) { + initialize_mr(); + std::cout << "RMM memory resource = " << rmm_mode << "\n"; + } cudf::set_pinned_memory_resource(create_cuio_host_memory_resource(cuio_host_mode)); std::cout << "CUIO host memory resource = " << cuio_host_mode << "\n"; @@ -128,4 +133,25 @@ struct nvbench_base_fixture { std::string cuio_host_mode{"pinned_pool"}; }; +// strip off the rmm_mode and cuio_host_mem parameters before passing the +// remaining arguments to nvbench::option_parser +inline void benchmark_arg_handler(std::vector& args) +{ + std::vector _cudf_tmp_args; + + for (std::size_t i = 0; i < args.size(); ++i) { + std::string arg = args[i]; + if (arg == cudf::detail::rmm_mode_param) { + i++; // skip the next argument + } else if (arg == cudf::detail::cuio_host_mem_param) { + i++; // skip the next argument + } else { + _cudf_tmp_args.push_back(arg); + } + } + + args = _cudf_tmp_args; +} + + } // namespace cudf diff --git a/cpp/benchmarks/fixture/nvbench_main.cpp b/cpp/benchmarks/fixture/nvbench_main.cpp index 5dfd67b1c5..0332d05300 100644 --- a/cpp/benchmarks/fixture/nvbench_main.cpp +++ b/cpp/benchmarks/fixture/nvbench_main.cpp @@ -21,30 +21,6 @@ #include #include -namespace cudf { - -// strip off the rmm_mode and cuio_host_mem parameters before passing the -// remaining arguments to nvbench::option_parser -void benchmark_arg_handler(std::vector& args) -{ - std::vector _cudf_tmp_args; - - for (std::size_t i = 0; i < args.size(); ++i) { - std::string arg = args[i]; - if (arg == cudf::detail::rmm_mode_param) { - i++; // skip the next argument - } else if (arg == cudf::detail::cuio_host_mem_param) { - i++; // skip the next argument - } else { - _cudf_tmp_args.push_back(arg); - } - } - - args = _cudf_tmp_args; -} - -} // namespace cudf - // Install arg handler #undef NVBENCH_MAIN_CUSTOM_ARGS_HANDLER #define NVBENCH_MAIN_CUSTOM_ARGS_HANDLER(args) cudf::benchmark_arg_handler(args) diff --git a/cpp/benchmarks/ndsh/q01.cpp b/cpp/benchmarks/ndsh/q01.cpp index 485e8e5497..f2d137a841 100644 --- a/cpp/benchmarks/ndsh/q01.cpp +++ b/cpp/benchmarks/ndsh/q01.cpp @@ -15,6 +15,7 @@ */ #include "utilities.hpp" +#include #include #include @@ -172,6 +173,7 @@ void ndsh_q1(nvbench::state& state) double const scale_factor = state.get_float64("scale_factor"); std::unordered_map sources; generate_parquet_data_sources(scale_factor, {"lineitem"}, sources); + cudf::ndsh_fixture::getInstance()->initialize_mr(); auto stream = cudf::get_default_stream(); state.set_cuda_stream(nvbench::make_cuda_stream_view(stream.value())); diff --git a/cpp/benchmarks/ndsh/q05.cpp b/cpp/benchmarks/ndsh/q05.cpp index 1c2d657913..85c60b2d59 100644 --- a/cpp/benchmarks/ndsh/q05.cpp +++ b/cpp/benchmarks/ndsh/q05.cpp @@ -15,6 +15,7 @@ */ #include "utilities.hpp" +#include #include #include @@ -168,6 +169,7 @@ void ndsh_q5(nvbench::state& state) std::unordered_map sources; generate_parquet_data_sources( scale_factor, {"customer", "orders", "lineitem", "supplier", "nation", "region"}, sources); + cudf::ndsh_fixture::getInstance()->initialize_mr(); auto stream = cudf::get_default_stream(); state.set_cuda_stream(nvbench::make_cuda_stream_view(stream.value()));