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 RooBatchCompute {
29class AbsBufferManager;
30}
31
32namespace RooFit {
33
34struct NodeInfo;
35
36class Evaluator {
37public:
38 Evaluator(const RooAbsReal &absReal, bool useGPU = false);
39 ~Evaluator();
40
41 std::span<const double> run();
42 void setInput(std::string const &name, std::span<const double> inputArray, bool isOnDevice);
44 void print(std::ostream &os);
45
47
48private:
49 void processVariable(NodeInfo &nodeInfo);
50 void setClientsDirty(NodeInfo &nodeInfo);
51 std::span<const double> getValHeterogeneous();
52 void markGPUNodes();
53 void assignToGPU(NodeInfo &info);
54 void computeCPUNode(const RooAbsArg *node, NodeInfo &info);
55 void setOperMode(RooAbsArg *arg, RooAbsArg::OperMode opMode);
56 void syncDataTokens();
57 void updateOutputSizes();
58
59 std::unique_ptr<RooBatchCompute::AbsBufferManager> _bufferManager;
61 const bool _useGPU = false;
66 std::vector<NodeInfo> _nodes; // the ordered computation graph
67 std::stack<std::unique_ptr<ChangeOperModeRAII>> _changeOperModeRAIIs;
68};
69
70} // end namespace RooFit
71
72#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:36
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:61
std::vector< NodeInfo > _nodes
Definition Evaluator.h:66
bool _needToUpdateOutputSizes
Definition Evaluator.h:63
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.
std::unique_ptr< RooBatchCompute::AbsBufferManager > _bufferManager
Definition Evaluator.h:59
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:65
RooFit::EvalContext _evalContextCPU
Definition Evaluator.h:64
void computeCPUNode(const RooAbsArg *node, NodeInfo &info)
std::stack< std::unique_ptr< ChangeOperModeRAII > > _changeOperModeRAIIs
Definition Evaluator.h:67
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:60
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 JSONIO.h:26
A struct used by the Evaluator to store information on the RooAbsArgs in the computation graph.
Definition Evaluator.cxx:97