Skip to content

Commit

Permalink
Introduce roofit and cuda options instead of inheriting from ROOT
Browse files Browse the repository at this point in the history
  • Loading branch information
guitargeek committed Oct 22, 2023
1 parent 89ff3ec commit 2e18f2f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion root/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 9 additions & 6 deletions root/roofit/roofit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 3 additions & 3 deletions root/roofit/roofit/RooFitUnBinnedBenchmarks.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -246,23 +246,23 @@ 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

BENCHMARK(BDecayGaussResolution)->Name("BDecayGaussResolution_FitLegacy")->Args({nEvents, Legacy, 1})->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

BENCHMARK(BDecayDoubleGauss)->Name("BDecayDoubleGauss_FitLegacy")->Args({nEvents, Legacy, 1})->ARGS;
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

Expand Down
2 changes: 1 addition & 1 deletion root/roofit/roofit/benchRooFitBackends.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 2e18f2f

Please sign in to comment.