NVBIO
|
Implements a WorkQueue using persistent warps to fetch more work at a warp's granularity. with dynamic work assignment. Each work-unit is assigned to a single thread, which runs until completion of all its continuations. Useful if the number of continuations is fairly random. Potentially destroys intra-CTA memory coherence. Very low continuation overhead.
The user of this class have to specify a WorkStream class responsible for feeding work to the queue in the shape of a subclass WorkStream::WorkUnit. The latter is responsible for specifying the data and execution of each unit. WorkStream has to implement two methods:
uint32 size() const void get(const uint32 i, WorkUnit* unit, const uint2 queue_slot)
When the method WorkQueue::consume( stream ) is called, the queue will launch a kernel to consume all WorkUnit's in the stream. WorkUnit has to implement a single method:
bool WorkUnit::run(const WorkStream& context)
which should run the associated work and indicate whether the unit has finished execution, or whether it has produced a continuation (stored in the WorkUnit itself), that has to be run further. The WorkQueue will automatically queue the continuation for later execution.
Optionally, the class can also be passed a WorkMover which is responsible for moving additional data attached to any WorkUnit. This must implement a method:
void move( const WorkStream& stream, const uint2 src_slot, WorkUnit* src_unit, const uint2 dst_slot, WorkUnit* dst_unit) const;
Definition at line 123 of file work_queue_persistent.h.
#include <work_queue_persistent.h>
Public Types | |
typedef WorkUnitT | WorkUnit |
Public Methods | |
WorkQueue () | |
void | set_capacity (const uint32 capacity) |
void | set_min_utilization (const float min_utilization) |
template<typename WorkStream > | |
void | consume (const WorkStream stream, WorkQueueStats *stats=NULL) |
template<typename WorkStream , typename WorkMover > | |
void | consume (const WorkStream stream, const WorkMover mover, WorkQueueStats *stats=NULL) |