Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RunContext.h
Go to the documentation of this file.
1// Author: Stephan Hageboeck, CERN Jul 2020
2
3/*****************************************************************************
4 * RooFit
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2020, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17#ifndef ROOFIT_ROOFITCORE_RUNCONTEXT_H
18#define ROOFIT_ROOFITCORE_RUNCONTEXT_H
19
20#include "RooSpan.h"
22
23#include <map>
24#include <vector>
25
26class RooArgSet;
27class RooAbsArg;
28class RooArgProxy;
29
30namespace RooBatchCompute {
31
32struct RunContext {
33 /// Create an empty RunContext that doesn't have access to any computation results.
35 /// Deleted because copying the owned memory is expensive.
36 /// If needed, it can be implemented, though.
37 /// \warning Remember to relocate all spans in `spans` to new location
38 /// in `ownedMemory` after data have been copied!
39 RunContext(const RunContext&) = delete;
40 /// Move a RunContext. All spans pointing to data retrieved from the original remain valid.
41 RunContext(RunContext&&) = default;
43 RooSpan<const double> getBatch(const RooAbsArg* owner) const;
44 /// Retrieve a batch of data corresponding to the element passed as `owner`.
45 RooSpan<const double> operator[](const RooAbsArg* owner) const { return getBatch(owner); }
47 RooSpan<double> makeBatch(const RooAbsArg* owner, std::size_t size);
48
49 /// Clear all computation results without freeing memory.
50 void clear();
51
52 /// Once an object has computed its value(s), the span pointing to the results is registered here.
53 std::map<RooFit::Detail::DataKey, RooSpan<const double>> spans;
54 std::map<RooFit::Detail::DataKey, const double*> spansCuda;
55
56 /// Memory owned by this struct. It is associated to nodes in the computation graph using their pointers.
57 std::map<RooFit::Detail::DataKey, std::vector<double>> ownedMemory;
58 std::map<RooFit::Detail::DataKey, double*> ownedMemoryCuda;
59
60 const char* rangeName{nullptr}; ///< If evaluation should only occur in a range, the range name can be passed here.
61 std::vector<double> logProbabilities; ///< Possibility to register log probabilities.
62};
63
64}
65
66#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition RooAbsArg.h:69
RooArgProxy is the abstract interface for RooAbsArg proxy classes.
Definition RooArgProxy.h:24
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:35
A simple container to hold a batch of data values.
Definition RooSpan.h:34
Namespace for dispatching RooFit computations to various backends.
This struct enables passing computation data around between elements of a computation graph.
Definition RunContext.h:32
const char * rangeName
If evaluation should only occur in a range, the range name can be passed here.
Definition RunContext.h:60
std::vector< double > logProbabilities
Possibility to register log probabilities.
Definition RunContext.h:61
RooSpan< double > makeBatch(const RooAbsArg *owner, std::size_t size)
Create a writable batch.
void clear()
Clear all computation results without freeing memory.
RunContext(RunContext &&)=default
Move a RunContext. All spans pointing to data retrieved from the original remain valid.
RunContext(const RunContext &)=delete
Deleted because copying the owned memory is expensive.
std::map< RooFit::Detail::DataKey, std::vector< double > > ownedMemory
Memory owned by this struct. It is associated to nodes in the computation graph using their pointers.
Definition RunContext.h:57
std::map< RooFit::Detail::DataKey, double * > ownedMemoryCuda
Definition RunContext.h:58
RooSpan< const double > getBatch(const RooArgProxy &proxy) const
std::map< RooFit::Detail::DataKey, const double * > spansCuda
Definition RunContext.h:54
RooSpan< const double > operator[](const RooAbsArg *owner) const
Retrieve a batch of data corresponding to the element passed as owner.
Definition RunContext.h:45
RunContext()
Create an empty RunContext that doesn't have access to any computation results.
Definition RunContext.h:34
std::map< RooFit::Detail::DataKey, RooSpan< const double > > spans
Once an object has computed its value(s), the span pointing to the results is registered here.
Definition RunContext.h:53
RooSpan< double > getWritableBatch(const RooAbsArg *owner)
Check if there is a writable span of data corresponding to the object passed as owner.