CacheMemory.cc (11308:7d8836fd043d) | CacheMemory.cc (11321:02e930db812d) |
---|---|
1/* 2 * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood 3 * Copyright (c) 2013 Advanced Micro Devices, Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 309 unchanged lines hidden (view full) --- 318 319// looks an address up in the cache 320AbstractCacheEntry* 321CacheMemory::lookup(Addr address) 322{ 323 assert(address == makeLineAddress(address)); 324 int64_t cacheSet = addressToCacheSet(address); 325 int loc = findTagInSet(cacheSet, address); | 1/* 2 * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood 3 * Copyright (c) 2013 Advanced Micro Devices, Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 309 unchanged lines hidden (view full) --- 318 319// looks an address up in the cache 320AbstractCacheEntry* 321CacheMemory::lookup(Addr address) 322{ 323 assert(address == makeLineAddress(address)); 324 int64_t cacheSet = addressToCacheSet(address); 325 int loc = findTagInSet(cacheSet, address); |
326 if(loc == -1) return NULL; | 326 if (loc == -1) return NULL; |
327 return m_cache[cacheSet][loc]; 328} 329 330// looks an address up in the cache 331const AbstractCacheEntry* 332CacheMemory::lookup(Addr address) const 333{ 334 assert(address == makeLineAddress(address)); 335 int64_t cacheSet = addressToCacheSet(address); 336 int loc = findTagInSet(cacheSet, address); | 327 return m_cache[cacheSet][loc]; 328} 329 330// looks an address up in the cache 331const AbstractCacheEntry* 332CacheMemory::lookup(Addr address) const 333{ 334 assert(address == makeLineAddress(address)); 335 int64_t cacheSet = addressToCacheSet(address); 336 int loc = findTagInSet(cacheSet, address); |
337 if(loc == -1) return NULL; | 337 if (loc == -1) return NULL; |
338 return m_cache[cacheSet][loc]; 339} 340 341// Sets the most recently used bit for a cache block 342void 343CacheMemory::setMRU(Addr address) 344{ 345 int64_t cacheSet = addressToCacheSet(address); 346 int loc = findTagInSet(cacheSet, address); 347 | 338 return m_cache[cacheSet][loc]; 339} 340 341// Sets the most recently used bit for a cache block 342void 343CacheMemory::setMRU(Addr address) 344{ 345 int64_t cacheSet = addressToCacheSet(address); 346 int loc = findTagInSet(cacheSet, address); 347 |
348 if(loc != -1) | 348 if (loc != -1) |
349 m_replacementPolicy_ptr->touch(cacheSet, loc, curTick()); 350} 351 352void 353CacheMemory::setMRU(const AbstractCacheEntry *e) 354{ 355 uint32_t cacheSet = e->getSetIndex(); 356 uint32_t loc = e->getWayIndex(); 357 m_replacementPolicy_ptr->touch(cacheSet, loc, curTick()); 358} 359 360void 361CacheMemory::setMRU(Addr address, int occupancy) 362{ 363 int64_t cacheSet = addressToCacheSet(address); 364 int loc = findTagInSet(cacheSet, address); 365 | 349 m_replacementPolicy_ptr->touch(cacheSet, loc, curTick()); 350} 351 352void 353CacheMemory::setMRU(const AbstractCacheEntry *e) 354{ 355 uint32_t cacheSet = e->getSetIndex(); 356 uint32_t loc = e->getWayIndex(); 357 m_replacementPolicy_ptr->touch(cacheSet, loc, curTick()); 358} 359 360void 361CacheMemory::setMRU(Addr address, int occupancy) 362{ 363 int64_t cacheSet = addressToCacheSet(address); 364 int loc = findTagInSet(cacheSet, address); 365 |
366 if(loc != -1) { | 366 if (loc != -1) { |
367 if (m_replacementPolicy_ptr->useOccupancy()) { 368 (static_cast<WeightedLRUPolicy*>(m_replacementPolicy_ptr))-> 369 touch(cacheSet, loc, curTick(), occupancy); 370 } else { 371 m_replacementPolicy_ptr-> 372 touch(cacheSet, loc, curTick()); 373 } 374 } 375} 376 377int 378CacheMemory::getReplacementWeight(int64_t set, int64_t loc) 379{ 380 assert(set < m_cache_num_sets); 381 assert(loc < m_cache_assoc); 382 int ret = 0; | 367 if (m_replacementPolicy_ptr->useOccupancy()) { 368 (static_cast<WeightedLRUPolicy*>(m_replacementPolicy_ptr))-> 369 touch(cacheSet, loc, curTick(), occupancy); 370 } else { 371 m_replacementPolicy_ptr-> 372 touch(cacheSet, loc, curTick()); 373 } 374 } 375} 376 377int 378CacheMemory::getReplacementWeight(int64_t set, int64_t loc) 379{ 380 assert(set < m_cache_num_sets); 381 assert(loc < m_cache_assoc); 382 int ret = 0; |
383 if(m_cache[set][loc] != NULL) { | 383 if (m_cache[set][loc] != NULL) { |
384 ret = m_cache[set][loc]->getNumValidBlocks(); 385 assert(ret >= 0); 386 } 387 388 return ret; 389} 390 391void --- 261 unchanged lines hidden --- | 384 ret = m_cache[set][loc]->getNumValidBlocks(); 385 assert(ret >= 0); 386 } 387 388 return ret; 389} 390 391void --- 261 unchanged lines hidden --- |