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
189 changes: 105 additions & 84 deletions cmake/modules/SearchInstalledSoftware.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -397,62 +397,6 @@ if(asimage)
endif()
endif()

#---Check for GSL library---------------------------------------------------------------
if(mathmore OR builtin_gsl OR (tmva-cpu AND use_gsl_cblas))
if(builtin_gsl)
ROOT_CHECK_CONNECTION_AND_DISABLE_OPTION("builtin_gsl")
endif()
message(STATUS "Looking for GSL")
if(NOT builtin_gsl)
find_package(GSL 1.10)
if(NOT GSL_FOUND)
if(fail-on-missing)
message(SEND_ERROR "GSL package not found and 'mathmore' component if required ('fail-on-missing' enabled). "
"Alternatively, you can enable the option 'builtin_gsl' to build the GSL libraries internally.")
else()
message(STATUS "GSL not found. Set variable GSL_ROOT_DIR to point to your GSL installation")
message(STATUS " Alternatively, you can also enable the option 'builtin_gsl' to build the GSL libraries internally'")
message(STATUS " For the time being switching OFF 'mathmore' option")
set(mathmore OFF CACHE BOOL "Disable because builtin_gsl disabled and external GSL not found (${mathmore_description})" FORCE)
endif()
endif()
else()
set(gsl_version 2.8)
message(STATUS "Downloading and building GSL version ${gsl_version}")
foreach(l gsl gslcblas)
list(APPEND GSL_LIBRARIES ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${l}${CMAKE_STATIC_LIBRARY_SUFFIX})
endforeach()
set(GSL_CBLAS_LIBRARY ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gslcblas${CMAKE_STATIC_LIBRARY_SUFFIX})
if(CMAKE_OSX_SYSROOT)
set(_gsl_cppflags "-isysroot ${CMAKE_OSX_SYSROOT}")
set(_gsl_ldflags "-isysroot ${CMAKE_OSX_SYSROOT}")
endif()
ExternalProject_Add(
GSL
# http://mirror.switch.ch/ftp/mirror/gnu/gsl/gsl-${gsl_version}.tar.gz
URL ${lcgpackages}/gsl-${gsl_version}.tar.gz
URL_HASH SHA256=6a99eeed15632c6354895b1dd542ed5a855c0f15d9ad1326c6fe2b2c9e423190
SOURCE_DIR GSL-src # prevent "<gsl/...>" vs GSL/ macOS warning
INSTALL_DIR ${CMAKE_BINARY_DIR}
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix <INSTALL_DIR>
--libdir=<INSTALL_DIR>/lib
--enable-shared=no --with-pic
CC=${CMAKE_C_COMPILER}
CFLAGS=${CMAKE_C_FLAGS}
CPPFLAGS=${_gsl_cppflags}
LDFLAGS=${_gsl_ldflags}
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1
BUILD_BYPRODUCTS ${GSL_LIBRARIES}
TIMEOUT 600
)
set(GSL_TARGET GSL)
# FIXME: one need to find better way to extract path with GSL include files
set(GSL_INCLUDE_DIR ${CMAKE_BINARY_DIR}/GSL-prefix/src/GSL-build)
set(GSL_FOUND ON)
set(mathmore ON CACHE BOOL "Enabled because builtin_gsl requested (${mathmore_description})" FORCE)
endif()
endif()

#---Check for Python installation-------------------------------------------------------

message(STATUS "Looking for Python")
Expand Down Expand Up @@ -1264,42 +1208,120 @@ if(tmva-sofie)
endif()
endif()

