fa_lru.cc (2811:9da12e9830ce) | fa_lru.cc (2814:b723c79f5349) |
---|---|
1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 25 unchanged lines hidden (view full) --- 34 */ 35 36#include <sstream> 37 38#include <assert.h> 39 40#include "mem/cache/tags/fa_lru.hh" 41#include "base/intmath.hh" | 1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 25 unchanged lines hidden (view full) --- 34 */ 35 36#include <sstream> 37 38#include <assert.h> 39 40#include "mem/cache/tags/fa_lru.hh" 41#include "base/intmath.hh" |
42#include "base/misc.hh" |
|
42 43using namespace std; 44 45FALRU::FALRU(int _blkSize, int _size, int hit_latency) 46 : blkSize(_blkSize), size(_size), 47 numBlks(size/blkSize), hitLatency(hit_latency) 48{ 49 if (!isPowerOf2(blkSize)) --- 149 unchanged lines hidden (view full) --- 199 lat = hitLatency; 200 //assert(check()); 201 return blk; 202} 203 204FALRUBlk* 205FALRU::findBlock(Packet * &pkt, int &lat, int *inCache) 206{ | 43 44using namespace std; 45 46FALRU::FALRU(int _blkSize, int _size, int hit_latency) 47 : blkSize(_blkSize), size(_size), 48 numBlks(size/blkSize), hitLatency(hit_latency) 49{ 50 if (!isPowerOf2(blkSize)) --- 149 unchanged lines hidden (view full) --- 200 lat = hitLatency; 201 //assert(check()); 202 return blk; 203} 204 205FALRUBlk* 206FALRU::findBlock(Packet * &pkt, int &lat, int *inCache) 207{ |
207 Addr addr = pkt->paddr; | 208 Addr addr = pkt->getAddr(); |
208 209 accesses++; 210 int tmp_in_cache = 0; 211 Addr blkAddr = blkAlign(addr); 212 FALRUBlk* blk = hashLookup(blkAddr); 213 214 if (blk && blk->isValid()) { 215 assert(blk->tag == blkAddr); --- 34 unchanged lines hidden (view full) --- 250 assert(blk->tag == blkAddr); 251 } else { 252 blk = NULL; 253 } 254 return blk; 255} 256 257FALRUBlk* | 209 210 accesses++; 211 int tmp_in_cache = 0; 212 Addr blkAddr = blkAlign(addr); 213 FALRUBlk* blk = hashLookup(blkAddr); 214 215 if (blk && blk->isValid()) { 216 assert(blk->tag == blkAddr); --- 34 unchanged lines hidden (view full) --- 251 assert(blk->tag == blkAddr); 252 } else { 253 blk = NULL; 254 } 255 return blk; 256} 257 258FALRUBlk* |
258FALRU::findReplacement(Packet * &pkt, PacketList* &writebacks, | 259FALRU::findReplacement(Packet * &pkt, PacketList &writebacks, |
259 BlkList &compress_blocks) 260{ 261 FALRUBlk * blk = tail; 262 assert(blk->inCache == 0); 263 moveToHead(blk); 264 tagHash.erase(blk->tag); | 260 BlkList &compress_blocks) 261{ 262 FALRUBlk * blk = tail; 263 assert(blk->inCache == 0); 264 moveToHead(blk); 265 tagHash.erase(blk->tag); |
265 tagHash[blkAlign(pkt->paddr)] = blk; | 266 tagHash[blkAlign(pkt->getAddr())] = blk; |
266 if (blk->isValid()) { | 267 if (blk->isValid()) { |
267 int req->setThreadNum() = (blk->xc) ? blk->xc->getThreadNum() : 0; 268 replacements[req->getThreadNum()]++; | 268 replacements[0]++; |
269 } else { 270 tagsInUse++; 271 blk->isTouched = true; 272 if (!warmedUp && tagsInUse.value() >= warmupBound) { 273 warmedUp = true; 274 warmupCycle = curTick; 275 } 276 } --- 58 unchanged lines hidden --- | 269 } else { 270 tagsInUse++; 271 blk->isTouched = true; 272 if (!warmedUp && tagsInUse.value() >= warmupBound) { 273 warmedUp = true; 274 warmupCycle = curTick; 275 } 276 } --- 58 unchanged lines hidden --- |