gem5  v22.1.0.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
gem5::FetchUnit::FetchBufDesc Class Reference

fetch buffer descriptor. More...

Public Member Functions

 FetchBufDesc ()
 
 ~FetchBufDesc ()
 
void allocateBuf (int fetch_depth, int cache_line_size, Wavefront *wf)
 allocate the fetch buffer space, and set the fetch depth (number of lines that may be buffered), fetch size (cache line size), and parent WF for this fetch buffer. More...
 
int bufferedAndReservedLines () const
 
int bufferedLines () const
 
int bufferedBytes () const
 
int reservedLines () const
 
bool hasFreeSpace () const
 
void flushBuf ()
 
Addr nextFetchAddr ()
 
void reserveBuf (Addr vaddr)
 reserve an entry in the fetch buffer for PC = vaddr, More...
 
uint8_t * reservedBuf (Addr vaddr) const
 return a pointer to the raw fetch buffer data. More...
 
bool isReserved (Addr vaddr) const
 returns true if there is an entry reserved for this address, and false otherwise More...
 
void fetchDone (Addr vaddr)
 
bool hasFetchDataToProcess () const
 checks if the buffer contains valid data. More...
 
void decodeInsts ()
 each time the fetch stage is ticked, we check if there are any data in the fetch buffer that may be decoded and sent to the IB. More...
 
void checkWaveReleaseBuf ()
 checks if the wavefront can release any of its fetch buffer entries. More...
 
void decoder (TheGpuISA::Decoder *dec)
 
bool pcBuffered (Addr pc) const
 
int fetchBytesRemaining () const
 calculates the number of fetched bytes that have yet to be decoded. More...
 

Private Member Functions

void decodeSplitInst ()
 
bool splitDecode () const
 check if the next instruction to be processed out of the fetch buffer is split across the end/beginning of the fetch buffer. More...
 

Private Attributes

std::map< Addr, uint8_t * > bufferedPCs
 the set of PCs (fetch addresses) that are currently buffered. More...
 
std::map< Addr, uint8_t * > reservedPCs
 
std::deque< uint8_t * > freeList
 represents the fetch buffer free list. More...
 
uint8_t * bufStart
 raw instruction buffer. More...
 
uint8_t * bufEnd
 
uint8_t * readPtr
 pointer that points to the next chunk of inst data to be decoded. More...
 
int fetchDepth
 
int maxIbSize
 
int maxFbSize
 
int cacheLineSize
 
int cacheLineBits
 
bool restartFromBranch
 
Wavefrontwavefront
 
TheGpuISA::Decoder * _decoder
 

Detailed Description

fetch buffer descriptor.

holds buffered instruction data in the fetch unit.

Definition at line 74 of file fetch_unit.hh.

Constructor & Destructor Documentation

◆ FetchBufDesc()

gem5::FetchUnit::FetchBufDesc::FetchBufDesc ( )
inline

Definition at line 77 of file fetch_unit.hh.

◆ ~FetchBufDesc()

gem5::FetchUnit::FetchBufDesc::~FetchBufDesc ( )
inline

Definition at line 84 of file fetch_unit.hh.

References bufStart.

Member Function Documentation

◆ allocateBuf()

void gem5::FetchUnit::FetchBufDesc::allocateBuf ( int  fetch_depth,
int  cache_line_size,
Wavefront wf 
)

allocate the fetch buffer space, and set the fetch depth (number of lines that may be buffered), fetch size (cache line size), and parent WF for this fetch buffer.

FetchBufDesc.

Definition at line 346 of file fetch_unit.cc.

References bufEnd, bufStart, cacheLineBits, cacheLineSize, fetchDepth, gem5::floorLog2(), freeList, gem5::ArmISA::i, gem5::isPowerOf2(), maxFbSize, maxIbSize, gem5::Wavefront::maxIbSize, panic_if, readPtr, and wavefront.

◆ bufferedAndReservedLines()

int gem5::FetchUnit::FetchBufDesc::bufferedAndReservedLines ( ) const
inline

Definition at line 97 of file fetch_unit.hh.

References bufferedLines(), and reservedLines().

◆ bufferedBytes()

int gem5::FetchUnit::FetchBufDesc::bufferedBytes ( ) const
inline

Definition at line 103 of file fetch_unit.hh.

References bufferedLines(), and cacheLineSize.

◆ bufferedLines()

int gem5::FetchUnit::FetchBufDesc::bufferedLines ( ) const
inline

Definition at line 102 of file fetch_unit.hh.

References bufferedPCs.

Referenced by bufferedAndReservedLines(), and bufferedBytes().

