gem5  v20.1.0.0
Classes | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
CircularQueue< T > Class Template Reference

Circular queue. More...

#include <circular_queue.hh>

Inheritance diagram for CircularQueue< T >:
std::vector< T > CircleBuf< T >

Classes

struct  iterator
 Iterator to the circular queue. More...
 

Public Member Functions

 CircularQueue (uint32_t size=0)
 
void flush ()
 Remove all the elements in the queue. More...
 
bool isValidIdx (size_t idx) const
 Test if the index is in the range of valid elements. More...
 
bool isValidIdx (size_t idx, uint32_t round) const
 Test if the index is in the range of valid elements. More...
 
reference front ()
 
reference back ()
 
uint32_t head () const
 
uint32_t tail () const
 
size_t capacity () const
 
uint32_t size () const
 
uint32_t moduloAdd (uint32_t s1, uint32_t s2) const
 
uint32_t moduloSub (uint32_t s1, uint32_t s2) const
 
void pop_front (size_t num_elem=1)
 Circularly increase the head pointer. More...
 
void pop_back ()
 Circularly decrease the tail pointer. More...
 
void push_back (typename Base::value_type val)
 Pushes an element at the end of the queue. More...
 
void advance_tail ()
 Increases the tail by one. More...
 
void advance_tail (uint32_t len)
 Increases the tail by a specified number of steps. More...
 
bool empty () const
 Is the queue empty? More...
 
bool full () const
 Is the queue full? A queue is full if the head is the 0^{th} element and the tail is the (size-1)^{th} element, or if the head is the n^{th} element and the tail the (n-1)^{th} element. More...
 
iterator begin ()
 Iterators. More...
 
iterator begin () const
 
iterator end ()
 
iterator end () const
 
iterator getIterator (size_t idx)
 Return an iterator to an index in the vector. More...
 

Protected Types

using Base = std::vector< T >
 

Protected Member Functions

void increase (uint32_t &v, size_t delta=1)
 
void decrease (uint32_t &v)
 

Static Protected Member Functions

static uint32_t moduloAdd (uint32_t op1, uint32_t op2, uint32_t size)
 General modular addition. More...
 
static uint32_t moduloSub (uint32_t op1, uint32_t op2, uint32_t size)
 General modular subtraction. More...
 
static int32_t sub (uint32_t op1, uint32_t op2, uint32_t size)
 

Protected Attributes

const uint32_t _capacity
 
uint32_t _head
 
uint32_t _tail
 
uint32_t _empty
 
uint32_t _round
 Counter for how many times the tail wraps around. More...
 

Additional Inherited Members

- Private Attributes inherited from std::vector< T >
item
 Dummy Item. More...
 

Detailed Description

template<typename T>
class CircularQueue< T >

Circular queue.

Circular queue implemented on top of a standard vector. Instead of using a sentinel entry, we use a boolean to distinguish the case in which the queue is full or empty. Thus, a circular queue is represented by the 5-tuple (Capacity, IsEmpty?, Head, Tail, Round) Where:

The Round number is only relevant for checking validity of indices, therefore it will be omitted or shown as '_'

Template Parameters
TType of the elements in the queue

Definition at line 86 of file circular_queue.hh.

Member Typedef Documentation

◆ Base

template<typename T >
using CircularQueue< T >::Base = std::vector<T>
protected

Definition at line 89 of file circular_queue.hh.

Member Function Documentation

◆ decrease()

template<typename T >
void CircularQueue< T >::decrease ( uint32_t &  v)
inlineprotected

◆ getIterator()

template<typename T >
iterator CircularQueue< T >::getIterator ( size_t  idx)
inline

Return an iterator to an index in the vector.

This poses the problem of round determination. By convention, the round is picked so that isValidIndex(idx, round) is true. If that is not possible, then the round value is _round, unless _tail is at the end of the storage, in which case the PTE wraps up and becomes _round + 1

Definition at line 812 of file circular_queue.hh.

Referenced by LSQUnit< Impl >::insertLoad(), and Prefetcher::PIF::notifyRetiredInst().

◆ increase()

template<typename T >
void CircularQueue< T >::increase ( uint32_t &  v,
size_t  delta = 1 
)
inlineprotected

◆ isValidIdx() [1/2]

template<typename T >
bool CircularQueue< T >::isValidIdx ( size_t  idx) const
inline

Test if the index is in the range of valid elements.

Definition at line 547 of file circular_queue.hh.

Referenced by CircularQueue< T >::iterator::dereferenceable(), and CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::getIterator().

◆ isValidIdx() [2/2]

template<typename T >
bool CircularQueue< T >::isValidIdx ( size_t  idx,
uint32_t  round 
) const
inline

Test if the index is in the range of valid elements.

The round counter is used to disambiguate aliasing.

Definition at line 571 of file circular_queue.hh.

◆ moduloAdd() [1/2]

template<typename T >
static uint32_t CircularQueue< T >::moduloAdd ( uint32_t  op1,
uint32_t  op2,
uint32_t  size 
)
inlinestaticprotected

◆ moduloAdd() [2/2]

template<typename T >
uint32_t CircularQueue< T >::moduloAdd ( uint32_t  s1,
uint32_t  s2 
) const
inline

Definition at line 643 of file circular_queue.hh.

◆ moduloSub() [1/2]

template<typename T >
static uint32_t CircularQueue< T >::moduloSub ( uint32_t  op1,
uint32_t  op2,
uint32_t  size 
)
inlinestaticprotected

◆ moduloSub() [2/2]

template<typename T >
uint32_t CircularQueue< T >::moduloSub ( uint32_t  s1,
uint32_t  s2 
) const
inline

Definition at line 648 of file circular_queue.hh.

◆ sub()

template<typename T >
static int32_t CircularQueue< T >::sub ( uint32_t  op1,
uint32_t  op2,
uint32_t  size 
)
inlinestaticprotected

Member Data Documentation

◆ _capacity

template<typename T >
const uint32_t CircularQueue< T >::_capacity
protected

◆ _empty

template<typename T >
uint32_t CircularQueue< T >::_empty
protected

◆ _head

template<typename T >
uint32_t CircularQueue< T >::_head
protected

◆ _round

template<typename T >
uint32_t CircularQueue< T >::_round
protected

◆ _tail

template<typename T >
uint32_t CircularQueue< T >::_tail
protected

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

Generated on Wed Sep 30 2020 14:02:22 for gem5 by doxygen 1.8.17