#---TMVA and its dependencies------------------------------------------------------------
if(tmva)
if(tmva-cpu AND imt)
message(STATUS "Looking for BLAS for optional parts of TMVA")
# ROOT internal BLAS target
add_library(Blas INTERFACE)
add_library(ROOT::BLAS ALIAS Blas)
if(use_gsl_cblas)
message(STATUS "Using GSL CBLAS for optional parts of TMVA")
if(builtin_gsl)
add_dependencies(Blas GSL)
target_include_directories(Blas INTERFACE ${GSL_INCLUDE_DIR})
target_link_libraries(Blas INTERFACE ${GSL_CBLAS_LIBRARY})
#---Figure out if TMVA CPU should be built and which BLAS we will use ------------------
if(tmva-cpu)
if (NOT tmva)
set(tmva-cpu OFF CACHE BOOL "Disabled because 'tmva' is disabled (${tmva-cpu_description})" FORCE)
elseif(NOT imt)
set(tmva-cpu OFF CACHE BOOL "Disabled because 'imt' is disabled (${tmva-cpu_description})" FORCE)
endif()
endif()
if(tmva-cpu)
if (NOT use_gsl_cblas)
find_package(BLAS)
if(NOT BLAS_FOUND)
# If no optimized BLAS library was found, we fall back to attempting to
# use the GSL CBLAS. If ROOT is built with fail-on-missing=ON, this
# usually means that the user does not want us to change build flags
# automatically, so we send an error.
if(fail-on-missing)
message(SEND_ERROR "Option tmva-cpu requires a BLAS library, but none could be found on the system. Either install a BLAS library like OpenBLAS (preferred), or set use_gsl_cblas=ON (possibly also builtin_gsl=ON if GSL not installed on the system).")
else()
if(GSL_FOUND)
target_link_libraries(Blas INTERFACE GSL::gslcblas)
endif()
endif()
target_compile_definitions(Blas INTERFACE -DR__USE_CBLAS)
else()
find_package(BLAS)
if(BLAS_FOUND)
target_link_libraries(Blas INTERFACE BLAS::BLAS)
set(use_gsl_cblas ON CACHE BOOL "Auto-enabling GSL CBLAS for TMVA [GPL]" FORCE)
endif()
endif()
if(NOT BLAS_FOUND AND NOT GSL_FOUND)
endif()
endif()

#---Check for GSL library---------------------------------------------------------------
if(mathmore OR builtin_gsl OR (tmva-cpu AND use_gsl_cblas))
if(builtin_gsl)
ROOT_CHECK_CONNECTION_AND_DISABLE_OPTION("builtin_gsl")
endif()
message(STATUS "Looking for GSL")
if(NOT builtin_gsl)
find_package(GSL 1.10)
if(NOT GSL_FOUND)
if(fail-on-missing)
message(SEND_ERROR "tmva-cpu can't be built because BLAS was not found!")
message(SEND_ERROR "GSL package not found and 'mathmore' component is required ('fail-on-missing' enabled). "
"Alternatively, you can enable the option 'builtin_gsl' to build the GSL libraries internally.")
else()
message(STATUS "tmva-cpu disabled because BLAS was not found")
set(tmva-cpu OFF CACHE BOOL "Disabled because BLAS was not found (${tmva-cpu_description})" FORCE)
message(STATUS "GSL not found. Set variable GSL_ROOT_DIR to point to your GSL installation")
message(STATUS " Alternatively, you can also enable the option 'builtin_gsl' to build the GSL libraries internally'")
if (mathmore)
message(STATUS " For the time being switching OFF 'mathmore' option")
set(mathmore OFF CACHE BOOL "Disable because builtin_gsl disabled and external GSL not found (${mathmore_description})" FORCE)
endif()
if (tmva-cpu AND use_gsl_cblas)
message(STATUS " For the time being switching OFF 'tmva-cpu' option")
set(tmva-cpu OFF CACHE BOOL "Disable because use_gsl_cblas enabled, builtin_gsl disabled and external GSL not found (${tmva-cpu_description})" FORCE)
endif()
endif()
endif()
else()
set(tmva-cpu OFF CACHE BOOL "Disabled because 'imt' is disabled (${tmva-cpu_description})" FORCE)
set(gsl_version 2.8)
message(STATUS "Downloading and building GSL version ${gsl_version}")
foreach(l gsl gslcblas)
list(APPEND GSL_LIBRARIES ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${l}${CMAKE_STATIC_LIBRARY_SUFFIX})
endforeach()
set(GSL_CBLAS_LIBRARY ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gslcblas${CMAKE_STATIC_LIBRARY_SUFFIX})
if(CMAKE_OSX_SYSROOT)
set(_gsl_cppflags "-isysroot ${CMAKE_OSX_SYSROOT}")
set(_gsl_ldflags "-isysroot ${CMAKE_OSX_SYSROOT}")
endif()
ExternalProject_Add(
GSL
# http://mirror.switch.ch/ftp/mirror/gnu/gsl/gsl-${gsl_version}.tar.gz
URL ${lcgpackages}/gsl-${gsl_version}.tar.gz
URL_HASH SHA256=6a99eeed15632c6354895b1dd542ed5a855c0f15d9ad1326c6fe2b2c9e423190
SOURCE_DIR GSL-src # prevent "<gsl/...>" vs GSL/ macOS warning
INSTALL_DIR ${CMAKE_BINARY_DIR}
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix <INSTALL_DIR>
--libdir=<INSTALL_DIR>/lib
--enable-shared=no --with-pic
CC=${CMAKE_C_COMPILER}
CFLAGS=${CMAKE_C_FLAGS}
CPPFLAGS=${_gsl_cppflags}
LDFLAGS=${_gsl_ldflags}
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1
BUILD_BYPRODUCTS ${GSL_LIBRARIES}
TIMEOUT 600
)
set(GSL_TARGET GSL)
# FIXME: one need to find better way to extract path with GSL include files
set(GSL_INCLUDE_DIR ${CMAKE_BINARY_DIR}/GSL-prefix/src/GSL-build)
set(GSL_FOUND ON)
set(mathmore ON CACHE BOOL "Enabled because builtin_gsl requested (${mathmore_description})" FORCE)
endif()
endif()

