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>
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) const;
49
50private:
51 void processVariable(NodeInfo &nodeInfo);
52 void setClientsDirty(NodeInfo &nodeInfo);
53 std::span<const double> getValHeterogeneous();
54 void markGPUNodes();
55 void assignToGPU(NodeInfo &info);
56 void computeCPUNode(const RooAbsArg *node, NodeInfo &info);
57 void setOperMode(RooAbsArg *arg, RooAbsArg::OperMode opMode);
58 void syncDataTokens();
59 void updateOutputSizes();
60
61 std::unique_ptr<Detail::BufferManager> _bufferManager;
63 const bool _useGPU = false;
68 std::vector<NodeInfo> _nodes; // the ordered computation graph
69 std::stack<std::unique_ptr<ChangeOperModeRAII>> _changeOperModeRAIIs;
70};
71
72} // end namespace RooFit
73
74#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:79
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
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.
RooFit::Detail::DataMap _dataMapCPU
Definition Evaluator.h:66
std::span< const double > run()
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.
const bool _useGPU
Definition Evaluator.h:63
std::vector< NodeInfo > _nodes
Definition Evaluator.h:68
bool _needToUpdateOutputSizes
Definition Evaluator.h:65
void print(std::ostream &os) const
std::span< const double > getValHeterogeneous()
Returns the value of the top node in the computation graph.
RooFit::Detail::DataMap _dataMapCUDA
Definition Evaluator.h:67
RooArgSet getParameters() const
Gets all the parameters of the RooAbsReal.
void setInput(std::string const &name, std::span< const double > inputArray, bool isOnDevice)
void assignToGPU(NodeInfo &info)
Assign a node to be computed in the GPU.
void syncDataTokens()
If there are servers with the same name that got de-duplicated in the _nodes list,...
void processVariable(NodeInfo &nodeInfo)
Process a variable in the computation graph.
std::unique_ptr< Detail::BufferManager > _bufferManager
Definition Evaluator.h:61
std::stack< std::unique_ptr< ChangeOperModeRAII > > _changeOperModeRAIIs
Definition Evaluator.h:69
RooAbsReal & _topNode
Definition Evaluator.h:62
void setClientsDirty(NodeInfo &nodeInfo)
Flags all the clients of a given node dirty.
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.