17#ifndef AGX_GLOBALRESULT_H
18#define AGX_GLOBALRESULT_H
22# pragma warning( disable : 4290 )
43 class EntityDataParameter;
87 bool commit(
Index sortIndex);
98 BufferSet *getBufferSet();
112 BufferSet *m_bufferSet;
137 template <
typename T>
142 template <
typename T>
149 bool didOverflow()
const;
161 BufferSet *getActiveSet();
181 template <
typename T>
227 void init(
size_t index,
size_t capacity);
281 void locateTargets(
Task *task);
286 template <
typename ParameterVectorT>
287 void locateTargets(
const ParameterVectorT& parameters);
293 bool m_targetInstanceBuffer;
307 bool isActive()
const;
327 , m_bufferSet(bufferSet)
341 m_target->getMutex().lock();
342 auto currentActiveSet = m_target->getActiveSet();
343 m_target->getMutex().unlock();
345 if (m_bufferSet == currentActiveSet)
348 m_target->reportCompletedTransaction(
this);
352 m_target->m_sortedRanges[sortIndex] = m_range;
357 m_bufferSet = m_target->reportFailedTransaction(
this);
363 agxAssertN(!(m_target->m_settings & (
SORT|
ORDER)) || m_target->m_sortedRanges.empty(),
"%s: Must use extended commit method if SORT or ORDER is specified", m_target->getPath().c_str());
365 m_target->getMutex().lock();
366 BufferSet *currentActiveSet = m_target->getActiveSet();
367 m_target->getMutex().unlock();
369 if (m_bufferSet == currentActiveSet)
372 m_target->reportCompletedTransaction(
this);
378 m_bufferSet = m_target->reportFailedTransaction(
this);
396 template <
typename T>
399 return this->
commit(target, vector.
size(), vector.ptr(), sortIndex);
402 template <
typename T>
405 return this->
commit(target, vector.
size(), vector.ptr());
#define AGX_DECLARE_POINTER_TYPES(type)
Arrays are fast accessors into the data, or a portion of it, held by a Buffer.
Abstract representation of a data buffer.
Data storage for a collection of entity instances of a specified EntityModel.
virtual void handleOverflow(size_t overflowSize) override
GlobalResultBuffer(agxData::Buffer *target, UInt settings)
virtual void sortResult(const agxData::IndexArray &permutation) override
virtual ~GlobalResultBuffer()
GlobalResultStorage(agxData::EntityStorage *targetStorage, UInt settings)
virtual void handleOverflow(size_t overflowSize) override
virtual void sortResult(const agxData::IndexArray &permutation) override
virtual ~GlobalResultStorage()
Transactions are used to reserve exclusive memory areas in which the threads can write their data.
const IndexRange & range() const
GlobalResult * getTarget()
bool commit()
Same as above but without deterministic sorting.
BufferSet * getBufferSet()
GlobalResult is used by kernels to generate result data from different threads.
VectorPOD< OverflowBuffer > & getOverflows()
@ SORT
Build a permutation table for deterministic ordering of result data.
@ ORDER
Append to the existing data.
virtual void handleOverflow(size_t overflowSize)=0
std::atomic< agx::Int32 > m_numCompletedTransactions
size_t commit(const agxData::AbstractArray &target, size_t numElements, const void *localResult, Index sortIndex)
Convenience wrapper to perform a complete transaction, this consists of:
Transaction allocateResult(size_t numElements)
Allocate a transaction.
BufferSet * createNewSet(size_t capacity)
void commitRanges(const IndexRangeVector &ranges)
Commit partial result to final buffers.
size_t getCapacity() const
void finalizeTransactions()
void init(const IndexRange &range)
virtual void sortResult(const agxData::IndexArray &permutation)=0
BufferSet * getActiveSet()
agxData::Buffer * m_resultOrderBuffer
size_t calculateInitialCapacity(const T *target)
VectorPOD< Transaction > m_transactions
Vector< BufferSetRef > m_bufferSets
size_t calculateIncreasedCapacity(size_t currentCapacity, size_t overflowSize)
void addOverflow(const OverflowBuffer &buffer)
Report an overflown buffer.
std::atomic< size_t > m_capacity
void finalizeResultSorting(IndexRange range)
agx::UInt getNumOverflows() const
BufferSet(size_t index, size_t capacity)
GlobalResult(UInt settings, const Path &bindPath)
size_t commit(const agxData::AbstractArray &target, size_t numElements, const void *localResult)
std::atomic< agx::Int32 > m_numTransactions
void init(size_t index, size_t capacity)
Initialize a buffer set.
VectorPOD< IndexRange > m_sortedRanges
std::atomic< agx::Int32 > m_head
void reportCompletedTransaction(Transaction *transaction)
void reportFailedTransaction(const IndexRange &transactionRange, BufferSet *startSet)
IndexRangeVector & getFailedTransactions()
void prepareResultSorting(size_t numJobs)
void addFailedTransaction(const IndexRange &transactionRange)
Report a failed transaction.
BufferSet * reportFailedTransaction(Transaction *transaction)
agx::Object is a refcounted object with a name.
Representation of a path, a list of name components.
Base class providing referencing counted objects.
A representation of a generic task.
Vector containing 'raw' data.
#define agxAssertN(expr, format,...)
Contains classes for low level data storage for AGX.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
OverflowBuffer(agxData::Buffer *buffer_)