Evaluates a RooAbsReal object in other ways than recursive graph traversal.
Currently, it is being used for evaluating a RooAbsReal object and supplying the value to the minimizer, during a fit. The class scans the dependencies and schedules the computations in a secure and efficient way. The computations take place in the RooBatchCompute library and can be carried off by either the CPU or a CUDA-supporting GPU. The Evaluator class takes care of data transfers. An instance of this class is created every time RooAbsPdf::fitTo() is called and gets destroyed when the fitting ends.
Definition at line 36 of file Evaluator.h.
Public Member Functions | |
Evaluator (const RooAbsReal &absReal, bool useGPU=false) | |
Construct a new Evaluator. | |
~Evaluator () | |
RooArgSet | getParameters () const |
Gets all the parameters of the RooAbsReal. | |
void | print (std::ostream &os) |
std::span< const double > | run () |
Returns the value of the top node in the computation graph. | |
void | setInput (std::string const &name, std::span< const double > inputArray, bool isOnDevice) |
void | setOffsetMode (RooFit::EvalContext::OffsetMode) |
Sets the offset mode for evaluation. | |
Private Member Functions | |
void | assignToGPU (NodeInfo &info) |
Assign a node to be computed in the GPU. | |
void | computeCPUNode (const RooAbsArg *node, NodeInfo &info) |
std::span< const double > | getValHeterogeneous () |
Returns the value of the top node in the computation graph. | |
void | markGPUNodes () |
Decides which nodes are assigned to the GPU in a CUDA fit. | |
void | processVariable (NodeInfo &nodeInfo) |
Process a variable in the computation graph. | |
void | setClientsDirty (NodeInfo &nodeInfo) |
Flags all the clients of a given node dirty. | |
void | setOperMode (RooAbsArg *arg, RooAbsArg::OperMode opMode) |
Temporarily change the operation mode of a RooAbsArg until the Evaluator gets deleted. | |
void | syncDataTokens () |
If there are servers with the same name that got de-duplicated in the _nodes list, we need to set their data tokens too. | |
void | updateOutputSizes () |
Private Attributes | |
std::unique_ptr< RooBatchCompute::AbsBufferManager > | _bufferManager |
std::stack< std::unique_ptr< ChangeOperModeRAII > > | _changeOperModeRAIIs |
RooFit::EvalContext | _evalContextCPU |
RooFit::EvalContext | _evalContextCUDA |
bool | _needToUpdateOutputSizes = false |
int | _nEvaluations = 0 |
std::vector< NodeInfo > | _nodes |
RooAbsReal & | _topNode |
const bool | _useGPU = false |
#include <RooFit/Evaluator.h>
RooFit::Evaluator::Evaluator | ( | const RooAbsReal & | absReal, |
bool | useGPU = false |
||
) |
Construct a new Evaluator.
The constructor analyzes and saves metadata about the graph, useful for the evaluation of it that will be done later. In case the CUDA mode is selected, there's also some CUDA-related initialization.
[in] | absReal | The RooAbsReal object that sits on top of the computation graph that we want to evaluate. |
[in] | useGPU | Whether the evaluation should be preferably done on the GPU. |
Definition at line 150 of file Evaluator.cxx.
RooFit::Evaluator::~Evaluator | ( | ) |
Definition at line 332 of file Evaluator.cxx.
|
private |
Assign a node to be computed in the GPU.
Scan it's clients and also assign them in case they only depend on GPU nodes.
Definition at line 525 of file Evaluator.cxx.
Definition at line 341 of file Evaluator.cxx.
RooArgSet RooFit::Evaluator::getParameters | ( | ) | const |
Gets all the parameters of the RooAbsReal.
This is in principle not necessary, because we can always ask the RooAbsReal itself, but the Evaluator has the cached information to get the answer quicker. Therefore, this is not meant to be used in general, just where it matters.
Definition at line 647 of file Evaluator.cxx.
|
private |
Returns the value of the top node in the computation graph.
Definition at line 450 of file Evaluator.cxx.
|
private |
Decides which nodes are assigned to the GPU in a CUDA fit.
Definition at line 560 of file Evaluator.cxx.
void RooFit::Evaluator::print | ( | std::ostream & | os | ) |
Definition at line 585 of file Evaluator.cxx.
|
private |
Process a variable in the computation graph.
This is a separate non-inlined function such that we can see in performance profiles how long this takes.
Definition at line 396 of file Evaluator.cxx.
std::span< const double > RooFit::Evaluator::run | ( | ) |
Returns the value of the top node in the computation graph.
Definition at line 420 of file Evaluator.cxx.
|
private |
Flags all the clients of a given node dirty.
This is a separate non-inlined function such that we can see in performance profiles how long this takes.
Definition at line 412 of file Evaluator.cxx.
void RooFit::Evaluator::setInput | ( | std::string const & | name, |
std::span< const double > | inputArray, | ||
bool | isOnDevice | ||
) |
Definition at line 241 of file Evaluator.cxx.
void RooFit::Evaluator::setOffsetMode | ( | RooFit::EvalContext::OffsetMode | mode | ) |
Sets the offset mode for evaluation.
This function sets the offset mode for evaluation to the specified mode. It updates the offset mode for both CPU and CUDA evaluation contexts.
mode | The offset mode to be set. |
Definition at line 669 of file Evaluator.cxx.
|
private |
Temporarily change the operation mode of a RooAbsArg until the Evaluator gets deleted.
Definition at line 578 of file Evaluator.cxx.
|
private |
If there are servers with the same name that got de-duplicated in the _nodes
list, we need to set their data tokens too.
We find such nodes by visiting the servers of every known node.
Definition at line 225 of file Evaluator.cxx.
|
private |
Definition at line 292 of file Evaluator.cxx.
|
private |
Definition at line 59 of file Evaluator.h.
|
private |
Definition at line 67 of file Evaluator.h.
|
private |
Definition at line 64 of file Evaluator.h.
|
private |
Definition at line 65 of file Evaluator.h.
|
private |
Definition at line 63 of file Evaluator.h.
|
private |
Definition at line 62 of file Evaluator.h.
|
private |
Definition at line 66 of file Evaluator.h.
|
private |
Definition at line 60 of file Evaluator.h.
|
private |
Definition at line 61 of file Evaluator.h.