Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Experimental::RooFitDriver Class Reference

Definition at line 39 of file RooFitDriver.h.

Public Types

using DataSpansMap = std::map< RooFit::Detail::DataKey, RooSpan< const double > >
 

Public Member Functions

 RooFitDriver (const RooAbsReal &absReal, RooArgSet const &normSet, RooFit::BatchModeOption batchMode=RooFit::BatchModeOption::Cpu)
 Construct a new RooFitDriver.
 
 ~RooFitDriver ()
 
double getVal ()
 Returns the value of the top node in the computation graph.
 
std::vector< doublegetValues ()
 
void setData (DataSpansMap const &dataSpans)
 
void setData (RooAbsData const &data, std::string_view rangeName="", RooAbsCategory const *indexCatForSplitting=nullptr, bool skipZeroWeights=false, bool takeGlobalObservablesFromData=true)
 
RooAbsRealtopNode () const
 

Private Member Functions

void assignToGPU (NodeInfo &info)
 Assign a node to be computed in the GPU.
 
void computeCPUNode (const RooAbsArg *node, NodeInfo &info)
 
void determineOutputSizes ()
 
double getValHeterogeneous ()
 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.
 
void setOperMode (RooAbsArg *arg, RooAbsArg::OperMode opMode)
 Temporarily change the operation mode of a RooAbsArg until the RooFitDriver gets deleted.
 
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 compute in gpu.
 

Private Attributes

const RooFit::BatchModeOption _batchMode = RooFit::BatchModeOption::Off
 
Detail::BufferManager _bufferManager
 
std::stack< RooHelpers::ChangeOperModeRAII_changeOperModeRAIIs
 
double_cudaMemDataset = nullptr
 
RooFit::Detail::DataMap _dataMapCPU
 
RooFit::Detail::DataMap _dataMapCUDA
 
int _getValInvocations = 0
 
std::unique_ptr< RooFit::NormalizationIntegralUnfolder_integralUnfolder
 
std::vector< NodeInfo_nodes
 
std::stack< std::vector< double > > _vectorBuffers
 

#include </home/sftnight/build/workspace/root-makedoc-v626/rootspi/rdoc/src/v6-26-00-patches/roofit/roofitcore/res/RooFitDriver.h>

Member Typedef Documentation

◆ DataSpansMap

Constructor & Destructor Documentation

◆ RooFitDriver()

RooFitDriver::RooFitDriver ( const RooAbsReal absReal,
RooArgSet const &  normSet,
RooFit::BatchModeOption  batchMode = RooFit::BatchModeOption::Cpu 
)

Construct a new RooFitDriver.

The constructor analyzes and saves metadata about the graph, useful for the evaluation of it that will be done later. In case the CUDA mode is selected, there's also some CUDA-related initialization.

Parameters
[in]absRealThe RooAbsReal object that sits on top of the computation graph that we want to evaluate.
[in]normSetNormalization set for the evaluation
[in]batchModeThe computation mode, accepted values are RooBatchCompute::Cpu and RooBatchCompute::Cuda.

Definition at line 111 of file RooFitDriver.cxx.

◆ ~RooFitDriver()

RooFitDriver::~RooFitDriver ( )

Definition at line 266 of file RooFitDriver.cxx.

Member Function Documentation

◆ assignToGPU()

void RooFitDriver::assignToGPU ( NodeInfo info)
private

Assign a node to be computed in the GPU.

Scan it's clients and also assign them in case they only depend on gpu nodes.

Definition at line 457 of file RooFitDriver.cxx.

◆ computeCPUNode()

void RooFitDriver::computeCPUNode ( const RooAbsArg node,
NodeInfo info 
)
private

Definition at line 298 of file RooFitDriver.cxx.

◆ determineOutputSizes()

void RooFitDriver::determineOutputSizes ( )
private

Definition at line 712 of file RooFitDriver.cxx.

◆ getVal()

double RooFitDriver::getVal ( )

Returns the value of the top node in the computation graph.

Definition at line 338 of file RooFitDriver.cxx.

◆ getValHeterogeneous()

double RooFitDriver::getValHeterogeneous ( )
private

Returns the value of the top node in the computation graph.

Definition at line 376 of file RooFitDriver.cxx.

◆ getValues()

std::vector< double > RooFitDriver::getValues ( )

