Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
Evaluator.h
Go to the documentation of this file.
1/*
2 * Project: RooFit
3 * Authors:
4 * Jonas Rembser, CERN 2021
5 * Emmanouil Michalainas, CERN 2021
6 *
7 * Copyright (c) 2023, CERN
8 *
9 * Redistribution and use in source and binary forms,
10 * with or without modification, are permitted according to the terms
11 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
12 */
13
14#ifndef RooFit_Evaluator_h
15#define RooFit_Evaluator_h
16
17#include <RooAbsReal.h>
18#include <RooFit/EvalContext.h>
19
20#include <RConfig.h>
21
22#include <memory>
23
25class RooAbsArg;
26
27namespace RooBatchCompute {
28class AbsBufferManager;
29}
30
31namespace RooFit {
32
33struct NodeInfo;
34
35class Evaluator {
36public:
37 Evaluator(const RooAbsReal &absReal, bool useGPU = false);
38 ~Evaluator();
39
40 std::span<const double> run();
41 void setInput(std::string const &name, std::span<const double> inputArray, bool isOnDevice);
43 void print(std::ostream &os);
44
46
47 std::unique_ptr<ChangeOperModeRAII> setOperModes(RooAbsArg::OperMode opMode);
48
49private:
53 std::span<const double> getValHeterogeneous();
54 void markGPUNodes();
56 void computeCPUNode(const RooAbsArg *node, NodeInfo &info);
58 void syncDataTokens();
59 void updateOutputSizes();
60
61 std::unique_ptr<RooBatchCompute::AbsBufferManager> _bufferManager;
63 const bool _useGPU = false;
68 std::vector<NodeInfo> _nodes; // the ordered computation graph
69 std::unordered_map<TNamed const *, NodeInfo *> _nodesMap; // for quick lookup of nodes
70 std::unique_ptr<ChangeOperModeRAII> _operModeChanges;
71};
72
73} // end namespace RooFit
74
75#endif
char name[80]
Definition TGX11.cxx:145
Scope guard that temporarily changes the operation mode of one or more RooAbsArg instances.
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:76
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:63
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Evaluates a RooAbsReal object in other ways than recursive graph traversal.
Definition Evaluator.h:35
void print(std::ostream &os)
void setClientsDirty(NodeInfo &nodeInfo)
Flags all the clients of a given node dirty.
std::unique_ptr< ChangeOperModeRAII > setOperModes(RooAbsArg::OperMode opMode)
RooArgSet getParameters() const
Gets all the parameters of the RooAbsReal.
void setOffsetMode(RooFit::EvalContext::OffsetMode)
Sets the offset mode for evaluation.
void syncDataTokens()
If there are servers with the same name that got de-duplicated in the _nodes list,...
const bool _useGPU
Definition Evaluator.h:63
std::unordered_map< TNamed const *, NodeInfo * > _nodesMap
Definition Evaluator.h:69
std::unique_ptr< ChangeOperModeRAII > _operModeChanges
Definition Evaluator.h:70
std::vector< NodeInfo > _nodes
Definition Evaluator.h:68
bool _needToUpdateOutputSizes
Definition Evaluator.h:65
std::span< const double > getValHeterogeneous()
Returns the value of the top node in the computation graph.
std::span< const double > run()
Returns the value of the top node in the computation graph.
Evaluator(const RooAbsReal &absReal, bool useGPU=false)
Construct a new Evaluator.
void processVariable(NodeInfo &nodeInfo)
Process a variable in the computation graph.
void processCategory(NodeInfo &nodeInfo)
Process a category in the computation graph.
std::unique_ptr< RooBatchCompute::AbsBufferManager > _bufferManager
Definition Evaluator.h:61
void markGPUNodes()
Decides which nodes are assigned to the GPU in a CUDA fit.
void assignToGPU(NodeInfo &info)
Assign a node to be computed in the GPU.
void setInput(std::string const &name, std::span< const double > inputArray, bool isOnDevice)
RooFit::EvalContext _evalContextCUDA
Definition Evaluator.h:67
RooFit::EvalContext _evalContextCPU
Definition Evaluator.h:66
void computeCPUNode(const RooAbsArg *node, NodeInfo &info)
void setOperMode(RooAbsArg *arg, RooAbsArg::OperMode opMode)
Temporarily change the operation mode of a RooAbsArg until the Evaluator gets deleted.
RooAbsReal & _topNode
Definition Evaluator.h:62
Namespace for dispatching RooFit computations to various backends.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition CodegenImpl.h:72
A struct used by the Evaluator to store information on the RooAbsArgs in the computation graph.
Definition Evaluator.cxx:98