-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RF] RooFit AD refactoring #16772
Open
guitargeek
wants to merge
3
commits into
root-project:master
Choose a base branch
from
guitargeek:roofit_ad_refactoring
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,617
−1,257
Open
[RF] RooFit AD refactoring #16772
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. | ||
# All rights reserved. | ||
# | ||
# For the licensing terms see $ROOTSYS/LICENSE. | ||
# For the list of contributors see $ROOTSYS/README/CREDITS. | ||
|
||
############################################################################ | ||
# CMakeLists.txt file for building ROOT rootfit/histfactory package | ||
# @author Pere Mato, CERN | ||
############################################################################ | ||
|
||
ROOT_STANDARD_LIBRARY_PACKAGE(RooFitCodegen | ||
HEADERS | ||
RooFit/CodegenImpl.h | ||
SOURCES | ||
src/CodegenImpl.cxx | ||
DICTIONARY_OPTIONS | ||
"-writeEmptyRootPCM" | ||
DEPENDENCIES | ||
RooFit | ||
RooFitCore | ||
HistFactory | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifdef __CLING__ | ||
|
||
#pragma link off all globals; | ||
#pragma link off all classes; | ||
#pragma link off all functions; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
/* | ||
* Project: RooFit | ||
* Authors: | ||
* Jonas Rembser, CERN 2024 | ||
* | ||
* Copyright (c) 2024, CERN | ||
* | ||
* Redistribution and use in source and binary forms, | ||
* with or without modification, are permitted according to the terms | ||
* listed in LICENSE (http://roofit.sourceforge.net/license.txt) | ||
*/ | ||
|
||
#ifndef RooFit_Detail_CodegenImpl_h | ||
#define RooFit_Detail_CodegenImpl_h | ||
|
||
#include <RooFit/CodegenContext.h> | ||
|
||
#include <type_traits> | ||
|
||
class ParamHistFunc; | ||
class PiecewiseInterpolation; | ||
class RooAbsArg; | ||
class RooAbsReal; | ||
class RooAddPdf; | ||
class RooAddition; | ||
class RooBernstein; | ||
class RooBifurGauss; | ||
class RooCBShape; | ||
class RooChebychev; | ||
class RooConstVar; | ||
class RooConstraintSum; | ||
class RooEffProd; | ||
class RooEfficiency; | ||
class RooExponential; | ||
class RooExtendPdf; | ||
class RooFormulaVar; | ||
class RooGamma; | ||
class RooGaussian; | ||
class RooGenericPdf; | ||
class RooHistFunc; | ||
class RooHistPdf; | ||
class RooLandau; | ||
class RooLognormal; | ||
class RooMultiVarGaussian; | ||
class RooParamHistFunc; | ||
class RooPoisson; | ||
class RooPolyVar; | ||
class RooPolynomial; | ||
class RooProduct; | ||
class RooRatio; | ||
class RooRealIntegral; | ||
class RooRealSumFunc; | ||
class RooRealSumPdf; | ||
class RooRealVar; | ||
class RooRecursiveFraction; | ||
class RooUniform; | ||
|
||
namespace RooStats { | ||
namespace HistFactory { | ||
class FlexibleInterpVar; | ||
} | ||
} // namespace RooStats | ||
|
||
namespace RooFit { | ||
|
||
namespace Detail { | ||
class RooFixedProdPdf; | ||
class RooNLLVarNew; | ||
class RooNormalizedPdf; | ||
} // namespace Detail | ||
|
||
class CodegenContext; | ||
|
||
void codegenImpl(Detail::RooFixedProdPdf &arg, CodegenContext &ctx); | ||
void codegenImpl(Detail::RooNLLVarNew &arg, CodegenContext &ctx); | ||
void codegenImpl(Detail::RooNormalizedPdf &arg, CodegenContext &ctx); | ||
void codegenImpl(ParamHistFunc &arg, CodegenContext &ctx); | ||
void codegenImpl(PiecewiseInterpolation &arg, CodegenContext &ctx); | ||
void codegenImpl(RooAbsArg &arg, RooFit::CodegenContext &ctx); | ||
void codegenImpl(RooAddPdf &arg, CodegenContext &ctx); | ||
void codegenImpl(RooAddition &arg, CodegenContext &ctx); | ||
void codegenImpl(RooBernstein &arg, CodegenContext &ctx); | ||
void codegenImpl(RooBifurGauss &arg, CodegenContext &ctx); | ||
void codegenImpl(RooCBShape &arg, CodegenContext &ctx); | ||
void codegenImpl(RooChebychev &arg, CodegenContext &ctx); | ||
void codegenImpl(RooConstVar &arg, CodegenContext &ctx); | ||
void codegenImpl(RooConstraintSum &arg, CodegenContext &ctx); | ||
void codegenImpl(RooEffProd &arg, CodegenContext &ctx); | ||
void codegenImpl(RooEfficiency &arg, CodegenContext &ctx); | ||
void codegenImpl(RooExponential &arg, CodegenContext &ctx); | ||
void codegenImpl(RooExtendPdf &arg, CodegenContext &ctx); | ||
void codegenImpl(RooFormulaVar &arg, CodegenContext &ctx); | ||
void codegenImpl(RooGamma &arg, CodegenContext &ctx); | ||
void codegenImpl(RooGaussian &arg, CodegenContext &ctx); | ||
void codegenImpl(RooGenericPdf &arg, CodegenContext &ctx); | ||
void codegenImpl(RooHistFunc &arg, CodegenContext &ctx); | ||
void codegenImpl(RooHistPdf &arg, CodegenContext &ctx); | ||
void codegenImpl(RooLandau &arg, CodegenContext &ctx); | ||
void codegenImpl(RooLognormal &arg, CodegenContext &ctx); | ||
void codegenImpl(RooMultiVarGaussian &arg, CodegenContext &ctx); | ||
void codegenImpl(RooParamHistFunc &arg, CodegenContext &ctx); | ||
void codegenImpl(RooPoisson &arg, CodegenContext &ctx); | ||
void codegenImpl(RooPolyVar &arg, CodegenContext &ctx); | ||
void codegenImpl(RooPolynomial &arg, CodegenContext &ctx); | ||
void codegenImpl(RooProduct &arg, CodegenContext &ctx); | ||
void codegenImpl(RooRatio &arg, CodegenContext &ctx); | ||
void codegenImpl(RooRealIntegral &arg, CodegenContext &ctx); | ||
void codegenImpl(RooRealSumFunc &arg, CodegenContext &ctx); | ||
void codegenImpl(RooRealSumPdf &arg, CodegenContext &ctx); | ||
void codegenImpl(RooRealVar &arg, CodegenContext &ctx); | ||
void codegenImpl(RooRecursiveFraction &arg, CodegenContext &ctx); | ||
void codegenImpl(RooStats::HistFactory::FlexibleInterpVar &arg, CodegenContext &ctx); | ||
void codegenImpl(RooUniform &arg, CodegenContext &ctx); | ||
|
||
std::string codegenIntegralImpl(RooAbsReal &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
std::string codegenIntegralImpl(RooBernstein &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
std::string codegenIntegralImpl(RooBifurGauss &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
std::string codegenIntegralImpl(RooCBShape &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
std::string codegenIntegralImpl(RooChebychev &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
std::string codegenIntegralImpl(RooEfficiency &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
std::string codegenIntegralImpl(RooExponential &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
std::string codegenIntegralImpl(RooGamma &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
std::string codegenIntegralImpl(RooGaussian &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
std::string codegenIntegralImpl(RooHistFunc &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
std::string codegenIntegralImpl(RooHistPdf &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
std::string codegenIntegralImpl(RooLandau &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
std::string codegenIntegralImpl(RooLognormal &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
std::string codegenIntegralImpl(RooMultiVarGaussian &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
std::string codegenIntegralImpl(RooPoisson &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
std::string codegenIntegralImpl(RooPolyVar &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
std::string codegenIntegralImpl(RooPolynomial &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
std::string codegenIntegralImpl(RooUniform &arg, int code, const char *rangeName, CodegenContext &ctx); | ||
|
||
template <class Arg_t, int P> | ||
std::string codegenIntegralImpl(Arg_t &arg, int code, const char *rangeName, CodegenContext &ctx, Prio<P> p) | ||
{ | ||
if constexpr (std::is_same<Prio<P>, PrioLowest>::value) { | ||
return codegenIntegralImpl(arg, code, rangeName, ctx); | ||
} else { | ||
return codegenIntegralImpl(arg, code, rangeName, ctx, p.next()); | ||
} | ||
} | ||
|
||
template <class Arg_t> | ||
struct CodegenIntegralImplCaller { | ||
|
||
static auto call(RooAbsReal &arg, int code, const char *rangeName, RooFit::CodegenContext &ctx) | ||
{ | ||
return codegenIntegralImpl(static_cast<Arg_t &>(arg), code, rangeName, ctx, PrioHighest{}); | ||
} | ||
}; | ||
|
||
} // namespace RooFit | ||
|
||
#endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand correctly that the Caller first tries to call the prio 1 (highest) implementation, and then will loop through all 10 using the Impl template until it finds one that is actually implemented for the Arg_t already so doesn't need to use the template?
Few questions:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great comments!
unordered_map
, so speed up the lookup for the same class later. I'll check what would happen if the caching is disabled, that's an interesting question!