Definition at line 277 of file RooFitDriver.cxx.

◆ markGPUNodes()

void RooFitDriver::markGPUNodes ( )
private

Decides which nodes are assigned to the gpu in a cuda fit.

In the 1st iteration, everything is computed in cpu for measuring the cpu time. In the 2nd iteration, everything is computed in gpu (if possible) to measure the gpu time. In the 3rd iteration, simulate the computation of the graph by calling simulateFit with every distinct threshold found as timeDiff within the nodes of the graph and select the best configuration. In the end, mark the nodes and handle the details accordingly.

Definition at line 619 of file RooFitDriver.cxx.

◆ setData() [1/2]

void RooFitDriver::setData ( DataSpansMap const &  dataSpans)

Definition at line 206 of file RooFitDriver.cxx.

◆ setData() [2/2]

void RooFitDriver::setData ( RooAbsData const &  data,
std::string_view  rangeName = "",
RooAbsCategory const *  indexCatForSplitting = nullptr,
bool  skipZeroWeights = false,
bool  takeGlobalObservablesFromData = true 
)

Definition at line 186 of file RooFitDriver.cxx.

◆ setOperMode()

void RooFitDriver::setOperMode ( RooAbsArg arg,
RooAbsArg::OperMode  opMode 
)
private

Temporarily change the operation mode of a RooAbsArg until the RooFitDriver gets deleted.

Definition at line 725 of file RooFitDriver.cxx.

◆ simulateFit()

std::chrono::microseconds RooFitDriver::simulateFit ( std::chrono::microseconds  h2dTime,
std::chrono::microseconds  d2hTime,
std::chrono::microseconds  diffThreshold 
)
private

This methods simulates the computation of the whole graph and the time it takes and decides what to compute in gpu.

The decision is made on the basis of avoiding leaving either the gpu or the cpu idle at any time, if possible, and on assigning to each piece of hardware a computation that is significantly slower on the other part. The nodes may be assigned to the non-efficient side (cpu or gpu) to prevent idleness only if the absolute difference cpuTime-cudaTime does not exceed the diffThreshold.

Definition at line 497 of file RooFitDriver.cxx.

◆ topNode()

RooAbsReal & RooFitDriver::topNode ( ) const

Definition at line 732 of file RooFitDriver.cxx.

Member Data Documentation

◆ _batchMode

const RooFit::BatchModeOption ROOT::Experimental::RooFitDriver::_batchMode = RooFit::BatchModeOption::Off
private

Definition at line 80 of file RooFitDriver.h.

◆ _bufferManager

Detail::BufferManager ROOT::Experimental::RooFitDriver::_bufferManager
private

Definition at line 78 of file RooFitDriver.h.

◆ _changeOperModeRAIIs

std::stack<RooHelpers::ChangeOperModeRAII> ROOT::Experimental::RooFitDriver::_changeOperModeRAIIs
private

Definition at line 96 of file RooFitDriver.h.

◆ _cudaMemDataset

double* ROOT::Experimental::RooFitDriver::_cudaMemDataset = nullptr
private

Definition at line 82 of file RooFitDriver.h.

◆ _dataMapCPU

RooFit::Detail::DataMap ROOT::Experimental::RooFitDriver::_dataMapCPU
private

Definition at line 85 of file RooFitDriver.h.

◆ _dataMapCUDA

RooFit::Detail::DataMap ROOT::Experimental::RooFitDriver::_dataMapCUDA
private

Definition at line 86 of file RooFitDriver.h.

◆ _getValInvocations

int ROOT::Experimental::RooFitDriver::_getValInvocations = 0
private

Definition at line 81 of file RooFitDriver.h.

◆ _integralUnfolder

std::unique_ptr<RooFit::NormalizationIntegralUnfolder> ROOT::Experimental::RooFitDriver::_integralUnfolder
private

Definition at line 93 of file RooFitDriver.h.

◆ _nodes

std::vector<NodeInfo> ROOT::Experimental::RooFitDriver::_nodes
private

Definition at line 89 of file RooFitDriver.h.

◆ _vectorBuffers

std::stack<std::vector<double> > ROOT::Experimental::RooFitDriver::_vectorBuffers
private

Definition at line 92 of file RooFitDriver.h.

  • roofit/roofitcore/res/RooFitDriver.h
  • roofit/roofitcore/src/RooFitDriver.cxx