33#error "RF_ARCH should always be defined"
59#error "It's unexpected that _QUOTEVAL_ is defined at this point!"
61#define _QUOTEVAL_(x) _QUOTE_(x)
64 std::transform(out.begin(), out.end(), out.begin(), [](
unsigned char c) { return std::tolower(c); });
81 static std::vector<double> buffer;
86 std::size_t nThreads =
ex.GetPoolSize();
88 std::size_t nEventsPerThread = nEvents / nThreads + (nEvents % nThreads > 0);
91 nThreads = nEvents / nEventsPerThread + (nEvents % nEventsPerThread > 0);
93 auto task = [&](std::size_t idx) ->
int {
97 Batches batches(
output, nEventsPerThread, vars, extraArgs, buffer.data());
101 if (idx == nThreads - 1) {
117 std::vector<std::size_t> indices(nThreads);
118 for (
unsigned int i = 1; i < nThreads; i++) {
121 ex.Map(task, indices);
125 Batches batches(
output, nEvents, vars, extraArgs, buffer.data());
141 long double sum = 0.0;
142 for (
size_t i = 0; i <
n; i++)
161 : _nEvents(nEvents), _nBatches(vars.
size()), _nExtraArgs(extraArgs.
size()), _output(
output)
163 _arrays.resize(vars.size());
164 for (
size_t i = 0; i < vars.size(); i++) {
167 std::stringstream ss;
168 ss <<
"The span number " << i <<
" passed to Batches::Batches() is empty!";
169 throw std::runtime_error(ss.str());
170 }
else if (span.
size() > 1)
171 _arrays[i].set(span.
data()[0], span.
data(),
true);
177 _extraArgs = extraArgs;
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
This class implements the interface to execute the same task multiple times, sequentially or in paral...
__roodevice__ std::size_t getNEvents() const
void advance(std::size_t nEvents)
Batches(RestrictArr output, std::size_t nEvents, const VarVector &vars, const ArgVector &extraArgs={}, double *buffer=nullptr)
void setNEvents(std::size_t n)
This class overrides some RooBatchComputeInterface functions, for the purpose of providing a CPU spec...
std::string architectureName() const override
void compute(cudaStream_t *, Computer computer, RestrictArr output, size_t nEvents, const VarVector &vars, const ArgVector &extraArgs) override
Compute multiple values using optimized functions.
double sumReduce(cudaStream_t *, InputArr input, size_t n) override
Return the sum of an input array.
Architecture architecture() const override
const std::vector< void(*)(BatchesHandle)> _computeFunctions
The interface which should be implemented to provide optimised computation functions for implementati...
A simple container to hold a batch of data values.
constexpr std::span< T >::pointer data() const
constexpr std::span< T >::size_type size() const noexcept
constexpr bool empty() const noexcept
void(off) SmallVectorTemplateBase< T
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
static RooBatchComputeClass computeObj
Static object to trigger the constructor which overwrites the dispatch pointer.
std::vector< void(*)(BatchesHandle)> getFunctions()
Returns a std::vector of pointers to the compute functions in this file.
Namespace for dispatching RooFit computations to various backends.
std::vector< RooSpan< const double > > VarVector
R__EXTERN RooBatchComputeInterface * dispatchCPU
This dispatch pointer points to an implementation of the compute library, provided one has been loade...
constexpr std::size_t bufferSize
const double *__restrict InputArr
std::vector< double > ArgVector
double *__restrict RestrictArr