Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooFit::Evaluator Class Reference

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 doublerun ()
 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 doublegetValHeterogeneous ()
 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>

Constructor & Destructor Documentation

◆ Evaluator()

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.

Parameters
[in]absRealThe RooAbsReal object that sits on top of the computation graph that we want to evaluate.
[in]useGPUWhether the evaluation should be preferably done on the GPU.

Definition at line 150 of file Evaluator.cxx.

◆ ~Evaluator()

RooFit::Evaluator::~Evaluator ( )

Definition at line 332 of file Evaluator.cxx.

Member Function Documentation

◆ assignToGPU()

void RooFit::Evaluator::assignToGPU ( NodeInfo info)
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.

◆ computeCPUNode()

void RooFit::Evaluator::computeCPUNode ( const RooAbsArg node,
NodeInfo info 
)
private

Definition at line 341 of file Evaluator.cxx.

◆ getParameters()

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.

Warning
If we find another solution to get the parameters efficiently, this function might be removed without notice.

Definition at line 647 of file Evaluator.cxx.

◆ getValHeterogeneous()

std::span< const double > RooFit::Evaluator::getValHeterogeneous ( )
private

Returns the value of the top node in the computation graph.

Definition at line 450 of file Evaluator.cxx.

◆ markGPUNodes()

void RooFit::Evaluator::markGPUNodes ( )
private

Decides which nodes are assigned to the GPU in a CUDA fit.

Definition at line 560 of file Evaluator.cxx.

◆ print()

void RooFit::Evaluator::print ( std::ostream &  os)

Definition at line 585 of file Evaluator.cxx.

◆ processVariable()

void RooFit::Evaluator::processVariable ( NodeInfo nodeInfo)
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.

◆ run()

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.

◆ setClientsDirty()

void RooFit::Evaluator::setClientsDirty ( NodeInfo nodeInfo)
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.

◆ setInput()

void RooFit::Evaluator::setInput ( std::string const &  name,
std::span< const double inputArray,
bool  isOnDevice 
)

Definition at line 241 of file Evaluator.cxx.

◆ setOffsetMode()

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.

Parameters
modeThe offset mode to be set.
Note
This function marks reducer nodes as dirty if the offset mode is changed, because only reducer nodes can use offsetting.

Definition at line 669 of file Evaluator.cxx.

◆ setOperMode()

void RooFit::Evaluator::setOperMode ( RooAbsArg arg,
RooAbsArg::OperMode  opMode 
)
private

Temporarily change the operation mode of a RooAbsArg until the Evaluator gets deleted.

Definition at line 578 of file Evaluator.cxx.

◆ syncDataTokens()

void RooFit::Evaluator::syncDataTokens ( )
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.

◆ updateOutputSizes()

void RooFit::Evaluator::updateOutputSizes ( )
private

Definition at line 292 of file Evaluator.cxx.

Member Data Documentation

◆ _bufferManager

std::unique_ptr<RooBatchCompute::AbsBufferManager> RooFit::Evaluator::_bufferManager
private

Definition at line 59 of file Evaluator.h.

◆ _changeOperModeRAIIs

std::stack<std::unique_ptr<ChangeOperModeRAII> > RooFit::Evaluator::_changeOperModeRAIIs
private

Definition at line 67 of file Evaluator.h.

◆ _evalContextCPU

RooFit::EvalContext RooFit::Evaluator::_evalContextCPU
private

Definition at line 64 of file Evaluator.h.

◆ _evalContextCUDA

RooFit::EvalContext RooFit::Evaluator::_evalContextCUDA
private

Definition at line 65 of file Evaluator.h.

◆ _needToUpdateOutputSizes

bool RooFit::Evaluator::_needToUpdateOutputSizes = false
private

Definition at line 63 of file Evaluator.h.

◆ _nEvaluations

int RooFit::Evaluator::_nEvaluations = 0
private

Definition at line 62 of file Evaluator.h.

◆ _nodes

std::vector<NodeInfo> RooFit::Evaluator::_nodes
private

Definition at line 66 of file Evaluator.h.

◆ _topNode

RooAbsReal& RooFit::Evaluator::_topNode
private

Definition at line 60 of file Evaluator.h.

◆ _useGPU

const bool RooFit::Evaluator::_useGPU = false
private

Definition at line 61 of file Evaluator.h.

Libraries for RooFit::Evaluator:

The documentation for this class was generated from the following files: