Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooFitDriver.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) 2021, 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_RooFitDriver_h
15#define RooFit_RooFitDriver_h
16
18#include <RooGlobalFunc.h>
19#include <RooHelpers.h>
21
22#include <chrono>
23#include <memory>
24#include <stack>
25
26class RooAbsArg;
27class RooAbsReal;
28class RooAbsCategory;
29class RooAbsData;
30namespace RooFit {
32}
33
34namespace ROOT {
35namespace Experimental {
36
37struct NodeInfo;
38
40public:
41 ////////////////////
42 // Enums and aliases
43
44 using DataSpansMap = std::map<RooFit::Detail::DataKey, RooSpan<const double>>;
45
46 //////////////////////////
47 // Public member functions
48
49 RooFitDriver(const RooAbsReal &absReal, RooArgSet const &normSet,
51
52 void setData(RooAbsData const &data, std::string_view rangeName = "",
53 RooAbsCategory const *indexCatForSplitting = nullptr, bool skipZeroWeights = false,
54 bool takeGlobalObservablesFromData = true);
55 void setData(DataSpansMap const &dataSpans);
56
58 std::vector<double> getValues();
59 double getVal();
60 RooAbsReal &topNode() const;
61
62private:
63 ///////////////////////////
64 // Private member functions
65
66 double getValHeterogeneous();
67 std::chrono::microseconds simulateFit(std::chrono::microseconds h2dTime, std::chrono::microseconds d2hTime,
68 std::chrono::microseconds diffThreshold);
69 void markGPUNodes();
70 void assignToGPU(NodeInfo &info);
71 void computeCPUNode(const RooAbsArg *node, NodeInfo &info);
72 void setOperMode(RooAbsArg *arg, RooAbsArg::OperMode opMode);
74
75 ///////////////////////////
76 // Private member variables
77
78 Detail::BufferManager _bufferManager; // The object managing the different buffers for the intermediate results
79
82 double *_cudaMemDataset = nullptr;
83
84 // used for preserving static info about the computation graph
87
88 // the ordered computation graph
89 std::vector<NodeInfo> _nodes;
90
91 // used for preserving resources
92 std::stack<std::vector<double>> _vectorBuffers;
93 std::unique_ptr<RooFit::NormalizationIntegralUnfolder> _integralUnfolder;
94
95 // RAII structures to reset state of computation graph after driver destruction
96 std::stack<RooHelpers::ChangeOperModeRAII> _changeOperModeRAIIs;
97};
98
99} // end namespace Experimental
100} // end namespace ROOT
101
102#endif
A NormalizationIntegralUnfolder takes the top node of a computation graph and a normalization set for...
std::map< RooFit::Detail::DataKey, RooSpan< const double > > DataSpansMap
const RooFit::BatchModeOption _batchMode
void setOperMode(RooAbsArg *arg, RooAbsArg::OperMode opMode)
Temporarily change the operation mode of a RooAbsArg until the RooFitDriver gets deleted.
RooFit::Detail::DataMap _dataMapCPU
double getValHeterogeneous()
Returns the value of the top node in the computation graph.
double getVal()
Returns the value of the top node in the computation graph.
RooFit::Detail::DataMap _dataMapCUDA
std::unique_ptr< RooFit::NormalizationIntegralUnfolder > _integralUnfolder
std::vector< NodeInfo > _nodes
std::vector< double > getValues()
void assignToGPU(NodeInfo &info)
Assign a node to be computed in the GPU.
void computeCPUNode(const RooAbsArg *node, NodeInfo &info)
Detail::BufferManager _bufferManager
std::stack< std::vector< double > > _vectorBuffers
void markGPUNodes()
Decides which nodes are assigned to the gpu in a cuda fit.
std::stack< RooHelpers::ChangeOperModeRAII > _changeOperModeRAIIs
void setData(RooAbsData const &data, std::string_view rangeName="", RooAbsCategory const *indexCatForSplitting=nullptr, bool skipZeroWeights=false, bool takeGlobalObservablesFromData=true)
std::chrono::microseconds simulateFit(std::chrono::microseconds h2dTime, std::chrono::microseconds d2hTime, std::chrono::microseconds diffThreshold)
This methods simulates the computation of the whole graph and the time it takes and decides what to c...
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition RooAbsArg.h:69
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:82
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition RooAbsReal.h:64
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:35
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition Common.h:18
BatchModeOption
For setting the batch mode flag with the BatchMode() command argument to RooAbsPdf::fitTo();.
A struct used by the RooFitDriver to store information on the RooAbsArgs in the computation graph.