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;
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)
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)
typedef void(GLAPIENTRYP _GLUfuncptr)(void)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
This class implements the interface to execute the same task multiple times, sequentially or in paral...
unsigned GetPoolSize() const
Return the number of pooled workers.
void setNEvents(size_t n)
void advance(size_t nEvents)
std::vector< Batch > _arrays
std::vector< double > _extraArgs
__roodevice__ size_t getNEvents() const
Batches(RestrictArr output, size_t nEvents, const VarVector &vars, const ArgVector &extraArgs={}, double *buffer=nullptr)
Construct a Batches object.
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 >::index_type size() const noexcept
constexpr bool empty() const noexcept
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...
const double *__restrict InputArr
constexpr uint16_t bufferSize
std::vector< double > ArgVector
double *__restrict RestrictArr
static uint64_t sum(uint64_t i)
static void output(int code)