17 #ifndef AGX_GLOBALRESULT_H 18 #define AGX_GLOBALRESULT_H 21 # pragma warning(push) 22 # pragma warning( disable : 4290 ) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) 43 class EntityDataParameter;
87 bool commit(
Index sortIndex);
98 BufferSet *getBufferSet();
137 template <
typename T>
142 template <
typename T>
179 virtual void handleOverflow(
size_t overflowSize) = 0;
181 template <
typename T>
182 size_t calculateInitialCapacity(
const T *target);
184 size_t calculateIncreasedCapacity(
size_t currentCapacity,
size_t overflowSize);
186 void finalizeTransactions();
191 BufferSet *createNewSet(
size_t capacity);
192 BufferSet *reportFailedTransaction(
Transaction *transaction);
193 void reportFailedTransaction(
const IndexRange& transactionRange, BufferSet *startSet);
194 void reportCompletedTransaction(
Transaction *transaction);
224 BufferSet(
size_t index,
size_t capacity);
227 void init(
size_t index,
size_t capacity);
230 size_t getIndex()
const;
233 size_t getCapacity()
const;
239 void addFailedTransaction(
const IndexRange& transactionRange);
269 void prepare(
Task *task);
277 virtual void handleOverflow(
size_t overflowSize)
override;
281 void locateTargets(
Task *task);
286 template <
typename ParameterVectorT>
287 void locateTargets(
const ParameterVectorT& parameters);
293 bool m_targetInstanceBuffer;
304 void prepare(
Task *task);
307 bool isActive()
const;
310 virtual void handleOverflow(
size_t overflowSize)
override;
327 , m_bufferSet(bufferSet)
335 AGX_FORCE_INLINE GlobalResult::BufferSet *GlobalResult::Transaction::getBufferSet() {
return m_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);
351 agxAssert(sortIndex < m_target->m_sortedRanges.size());
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);
385 AGX_FORCE_INLINE GlobalResult::BufferSet *GlobalResult::getActiveSet() {
return m_activeSet; }
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());
415 # pragma warning(pop)
Representation of a path, a list of name components.
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API...
Vector< BufferSetRef > m_bufferSets
std::atomic< agx::Int32 > m_numTransactions
Data storage for a collection of entity instances of a specified EntityModel.
agx::UInt getNumOverflows() const
#define agxAssertN(expr, format,...)
BufferSet(size_t index, size_t capacity)
Transactions are used to reserve exclusive memory areas in which the threads can write their data...
#define AGX_DECLARE_POINTER_TYPES(type)
A representation of a generic task.
Arrays are fast accessors into the data, or a portion of it, held by a Buffer.
VectorPOD< IndexRange > m_sortedRanges
BufferSet * getActiveSet()
Base class providing referencing counted objects.
agxData::Buffer * m_resultOrderBuffer
void prepareResultSorting(size_t numJobs)
Vector containing 'raw' data.
GlobalResult is used by kernels to generate result data from different threads.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
VectorPOD< Transaction > m_transactions
Transaction allocateResult(size_t numElements)
Allocate a transaction.
std::atomic< agx::Int32 > m_head
std::atomic< agx::Int32 > m_numCompletedTransactions
Abstract representation of a data buffer.
Contains classes for low level data storage for AGX.
GlobalResult(UInt settings, const Path &bindPath)
std::atomic< size_t > m_capacity
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:
agx::Object is a refcounted object with a name.