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#include <stack>
24
26class RooAbsArg;
27
28namespace RooFit {
29
30namespace Detail {
31class BufferManager;
32}
33
34struct NodeInfo;
35
36namespace Detail {
37class BufferManager;
38}
39
40class Evaluator {
41public:
42 Evaluator(const RooAbsReal &absReal, bool useGPU = false);
43 ~Evaluator();
44
45 std::span<const double> run();
46 void setInput(std::string const &name, std::span<const double> inputArray, bool isOnDevice);
48 void print(std::ostream &os);
49
51
52private:
53 void processVariable(NodeInfo &nodeInfo);
54 void setClientsDirty(NodeInfo &nodeInfo);
55 std::span<const double> getValHeterogeneous();
56 void markGPUNodes();
57 void assignToGPU(NodeInfo &info);
58 void computeCPUNode(const RooAbsArg *node, NodeInfo &info);
59 void setOperMode(RooAbsArg *arg, RooAbsArg::OperMode opMode);
60 void syncDataTokens();
61 void updateOutputSizes();
62
63 std::unique_ptr<Detail::BufferManager> _bufferManager;
65 const bool _useGPU = false;
70 std::vector<NodeInfo> _nodes; // the ordered computation graph
71 std::stack<std::unique_ptr<ChangeOperModeRAII>> _changeOperModeRAIIs;
72};
73
74} // end namespace RooFit
75
76#endif
char name[80]
Definition TGX11.cxx:110
Struct to temporarily change the operation mode of a RooAbsArg until it goes out of scope.
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:77
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
Evaluates a RooAbsReal object in other ways than recursive graph traversal.
Definition Evaluator.h:40
void print(std::ostream &os)
void setClientsDirty(NodeInfo &nodeInfo)
Flags all the clients of a given node dirty.
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:65
std::vector< NodeInfo > _nodes
Definition Evaluator.h:70
bool _needToUpdateOutputSizes
Definition Evaluator.h:67
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.
void processVariable(NodeInfo &nodeInfo)
Process a variable in the computation graph.
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:69
RooFit::EvalContext _evalContextCPU
Definition Evaluator.h:68
std::unique_ptr< Detail::BufferManager > _bufferManager
Definition Evaluator.h:63
void computeCPUNode(const RooAbsArg *node, NodeInfo &info)
std::stack< std::unique_ptr< ChangeOperModeRAII > > _changeOperModeRAIIs
Definition Evaluator.h:71
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:64
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition JSONIO.h:26
A struct used by the Evaluator to store information on the RooAbsArgs in the computation graph.