From 2e18f2fbfb5034553d75d8af5c75b3ae57295c81 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Tue, 5 Sep 2023 19:41:58 +0200 Subject: [PATCH] Introduce `roofit` and `cuda` options instead of inheriting from ROOT --- .github/workflows/ci.yaml | 3 ++- CMakeLists.txt | 3 +++ root/CMakeLists.txt | 2 +- root/roofit/roofit/CMakeLists.txt | 15 +++++++++------ root/roofit/roofit/RooFitUnBinnedBenchmarks.cxx | 6 +++--- root/roofit/roofit/benchRooFitBackends.cxx | 2 +- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 29b61f50..e4ba5272 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -46,7 +46,8 @@ jobs: run: | conda activate root-nightly mkdir -p build && cd build - cmake .. + # The conda nightlies are not built with a cutting-edge ROOT version that the RooFit benchmarks require + cmake -Dcuda=OFF -Droofit=OFF .. cmake --build . - name: Run benchmarks diff --git a/CMakeLists.txt b/CMakeLists.txt index ae143cb0..9a01ba6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,9 @@ endif() project(rootbench) +option(cuda "Build benchmarks that run on CUDA GPUs" OFF) +option(roofit "Build RooFit benchmarks" ON) + include(CMakeToolsHelpers OPTIONAL) include(ExternalProject) diff --git a/root/CMakeLists.txt b/root/CMakeLists.txt index f5213558..a25eb8f3 100644 --- a/root/CMakeLists.txt +++ b/root/CMakeLists.txt @@ -3,7 +3,7 @@ add_subdirectory(io) add_subdirectory(hist) add_subdirectory(math) add_subdirectory(pyroot) -if (ROOT_roofit_FOUND AND ROOT_xml_FOUND) +if (roofit) add_subdirectory(roofit) endif() add_subdirectory(tree) diff --git a/root/roofit/roofit/CMakeLists.txt b/root/roofit/roofit/CMakeLists.txt index 75662037..d9d94ff0 100644 --- a/root/roofit/roofit/CMakeLists.txt +++ b/root/roofit/roofit/CMakeLists.txt @@ -13,11 +13,14 @@ RB_ADD_GBENCHMARK(benchRooFitBackends LABEL long LIBRARIES Core MathCore RooFitCore RooFit) +if(cuda) + target_compile_definitions(benchRooFitBinned PRIVATE DO_BENCH_ROOFIT_CUDA) + target_compile_definitions(benchRooFitBackends PRIVATE DO_BENCH_ROOFIT_CUDA) +endif() + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/benchRooFitBackends_make_plot.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -if(ROOT_VERSION VERSION_GREATER_EQUAL 6.29) - RB_ADD_GBENCHMARK(benchCodeSquashAD - benchCodeSquashAD.cxx - LABEL long - LIBRARIES Core MathCore RooFit RooStats RooFitCore) -endif(ROOT_VERSION VERSION_GREATER_EQUAL 6.29) +RB_ADD_GBENCHMARK(benchCodeSquashAD + benchCodeSquashAD.cxx + LABEL long + LIBRARIES Core MathCore RooFit RooStats RooFitCore) diff --git a/root/roofit/roofit/RooFitUnBinnedBenchmarks.cxx b/root/roofit/roofit/RooFitUnBinnedBenchmarks.cxx index c77fdf8b..58f8ecf5 100644 --- a/root/roofit/roofit/RooFitUnBinnedBenchmarks.cxx +++ b/root/roofit/roofit/RooFitUnBinnedBenchmarks.cxx @@ -246,7 +246,7 @@ BENCHMARK(BDecayWithMixing)->Name("BDecayWithMixing_FitLegacy")->Args({nEvents, BENCHMARK(BDecayWithMixing)->Name("BDecayWithMixing_FitLegacyNumCPU2")->Args({nEvents, Legacy, 2})->ARGS; BENCHMARK(BDecayWithMixing)->Name("BDecayWithMixing_FitLegacyNumCPU4")->Args({nEvents, Legacy, 4})->ARGS; BENCHMARK(BDecayWithMixing)->Name("BDecayWithMixing_FitCPU")->Args({nEvents, Cpu, 1})->ARGS; -#ifdef R__HAS_CUDA +#ifdef DO_BENCH_ROOFIT_CUDA BENCHMARK(BDecayWithMixing)->Name("BDecayWithMixing_FitCUDA")->Args({nEvents, Cuda, 1})->ARGS; #endif @@ -254,7 +254,7 @@ BENCHMARK(BDecayGaussResolution)->Name("BDecayGaussResolution_FitLegacy")->Args( BENCHMARK(BDecayGaussResolution)->Name("BDecayGaussResolution_FitLegacyNumCPU2")->Args({nEvents, Legacy, 2})->ARGS; BENCHMARK(BDecayGaussResolution)->Name("BDecayGaussResolution_FitLegacyNumCPU4")->Args({nEvents, Legacy, 4})->ARGS; BENCHMARK(BDecayGaussResolution)->Name("BDecayGaussResolution_FitCPU")->Args({nEvents, Cpu, 1})->ARGS; -#ifdef R__HAS_CUDA +#ifdef DO_BENCH_ROOFIT_CUDA BENCHMARK(BDecayGaussResolution)->Name("BDecayGaussResolution_FitCUDA")->Args({nEvents, Cuda, 1})->ARGS; #endif @@ -262,7 +262,7 @@ BENCHMARK(BDecayDoubleGauss)->Name("BDecayDoubleGauss_FitLegacy")->Args({nEvents BENCHMARK(BDecayDoubleGauss)->Name("BDecayDoubleGauss_FitLegacyNumCPU2")->Args({nEvents, Legacy, 2})->ARGS; BENCHMARK(BDecayDoubleGauss)->Name("BDecayDoubleGauss_FitLegacyNumCPU4")->Args({nEvents, Legacy, 4})->ARGS; BENCHMARK(BDecayDoubleGauss)->Name("BDecayDoubleGauss_FitCPU")->Args({nEvents, Cpu, 1})->ARGS; -#ifdef R__HAS_CUDA +#ifdef DO_BENCH_ROOFIT_CUDA BENCHMARK(BDecayDoubleGauss)->Name("BDecayDoubleGauss_FitCUDA")->Args({nEvents, Cuda, 1})->ARGS; #endif diff --git a/root/roofit/roofit/benchRooFitBackends.cxx b/root/roofit/roofit/benchRooFitBackends.cxx index 0699f0dd..4513baee 100644 --- a/root/roofit/roofit/benchRooFitBackends.cxx +++ b/root/roofit/roofit/benchRooFitBackends.cxx @@ -320,7 +320,7 @@ static void benchModel(benchmark::State &state) auto const unit = benchmark::kMillisecond; -#ifdef R__HAS_CUDA +#ifdef DO_BENCH_ROOFIT_CUDA // Only one iteration for CUDA benchmarks. Otherwise, the benchmark suit will // repeat them many times are they appear to be very fast, consuming almost no // CPU time.