OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
cub::GridQueue< OffsetT > Class Template Reference

GridQueue is a descriptor utility for dynamic queue management. More...

Detailed Description

template<typename OffsetT>
class cub::GridQueue< OffsetT >

GridQueue is a descriptor utility for dynamic queue management.

Overview
GridQueue descriptors provides abstractions for "filling" or "draining" globally-shared vectors.
A "filling" GridQueue works by atomically-adding to a zero-initialized counter, returning a unique offset for the calling thread to write its items. The GridQueue maintains the total "fill-size". The fill counter must be reset using GridQueue::ResetFill by the host or kernel instance prior to the kernel instance that will be filling.
Similarly, a "draining" GridQueue works by works by atomically-incrementing a zero-initialized counter, returning a unique offset for the calling thread to read its items. Threads can safely drain until the array's logical fill-size is exceeded. The drain counter must be reset using GridQueue::ResetDrain or GridQueue::FillAndResetDrain by the host or kernel instance prior to the kernel instance that will be filling. (For dynamic work distribution of existing data, the corresponding fill-size is simply the number of elements in the array.)
Iterative work management can be implemented simply with a pair of flip-flopping work buffers, each with an associated set of fill and drain GridQueue descriptors.
Template Parameters
OffsetTSigned integer type for global offsets

Definition at line 82 of file grid_queue.cuh.

Public Member Functions

__host__ __device__ __forceinline__ GridQueue ()
 Constructs an invalid GridQueue descriptor.
 
__host__ __device__ __forceinline__ GridQueue (void *d_storage)
 Constructs a GridQueue descriptor around the device storage allocation.
 
__host__ __device__ __forceinline__ cudaError_t FillAndResetDrain (OffsetT fill_size, cudaStream_t stream=0)
 This operation sets the fill-size and resets the drain counter, preparing the GridQueue for draining in the next kernel instance. To be called by the host or by a kernel prior to that which will be draining.
 
__host__ __device__ __forceinline__ cudaError_t ResetDrain (cudaStream_t stream=0)
 This operation resets the drain so that it may advance to meet the existing fill-size. To be called by the host or by a kernel prior to that which will be draining.
 
__host__ __device__ __forceinline__ cudaError_t ResetFill (cudaStream_t stream=0)
 This operation resets the fill counter. To be called by the host or by a kernel prior to that which will be filling.
 
__host__ __device__ __forceinline__ cudaError_t FillSize (OffsetT &fill_size, cudaStream_t stream=0)
 Returns the fill-size established by the parent or by the previous kernel.
 
__device__ __forceinline__ OffsetT Drain (OffsetT num_items)
 Drain num_items from the queue. Returns offset from which to read items. To be called from CUDA kernel.
 
__device__ __forceinline__ OffsetT Fill (OffsetT num_items)
 Fill num_items into the queue. Returns offset from which to write items. To be called from CUDA kernel.
 

Static Public Member Functions

__host__ __device__ static __forceinline__ size_t AllocationSize ()
 Returns the device allocation size in bytes needed to construct a GridQueue instance.
 

Private Types

enum  { FILL = 0 , DRAIN = 1 }
 Counter indices. More...
 

Private Attributes

OffsetTd_counters
 Pair of counters.
 

Member Enumeration Documentation

◆ anonymous enum

template<typename OffsetT >
anonymous enum
private

Counter indices.

Definition at line 87 of file grid_queue.cuh.

Constructor & Destructor Documentation

◆ GridQueue() [1/2]

template<typename OffsetT >
__host__ __device__ __forceinline__ cub::GridQueue< OffsetT >::GridQueue ( )
inline

Constructs an invalid GridQueue descriptor.

Definition at line 107 of file grid_queue.cuh.

◆ GridQueue() [2/2]

template<typename OffsetT >
__host__ __device__ __forceinline__ cub::GridQueue< OffsetT >::GridQueue ( void *  d_storage)
inline

Constructs a GridQueue descriptor around the device storage allocation.

Parameters
d_storageDevice allocation to back the GridQueue. Must be at least as big as AllocationSize().

Definition at line 114 of file grid_queue.cuh.

Member Function Documentation

◆ AllocationSize()

template<typename OffsetT >
__host__ __device__ static __forceinline__ size_t cub::GridQueue< OffsetT >::AllocationSize ( )
inlinestatic

Returns the device allocation size in bytes needed to construct a GridQueue instance.

Definition at line 100 of file grid_queue.cuh.

◆ Drain()

template<typename OffsetT >
__device__ __forceinline__ OffsetT cub::GridQueue< OffsetT >::Drain ( OffsetT  num_items)
inline

Drain num_items from the queue. Returns offset from which to read items. To be called from CUDA kernel.

Definition at line 182 of file grid_queue.cuh.

◆ Fill()

template<typename OffsetT >
__device__ __forceinline__ OffsetT cub::GridQueue< OffsetT >::Fill ( OffsetT  num_items)
inline

Fill num_items into the queue. Returns offset from which to write items. To be called from CUDA kernel.

Definition at line 189 of file grid_queue.cuh.

◆ FillAndResetDrain()

template<typename OffsetT >
__host__ __device__ __forceinline__ cudaError_t cub::GridQueue< OffsetT >::FillAndResetDrain ( OffsetT  fill_size,
cudaStream_t  stream = 0 
)
inline

This operation sets the fill-size and resets the drain counter, preparing the GridQueue for draining in the next kernel instance. To be called by the host or by a kernel prior to that which will be draining.

Definition at line 122 of file grid_queue.cuh.

◆ FillSize()

template<typename OffsetT >
__host__ __device__ __forceinline__ cudaError_t cub::GridQueue< OffsetT >::FillSize ( OffsetT fill_size,
cudaStream_t  stream = 0 
)
inline

Returns the fill-size established by the parent or by the previous kernel.

Definition at line 167 of file grid_queue.cuh.

◆ ResetDrain()

template<typename OffsetT >
__host__ __device__ __forceinline__ cudaError_t cub::GridQueue< OffsetT >::ResetDrain ( cudaStream_t  stream = 0)
inline

This operation resets the drain so that it may advance to meet the existing fill-size. To be called by the host or by a kernel prior to that which will be draining.

Definition at line 141 of file grid_queue.cuh.

◆ ResetFill()

template<typename OffsetT >
__host__ __device__ __forceinline__ cudaError_t cub::GridQueue< OffsetT >::ResetFill ( cudaStream_t  stream = 0)
inline

This operation resets the fill counter. To be called by the host or by a kernel prior to that which will be filling.

Definition at line 154 of file grid_queue.cuh.

Field Documentation

◆ d_counters

template<typename OffsetT >
OffsetT* cub::GridQueue< OffsetT >::d_counters
private

Pair of counters.

Definition at line 94 of file grid_queue.cuh.


The documentation for this class was generated from the following file: