diff options
author | Korey Sewell <ksewell@umich.edu> | 2011-06-19 21:43:39 -0400 |
---|---|---|
committer | Korey Sewell <ksewell@umich.edu> | 2011-06-19 21:43:39 -0400 |
commit | b72bdcf4f896ba9bc8ddca1872e7f897965127ee (patch) | |
tree | f8657096bb05800a3cc3cd15b1bd1c631cd69249 /src | |
parent | 4d4c7d79d0847a004b4fed4dcfd8fd98fd164163 (diff) | |
download | gem5-b72bdcf4f896ba9bc8ddca1872e7f897965127ee.tar.xz |
inorder: fetchBuffer tracking
calculate blocks in use for the fetch buffer to figure out how many total blocks
are pending
Diffstat (limited to 'src')
-rw-r--r-- | src/cpu/inorder/resources/fetch_unit.cc | 50 | ||||
-rw-r--r-- | src/cpu/inorder/resources/fetch_unit.hh | 2 |
2 files changed, 41 insertions, 11 deletions
diff --git a/src/cpu/inorder/resources/fetch_unit.cc b/src/cpu/inorder/resources/fetch_unit.cc index 04b80fbc9..52997917d 100644 --- a/src/cpu/inorder/resources/fetch_unit.cc +++ b/src/cpu/inorder/resources/fetch_unit.cc @@ -175,9 +175,13 @@ FetchUnit::setupMemRequest(DynInstPtr inst, CacheReqPtr cache_req, { ThreadID tid = inst->readTid(); Addr aligned_addr = cacheBlockAlign(inst->getMemAddr()); - cache_req->memReq = + if (cache_req->memReq == NULL) { + cache_req->memReq = new Request(tid, aligned_addr, acc_size, flags, inst->instAddr(), cpu->readCpuId(), tid); + DPRINTF(InOrderCachePort, "[sn:%i] Created memReq @%x, ->%x\n", + inst->seqNum, &cache_req->memReq, cache_req->memReq); + } } std::list<FetchUnit::FetchBlock*>::iterator @@ -230,6 +234,23 @@ FetchUnit::markBlockUsed(std::list<FetchBlock*>::iterator block_it) } } +int +FetchUnit::blocksInUse() +{ + std::list<FetchBlock*>::iterator fetch_it = fetchBuffer.begin(); + std::list<FetchBlock*>::iterator end_it = fetchBuffer.end(); + + int cnt = 0; + while (fetch_it != end_it) { + if ((*fetch_it)->cnt > 0) + cnt++; + + fetch_it++; + } + + return cnt; +} + void FetchUnit::execute(int slot_num) { @@ -256,6 +277,8 @@ FetchUnit::execute(int slot_num) // Check to see if we've already got this request buffered // or pending to be buffered bool do_fetch = true; + int total_pending = pendingFetch.size() + blocksInUse(); + std::list<FetchBlock*>::iterator pending_it; pending_it = findBlock(pendingFetch, asid, block_addr); if (pending_it != pendingFetch.end()) { @@ -265,14 +288,14 @@ FetchUnit::execute(int slot_num) DPRINTF(InOrderCachePort, "%08p is a pending fetch block " "(pending:%i).\n", block_addr, (*pending_it)->cnt); - } else if (pendingFetch.size() < fetchBuffSize) { + } else if (total_pending < fetchBuffSize) { std::list<FetchBlock*>::iterator buff_it; buff_it = findBlock(fetchBuffer, asid, block_addr); - if (buff_it != fetchBuffer.end()) { + if (buff_it != fetchBuffer.end()) { (*buff_it)->cnt++; do_fetch = false; - DPRINTF(InOrderCachePort, "%08p is in fetch buffer" + DPRINTF(InOrderCachePort, "%08p is in fetch buffer " "(pending:%i).\n", block_addr, (*buff_it)->cnt); } } @@ -287,9 +310,9 @@ FetchUnit::execute(int slot_num) // Check to see if there is room in the fetchbuffer for this instruction. // If not, block this request. - if (pendingFetch.size() >= fetchBuffSize) { + if (total_pending >= fetchBuffSize) { DPRINTF(InOrderCachePort, "No room available in fetch buffer.\n"); - cache_req->done(); + cache_req->done(false); return; } @@ -309,6 +332,8 @@ FetchUnit::execute(int slot_num) if (cache_req->isMemAccPending()) { pendingFetch.push_back(new FetchBlock(asid, block_addr)); + + // mark replacement block } } @@ -509,19 +534,22 @@ FetchUnit::squashCacheRequest(CacheReqPtr req_ptr) block_addr); if (buff_it != fetchBuffer.end()) { (*buff_it)->cnt--; - DPRINTF(InOrderCachePort, "[sn:%i] Removing Pending Fetch " - "for Buffer block %08p (cnt=%i)\n", inst->seqNum, + DPRINTF(InOrderCachePort, "[sn:%i] Removing Pending Access " + "for Fetch Buffer block %08p (cnt=%i)\n", inst->seqNum, block_addr, (*buff_it)->cnt); + assert((*buff_it)->cnt >= 0); } else { std::list<FetchBlock*>::iterator block_it = findBlock(pendingFetch, asid, block_addr); if (block_it != pendingFetch.end()) { (*block_it)->cnt--; + DPRINTF(InOrderCachePort, "[sn:%i] Removing Pending Access " + "for Pending Buffer Block %08p (cnt=%i)\n", + inst->seqNum, + block_addr, (*block_it)->cnt); + assert((*block_it)->cnt >= 0); if ((*block_it)->cnt == 0) { - DPRINTF(InOrderCachePort, "[sn:%i] Removing Pending Fetch " - "for block %08p (cnt=%i)\n", inst->seqNum, - block_addr, (*block_it)->cnt); if ((*block_it)->block) { delete [] (*block_it)->block; } diff --git a/src/cpu/inorder/resources/fetch_unit.hh b/src/cpu/inorder/resources/fetch_unit.hh index d6e36419a..cc1e72914 100644 --- a/src/cpu/inorder/resources/fetch_unit.hh +++ b/src/cpu/inorder/resources/fetch_unit.hh @@ -120,6 +120,8 @@ class FetchUnit : public CacheUnit void markBlockUsed(std::list<FetchBlock*>::iterator block_it); + int blocksInUse(); + int instSize; int fetchBuffSize; |