#---TMVA and its dependencies------------------------------------------------------------
if(tmva-cpu)
# ROOT internal BLAS target for TMVA
add_library(Blas INTERFACE)
add_library(ROOT::BLAS ALIAS Blas)
if (NOT use_gsl_cblas AND BLAS_FOUND)
target_link_libraries(Blas INTERFACE BLAS::BLAS)
elseif(use_gsl_cblas AND builtin_gsl)
message(STATUS "Using builtin GSL CBLAS for optional parts of TMVA")
add_dependencies(Blas GSL)
target_include_directories(Blas INTERFACE ${GSL_INCLUDE_DIR})
target_link_libraries(Blas INTERFACE ${GSL_CBLAS_LIBRARY})
target_compile_definitions(Blas INTERFACE -DR__USE_CBLAS)
elseif(use_gsl_cblas AND GSL_FOUND)
message(STATUS "Using GSL CBLAS for optional parts of TMVA")
target_link_libraries(Blas INTERFACE GSL::gslcblas)
target_compile_definitions(Blas INTERFACE -DR__USE_CBLAS)
else()
if(fail-on-missing)
message(SEND_ERROR "tmva-cpu can't be built because BLAS was not found!")
else()
message(STATUS "tmva-cpu disabled because BLAS was not found")
set(tmva-cpu OFF CACHE BOOL "Disabled because BLAS was not found (${tmva-cpu_description})" FORCE)
endif()
endif()
endif()
if(tmva)
if(tmva-gpu AND NOT CMAKE_CUDA_COMPILER)
set(tmva-gpu OFF CACHE BOOL "Disabled because cuda not found" FORCE)
endif()
Expand Down Expand Up @@ -1345,7 +1367,6 @@ if(tmva)
set(tmva-rmva OFF CACHE BOOL "Disabled because R was not found (${tmva-rmva_description})" FORCE)
endif()
else()
set(tmva-cpu OFF CACHE BOOL "Disabled because 'tmva' is disabled (${tmva-cpu_description})" FORCE)
set(tmva-gpu OFF CACHE BOOL "Disabled because 'tmva' is disabled (${tmva-gpu_description})" FORCE)
set(tmva-cudnn OFF CACHE BOOL "Disabled because 'tmva' is disabled (${tmva-rmva_description})" FORCE)
set(tmva-pymva OFF CACHE BOOL "Disabled because 'tmva' is disabled (${tmva-pymva_description})" FORCE)
Expand Down
2 changes: 1 addition & 1 deletion hist/hist/inc/HFitInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ namespace ROOT {
/**
compute the chi2 value for an histogram given a function (see TH1::Chisquare for the documentation)
*/
double Chisquare(const TH1 & h1, TF1 & f1, bool useRange, EChisquareType type);
double Chisquare(const TH1 & h1, TF1 & f1, bool useRange, EChisquareType type, bool useIntegral = false);

/**
compute the chi2 value for a graph given a function (see TGraph::Chisquare)
Expand Down
9 changes: 5 additions & 4 deletions hist/hist/src/HFitImpl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace HFit {
void StoreAndDrawFitFunction(FitObject * h1, TF1 * f1, const ROOT::Fit::DataRange & range, bool, bool, const char *goption);

template <class FitObject>
double ComputeChi2(const FitObject & h1, TF1 &f1, bool useRange, ROOT::Fit::EChisquareType type );
double ComputeChi2(const FitObject & h1, TF1 &f1, bool useRange, ROOT::Fit::EChisquareType type, bool useIntegral = false);



Expand Down Expand Up @@ -1029,22 +1029,23 @@ TFitResultPtr ROOT::Fit::FitObject(THnBase * s1, TF1 *f1 , Foption_t & foption ,
// function to compute the simple chi2 for graphs and histograms


double ROOT::Fit::Chisquare(const TH1 & h1, TF1 & f1, bool useRange, ROOT::Fit::EChisquareType type) {
return HFit::ComputeChi2(h1,f1,useRange, type);
double ROOT::Fit::Chisquare(const TH1 & h1, TF1 & f1, bool useRange, ROOT::Fit::EChisquareType type, bool useIntegral) {
return HFit::ComputeChi2(h1,f1,useRange, type, useIntegral);
}

double ROOT::Fit::Chisquare(const TGraph & g, TF1 & f1, bool useRange) {
return HFit::ComputeChi2(g,f1, useRange, ROOT::Fit::EChisquareType::kNeyman);
}

template<class FitObject>
double HFit::ComputeChi2(const FitObject & obj, TF1 & f1, bool useRange, ROOT::Fit::EChisquareType type ) {
double HFit::ComputeChi2(const FitObject & obj, TF1 & f1, bool useRange, ROOT::Fit::EChisquareType type, bool useIntegral ) {

// implement using the fitting classes
ROOT::Fit::DataOptions opt;
opt.fUseEmpty = (type != ROOT::Fit::EChisquareType::kNeyman); // use empty bin when not using Neyman chisquare (observed error)
opt.fExpErrors = (type == ROOT::Fit::EChisquareType::kPearson);
opt.fErrors1 = (type == ROOT::Fit::EChisquareType::kPearson); // not using observed errors in Pearson chi2
opt.fIntegral = useIntegral; // use bin integral instead of value at bin center

ROOT::Fit::DataRange range;
// get range of function
Expand Down
4 changes: 3 additions & 1 deletion hist/hist/src/TH1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2515,6 +2515,7 @@ Double_t TH1::Chi2TestX(const TH1* h2, Double_t &chi2, Int_t &ndf, Int_t &igood
/// Use option "R" for restricting the chisquare calculation to the given range of the function
/// Use option "L" for using the chisquare based on the poisson likelihood (Baker-Cousins Chisquare)
/// Use option "P" for using the Pearson chisquare based on the expected bin errors
/// Use option "I" for using the integral of the function in each bin instead of the value at the bin center

Double_t TH1::Chisquare(TF1 * func, Option_t *option) const
{
Expand All @@ -2525,11 +2526,12 @@ Double_t TH1::Chisquare(TF1 * func, Option_t *option) const

TString opt(option); opt.ToUpper();
bool useRange = opt.Contains("R");
bool useIntegral = opt.Contains("I");
ROOT::Fit::EChisquareType type = ROOT::Fit::EChisquareType::kNeyman; // default chi2 with observed error
if (opt.Contains("L")) type = ROOT::Fit::EChisquareType::kPLikeRatio;
else if (opt.Contains("P")) type = ROOT::Fit::EChisquareType::kPearson;

return ROOT::Fit::Chisquare(*this, *func, useRange, type);
return ROOT::Fit::Chisquare(*this, *func, useRange, type, useIntegral);
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
11 changes: 0 additions & 11 deletions roofit/roofitcore/src/RooFit/Evaluator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -326,17 +326,6 @@ void Evaluator::updateOutputSizes()
for (auto &info : _nodes) {
info.outputSize = outputSizeMap.at(info.absArg);
info.isDirty = true;
// We don't need dirty flag propagation because the evaluator takes care
// of deciding what needs to be re-evaluated. We can disable the regular
// dirty state propagation. However, fundamental variables like
// RooRealVars and RooCategories are usually shared with other
// computation graphs outside the evaluator, so they can't be mutated.
// See also the code of the RooMinimizer, which ensures that dirty state
// propagation is temporarily disabled during minimization to really
// eliminate any overhead from the dirty flag propagation.
if (!info.absArg->isFundamental()) {
setOperMode(info.absArg, RooAbsArg::ADirty);
}
}

if (_useGPU) {
Expand Down
2 changes: 1 addition & 1 deletion tmva/sofie_parsers/src/RModelParser_ONNX.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ void RModelParser_ONNX::ParseONNXGraph(RModel & rmodel, const onnx::GraphProto &
std::cout << "\t" << i << " " << nodesOrder[i] << " parsing operator " << op_type << std::endl;
}

std::unique_ptr<ROperator> op = ParseOperator(i, graph, nodesOrder, nodesChildren[i]);
std::unique_ptr<ROperator> op = ParseOperator(i, graph, nodesOrder, nodesChildren[nodesOrder[i]]);
if (!op) {
if (verbose) {
std::cout << "\t\tskipping operator since it is fused with previous one" << std::endl;
Expand Down
Loading