◆ checkWaveReleaseBuf()

void gem5::FetchUnit::FetchBufDesc::checkWaveReleaseBuf ( )

checks if the wavefront can release any of its fetch buffer entries.

this will occur when the WF's PC goes beyond any of the currently buffered cache lines.

we're using a std::map so the addresses are sorted. if this PC is not the oldest one in the map, we must be fetching from a newer block, and we can release the oldest PC's fetch buffer entry back to the free list.

Definition at line 503 of file fetch_unit.cc.

References DPRINTF, and gem5::roundDown().

◆ decodeInsts()

void gem5::FetchUnit::FetchBufDesc::decodeInsts ( )

each time the fetch stage is ticked, we check if there are any data in the fetch buffer that may be decoded and sent to the IB.

because we are modeling the fetch buffer as a circular buffer, it is possible that an instruction can straddle the end/beginning of the fetch buffer, so decodeSplitInsts() handles that case.

Definition at line 560 of file fetch_unit.cc.

References gem5::GPUStaticInst::disassemble(), DPRINTF, and gem5::GPUStaticInst::instSize().

◆ decoder()

void gem5::FetchUnit::FetchBufDesc::decoder ( TheGpuISA::Decoder *  dec)
inline

Definition at line 168 of file fetch_unit.hh.

References _decoder.

◆ decodeSplitInst()

void gem5::FetchUnit::FetchBufDesc::decodeSplitInst ( )
private

◆ fetchBytesRemaining()

int gem5::FetchUnit::FetchBufDesc::fetchBytesRemaining ( ) const

calculates the number of fetched bytes that have yet to be decoded.

Definition at line 648 of file fetch_unit.cc.

◆ fetchDone()

void gem5::FetchUnit::FetchBufDesc::fetchDone ( Addr  vaddr)

this address should have an entry reserved in the fetch buffer already, however it should be invalid until the fetch completes.

Definition at line 472 of file fetch_unit.cc.

References DPRINTF, and gem5::MipsISA::vaddr.

◆ flushBuf()

void gem5::FetchUnit::FetchBufDesc::flushBuf ( )

free list may have some entries so we clear it here to avoid duplicates

Definition at line 370 of file fetch_unit.cc.

References DPRINTF, gem5::FetchUnit::fetchDepth, and gem5::ArmISA::i.

◆ hasFetchDataToProcess()

bool gem5::FetchUnit::FetchBufDesc::hasFetchDataToProcess ( ) const

checks if the buffer contains valid data.

this essentially tells fetch when there is data remaining that needs to be decoded into the WF's IB.

Definition at line 497 of file fetch_unit.cc.

◆ hasFreeSpace()

bool gem5::FetchUnit::FetchBufDesc::hasFreeSpace ( ) const
inline

Definition at line 105 of file fetch_unit.hh.

References freeList.

◆ isReserved()

bool gem5::FetchUnit::FetchBufDesc::isReserved ( Addr  vaddr) const
inline

returns true if there is an entry reserved for this address, and false otherwise

Definition at line 134 of file fetch_unit.hh.

References reservedPCs, and gem5::MipsISA::vaddr.

◆ nextFetchAddr()

Addr gem5::FetchUnit::FetchBufDesc::nextFetchAddr ( )

get the PC of the most recently fetched cache line, then return the address of the next line.

should not be trying to fetch a line that has already been fetched.

we do not have any buffered cache lines yet, so we assume this is the initial fetch, or the first fetch after a branch, and get the PC directly from the WF. in the case of a branch, we may not start at the beginning of a cache line, so we adjust the readPtr by the current PC's offset from the start of the line.

if we are here we have no buffered lines. in the case we flushed the buffer due to a branch, we may need to start fetching from some offset from the start of the fetch buffer, so we adjust for that here.

Definition at line 392 of file fetch_unit.cc.

References gem5::ruby::makeLineAddress().

◆ pcBuffered()

bool gem5::FetchUnit::FetchBufDesc::pcBuffered ( Addr  pc) const
inline

Definition at line 174 of file fetch_unit.hh.

References bufferedPCs, gem5::MipsISA::pc, and reservedPCs.

◆ reserveBuf()

void gem5::FetchUnit::FetchBufDesc::reserveBuf ( Addr  vaddr)

reserve an entry in the fetch buffer for PC = vaddr,

we reserve buffer space, by moving it out of the free list, however we do not mark the buffered line as valid until the fetch unit for this buffer has receieved the response from the memory system.

Definition at line 447 of file fetch_unit.cc.

References DPRINTF, gem5::FetchUnit::fetchDepth, and gem5::MipsISA::vaddr.

