Logo ROOT  
Reference Guide
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 void setData(DataSpansMap const &dataSpans);
55
57 std::vector<double> getValues();
58 double getVal();
59 RooAbsReal &topNode() const;
60
61private:
62 ///////////////////////////
63 // Private member functions
64
65 double getValHeterogeneous();
66 std::chrono::microseconds simulateFit(std::chrono::microseconds h2dTime, std::chrono::microseconds d2hTime,
67 std::chrono::microseconds diffThreshold);
68 void markGPUNodes();
69 void assignToGPU(NodeInfo &info);
70 void computeCPUNode(const RooAbsArg *node, NodeInfo &info);
71 void setOperMode(RooAbsArg *arg, RooAbsArg::OperMode opMode);
73
74 ///////////////////////////
75 // Private member variables
76
77 Detail::BufferManager _bufferManager; // The object managing the different buffers for the intermediate results
78
81 double *_cudaMemDataset = nullptr;
82
83 // used for preserving static info about the computation graph
86
87 // the ordered computation graph
88 std::vector<NodeInfo> _nodes;
89
90 // used for preserving resources
91 std::stack<std::vector<double>> _vectorBuffers;
92 std::unique_ptr<RooFit::NormalizationIntegralUnfolder> _integralUnfolder;
93
94 // RAII structures to reset state of computation graph after driver destruction
95 std::stack<RooHelpers::ChangeOperModeRAII> _changeOperModeRAIIs;
96};
97
98} // end namespace Experimental
99} // end namespace ROOT
100
101#endif
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
A NormalizationIntegralUnfolder takes the top node of a computation graph and a normalization set for...
std::map< RooFit::Detail::DataKey, RooSpan< const double > > DataSpansMap
Definition: RooFitDriver.h:44
const RooFit::BatchModeOption _batchMode
Definition: RooFitDriver.h:79
void setOperMode(RooAbsArg *arg, RooAbsArg::OperMode opMode)
Temporarily change the operation mode of a RooAbsArg until the RooFitDriver gets deleted.
RooFitDriver(const RooAbsReal &absReal, RooArgSet const &normSet, RooFit::BatchModeOption batchMode=RooFit::BatchModeOption::Cpu)
Construct a new RooFitDriver.
RooFit::Detail::DataMap _dataMapCPU
Definition: RooFitDriver.h:84
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
Definition: RooFitDriver.h:85
std::unique_ptr< RooFit::NormalizationIntegralUnfolder > _integralUnfolder
Definition: RooFitDriver.h:92
std::vector< NodeInfo > _nodes
Definition: RooFitDriver.h:88
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
Definition: RooFitDriver.h:77
std::stack< std::vector< double > > _vectorBuffers
Definition: RooFitDriver.h:91
void markGPUNodes()
Decides which nodes are assigned to the gpu in a cuda fit.
std::stack< RooHelpers::ChangeOperModeRAII > _changeOperModeRAIIs
Definition: RooFitDriver.h:95
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...
void setData(RooAbsData const &data, std::string_view rangeName="", RooAbsCategory const *indexCatForSplitting=nullptr, bool skipZeroWeights=false)
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:71
A space to attach TBranches.
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:62
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:62
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:56
basic_string_view< char > string_view
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
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();.
Definition: RooGlobalFunc.h:70
A struct used by the RooFitDriver to store information on the RooAbsArgs in the computation graph.