Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CIValidations/Benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
foreach(TEST
MaCh3Benchmark
)

add_executable(${TEST} ${TEST}.cpp)
target_link_libraries(${TEST} PRIVATE Catch2::Catch2WithMain MaCh3::All MaCh3Tutorial::samplePDFTutorial)
catch_discover_tests(${TEST})
endforeach()
38 changes: 38 additions & 0 deletions CIValidations/Benchmark/MaCh3Benchmark.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// MaCh3 spline includes
#include "mcmc/MaCh3Factory.h"
#include "samplePDF/samplePDFTutorial.h"

#include "catch2/catch_test_macros.hpp"
#include "catch2/benchmark/catch_benchmark.hpp"

TEST_CASE("Benchmark MaCh3") {
// Initialise manger responsible for config handling
auto FitManager = std::make_unique<manager>("Inputs/FitterConfig.yaml");

// Initialise covariance class reasonable for Systematics
covarianceXsec* xsec = MaCh3CovarianceFactory(FitManager.get(), "Xsec");
covarianceOsc* osc = MaCh3CovarianceFactory<covarianceOsc>(FitManager.get(), "Osc");

// Initialise samplePDF
auto SampleConfig = FitManager->raw()["General"]["TutorialSamples"].as<std::vector<std::string>>();
auto mySamples = MaCh3SamplePDFFactory<samplePDFTutorial>(SampleConfig, xsec, osc);

// Create MCMC Class
std::unique_ptr<FitterBase> MaCh3Fitter = MaCh3FitterFactory(FitManager.get());
// Add covariance to MCM
MaCh3Fitter->addSystObj(xsec);
MaCh3Fitter->addSystObj(osc);
for (size_t i = 0; i < SampleConfig.size(); ++i) {
MaCh3Fitter->addSamplePDF(mySamples[i]);
}
// Benchmark
BENCHMARK("MaCh3Fitter::DragRace") {
MaCh3Fitter->DragRace(1);
};

delete xsec;
delete osc;
for (size_t i = 0; i < SampleConfig.size(); ++i) {
delete mySamples[i];
}
}
4 changes: 4 additions & 0 deletions CIValidations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ install(DIRECTORY
if(MaCh3Tutorial_UNITTESTS_ENABLED)
add_subdirectory(UnitTests)
endif()

if(MaCh3Tutorial_Benchmark_ENABLED)
add_subdirectory(Benchmark)
endif()
23 changes: 20 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ file(
)
include(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake)

include(CIValidations)

################################## MaCh3 ######################################
# KS: Here we try to find tag matching tutorial version. If we can't find one then use develop
# This will allow to grab tutorial for tagged MaCh3 version without a need of manually changing version
Expand Down Expand Up @@ -67,13 +69,30 @@ if(NOT DEFINED PYTHON_ENABLED)
SET(PYTHON_ENABLED false)
endif()
if(NOT MaCh3_FOUND)

set(MaCh3_OPTIONS
"MaCh3_PYTHON_ENABLED ${PYTHON_ENABLED}"
)

# KS: For benchmark we turn off logger to not interfere with output messages.
# Also to have code compile let's turn off Werror
if (MaCh3Tutorial_Benchmark_ENABLED)
list(APPEND MaCh3_OPTIONS "MaCh3_WERROR_ENABLED OFF")
set(LOG_LEVEL "OFF")
endif()

# Add LOG_LEVEL if defined
if (DEFINED LOG_LEVEL)
list(APPEND MaCh3_OPTIONS "LOG_LEVEL ${LOG_LEVEL}")
endif()

CPMAddPackage(
NAME MaCh3
GIT_TAG ${MaCh3_Branch}
GIT_SHALLOW YES
GITHUB_REPOSITORY mach3-software/MaCh3
OPTIONS
"MaCh3_PYTHON_ENABLED ${PYTHON_ENABLED}"
${MaCh3_OPTIONS}
"Prob3ppLinear_ENABLED ON"
"NuFastLinear_ENABLED ON"
)
Expand All @@ -92,8 +111,6 @@ if(MaCh3_VERSION GREATER MaCh3Tutorial_VERSION)
cmessage(WARNING "MaCh3Tutorial_VERSION (${MaCh3Tutorial_VERSION}) is smaller than MaCh3_VERSION (${MaCh3_VERSION}), this most likely will not work")
endif()

include(CIValidations)

############################ C++ Compiler ####################################
get_property(MACH3_CXX_STANDARD GLOBAL PROPERTY MACH3_CXX_STANDARD)
if(NOT DEFINED MACH3_CXX_STANDARD)
Expand Down
5 changes: 3 additions & 2 deletions cmake/Modules/CIValidations.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
option(MaCh3Tutorial_UNITTESTS_ENABLED "Whether to build MaCh3 Unit Tests" OFF)
option(MaCh3Tutorial_Coverage_ENABLED "Whether to build MaCh3 Coverage " OFF)
option(MaCh3Tutorial_Coverage_ENABLED "Whether to build MaCh3 Coverage" OFF)
option(MaCh3Tutorial_Benchmark_ENABLED "Enable benchmarking" ON) # WARNING FIXME

CPMAddPackage(
NAME NuMCMCTools
Expand All @@ -14,7 +15,7 @@ install(DIRECTORY
DESTINATION ${CMAKE_BINARY_DIR}/NuMCMCTools)

############################ Catch2/CTest ####################################
if(MaCh3Tutorial_UNITTESTS_ENABLED)
if(MaCh3Tutorial_UNITTESTS_ENABLED OR MaCh3Tutorial_Benchmark_ENABLED)
find_package(Catch2 QUIET)
if(NOT Catch2_FOUND)
CPMAddPackage("gh:catchorg/Catch2@3.5.2")
Expand Down
Loading