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 38 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 | setNThreads (int nThreads) |
| Sets the number of threads to use for the evaluation of a single node. | |
| void | setOffsetMode (RooFit::EvalContext::OffsetMode) |
| Sets the offset mode for evaluation. | |
| std::unique_ptr< ChangeOperModeRAII > | setOperModes (RooAbsArg::OperMode opMode) |
| void | unregisterNode (RooAbsArg const &arg) |
| Called from RooAbsArg::~RooAbsArg() when a node of the computation graph is deleted while this Evaluator is still alive. | |
Private Member Functions | |
| void | assignToGPU (NodeInfo &info) |
| Enqueue the computation of a node on 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 | processCategory (NodeInfo &nodeInfo) |
| Process a category in the computation graph. | |
| 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 |
| RooBatchCompute::CudaInterface::CudaStream * | _cudaStream = nullptr |
| RooFit::EvalContext | _evalContextCPU |
| RooFit::EvalContext | _evalContextCUDA |
| bool | _needToUpdateOutputSizes = false |
| int | _nEvaluations = 0 |
| std::vector< NodeInfo > | _nodes |
| std::unordered_map< TNamed const *, NodeInfo * > | _nodesMap |
| std::unique_ptr< ChangeOperModeRAII > | _operModeChanges |
| 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 153 of file Evaluator.cxx.
| RooFit::Evaluator::~Evaluator | ( | ) |
Definition at line 351 of file Evaluator.cxx.
|
private |
Enqueue the computation of a node on the GPU.
Definition at line 595 of file Evaluator.cxx.
Definition at line 376 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 790 of file Evaluator.cxx.
|
private |
Returns the value of the top node in the computation graph.
Definition at line 511 of file Evaluator.cxx.
|
private |
Decides which nodes are assigned to the GPU in a CUDA fit.
Definition at line 625 of file Evaluator.cxx.
| void RooFit::Evaluator::print | ( | std::ostream & | os | ) |
Definition at line 728 of file Evaluator.cxx.
|
private |
Process a category 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 445 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 429 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 469 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 461 of file Evaluator.cxx.
| void RooFit::Evaluator::setInput | ( | std::string const & | name, |
| std::span< const double > | inputArray, | ||
| bool | isOnDevice ) |
Definition at line 258 of file Evaluator.cxx.
| void RooFit::Evaluator::setNThreads | ( | int | nThreads | ) |
Sets the number of threads to use for the evaluation of a single node.
With a value greater than one, the computation functions and reductions of the CPU backend process large batches multi-threaded, using up to the given number of threads. Nodes evaluated on the CPU with fewer events than an internal threshold are still evaluated single-threaded, so requesting multiple threads never introduces scheduling overhead for small fits.
Definition at line 664 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 812 of file Evaluator.cxx.
|
private |
Temporarily change the operation mode of a RooAbsArg until the Evaluator gets deleted.
Definition at line 678 of file Evaluator.cxx.
| std::unique_ptr< ChangeOperModeRAII > RooFit::Evaluator::setOperModes | ( | RooAbsArg::OperMode | opMode | ) |
Definition at line 698 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 242 of file Evaluator.cxx.
| void RooFit::Evaluator::unregisterNode | ( | RooAbsArg const & | arg | ) |
Called from RooAbsArg::~RooAbsArg() when a node of the computation graph is deleted while this Evaluator is still alive.
The Evaluator can't be used anymore after that, but its destructor must not touch the deleted node. For internal use only.
Definition at line 368 of file Evaluator.cxx.
|
private |
Definition at line 321 of file Evaluator.cxx.
|
private |
Definition at line 68 of file Evaluator.h.
|
private |
Definition at line 79 of file Evaluator.h.
|
private |
Definition at line 73 of file Evaluator.h.
|
private |
Definition at line 74 of file Evaluator.h.
|
private |
Definition at line 72 of file Evaluator.h.
|
private |
Definition at line 71 of file Evaluator.h.
|
private |
Definition at line 75 of file Evaluator.h.
Definition at line 76 of file Evaluator.h.
|
private |
Definition at line 77 of file Evaluator.h.
|
private |
Definition at line 69 of file Evaluator.h.
|
private |
Definition at line 70 of file Evaluator.h.