gem5
v20.1.0.0
|
Circular queue. More...
#include <circular_queue.hh>
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 > | |
T | item |
Dummy Item. More... | |
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 '_'
T | Type of the elements in the queue |
Definition at line 86 of file circular_queue.hh.
|
protected |
Definition at line 89 of file circular_queue.hh.
|
inlineprotected |
Definition at line 134 of file circular_queue.hh.
Referenced by CircularQueue< T >::iterator::operator--(), and CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::pop_back().
|
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().
|
inlineprotected |
Definition at line 129 of file circular_queue.hh.
Referenced by CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::advance_tail(), and CircularQueue< T >::iterator::operator++().
|
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().
|
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.
|
inlinestaticprotected |
General modular addition.
Definition at line 107 of file circular_queue.hh.
Referenced by CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::end(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::getIterator(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::increase(), LSQUnit< Impl >::insertStore(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::moduloAdd(), and CircularQueue< T >::iterator::operator+=().
|
inline |
Definition at line 643 of file circular_queue.hh.
|
inlinestaticprotected |
General modular subtraction.
Definition at line 114 of file circular_queue.hh.
Referenced by CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::moduloSub(), and CircularQueue< T >::iterator::operator-=().
|
inline |
Definition at line 648 of file circular_queue.hh.
|
inlinestaticprotected |
Definition at line 121 of file circular_queue.hh.
Referenced by CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::moduloSub(), and CircularQueue< T >::iterator::operator-().
|
protected |
Definition at line 92 of file circular_queue.hh.
Referenced by CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::capacity(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::decrease(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::full(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::getIterator(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::increase(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::moduloAdd(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::moduloSub(), and CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::size().
|
protected |
Definition at line 95 of file circular_queue.hh.
Referenced by CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::advance_tail(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::begin(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::empty(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::flush(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::full(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::getIterator(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::isValidIdx(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::pop_back(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::pop_front(), and CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::size().
|
protected |
Definition at line 93 of file circular_queue.hh.
Referenced by CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::advance_tail(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::begin(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::flush(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::front(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::full(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::getIterator(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::head(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::isValidIdx(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::pop_back(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::pop_front(), and CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::size().
|
protected |
Counter for how many times the tail wraps around.
Some parts of the code rely on getting the past the end iterator, and expect to use it after inserting on the tail. To support this without ambiguity, we need the round number to guarantee that it did not become a before-the-beginning iterator.
Definition at line 103 of file circular_queue.hh.
Referenced by CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::advance_tail(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::begin(), CircularQueue< T >::iterator::decrementable(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::end(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::flush(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::getIterator(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::isValidIdx(), and CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::pop_back().
|
protected |
Definition at line 94 of file circular_queue.hh.
Referenced by CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::advance_tail(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::back(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::begin(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::end(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::flush(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::full(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::getIterator(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::isValidIdx(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::pop_back(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::push_back(), CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::size(), and CircularQueue< Prefetcher::STeMS::RegionMissOrderBufferEntry >::tail().