◆ reservedBuf()

uint8_t* gem5::FetchUnit::FetchBufDesc::reservedBuf ( Addr  vaddr) const
inline

return a pointer to the raw fetch buffer data.

this allows the fetch pkt to use this data directly to avoid unnecessary memcpy and malloc/new.

Definition at line 120 of file fetch_unit.hh.

References reservedPCs, and gem5::MipsISA::vaddr.

◆ reservedLines()

int gem5::FetchUnit::FetchBufDesc::reservedLines ( ) const
inline

Definition at line 104 of file fetch_unit.hh.

References reservedPCs.

Referenced by bufferedAndReservedLines().

◆ splitDecode()

bool gem5::FetchUnit::FetchBufDesc::splitDecode ( ) const
private

check if the next instruction to be processed out of the fetch buffer is split across the end/beginning of the fetch buffer.

if a read of a raw instruction would go beyond the end of the fetch buffer, then we must perform a split decode.

Definition at line 636 of file fetch_unit.cc.

Member Data Documentation

◆ _decoder

TheGpuISA::Decoder* gem5::FetchUnit::FetchBufDesc::_decoder
private

Definition at line 239 of file fetch_unit.hh.

Referenced by decoder().

◆ bufEnd

uint8_t* gem5::FetchUnit::FetchBufDesc::bufEnd
private

Definition at line 222 of file fetch_unit.hh.

Referenced by allocateBuf().

◆ bufferedPCs

std::map<Addr, uint8_t*> gem5::FetchUnit::FetchBufDesc::bufferedPCs
private

the set of PCs (fetch addresses) that are currently buffered.

bufferedPCs are valid, reservedPCs are waiting for their buffers to be filled with valid fetch data.

Definition at line 204 of file fetch_unit.hh.

Referenced by bufferedLines(), and pcBuffered().

◆ bufStart

uint8_t* gem5::FetchUnit::FetchBufDesc::bufStart
private

raw instruction buffer.

holds cache line data associated with the set of PCs (fetch addresses) that are buffered here.

Definition at line 221 of file fetch_unit.hh.

Referenced by allocateBuf(), and ~FetchBufDesc().

◆ cacheLineBits

int gem5::FetchUnit::FetchBufDesc::cacheLineBits
private

Definition at line 235 of file fetch_unit.hh.

Referenced by allocateBuf().

◆ cacheLineSize

int gem5::FetchUnit::FetchBufDesc::cacheLineSize
private

Definition at line 234 of file fetch_unit.hh.

Referenced by allocateBuf(), and bufferedBytes().

◆ fetchDepth

int gem5::FetchUnit::FetchBufDesc::fetchDepth
private

Definition at line 229 of file fetch_unit.hh.

Referenced by allocateBuf().

◆ freeList

std::deque<uint8_t*> gem5::FetchUnit::FetchBufDesc::freeList
private

represents the fetch buffer free list.

holds buffer space that is currently free. each pointer in this array must have enough space to hold a cache line. in reality we have one actual fetch buffer: 'bufStart', these pointers point to addresses within bufStart that are aligned to the cache line size.

Definition at line 215 of file fetch_unit.hh.

Referenced by allocateBuf(), and hasFreeSpace().

◆ maxFbSize

int gem5::FetchUnit::FetchBufDesc::maxFbSize
private

Definition at line 233 of file fetch_unit.hh.

Referenced by allocateBuf().

◆ maxIbSize

int gem5::FetchUnit::FetchBufDesc::maxIbSize
private

Definition at line 231 of file fetch_unit.hh.

Referenced by allocateBuf().

◆ readPtr

uint8_t* gem5::FetchUnit::FetchBufDesc::readPtr
private

pointer that points to the next chunk of inst data to be decoded.

Definition at line 227 of file fetch_unit.hh.

Referenced by allocateBuf().

◆ reservedPCs

std::map<Addr, uint8_t*> gem5::FetchUnit::FetchBufDesc::reservedPCs
private

Definition at line 205 of file fetch_unit.hh.

Referenced by isReserved(), pcBuffered(), reservedBuf(), and reservedLines().

◆ restartFromBranch

bool gem5::FetchUnit::FetchBufDesc::restartFromBranch
private

Definition at line 236 of file fetch_unit.hh.

◆ wavefront

Wavefront* gem5::FetchUnit::FetchBufDesc::wavefront
private

Definition at line 238 of file fetch_unit.hh.

Referenced by allocateBuf().


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

Generated on Wed Dec 21 2022 10:23:23 for gem5 by doxygen 1.9.1