From 6f94c3c8d755d1cdd3854fde5741305afcd44b19 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Sat, 2 Dec 2006 22:22:58 -0800 Subject: Make cache compression policy a runtime virtual thing instead of a template policy. --HG-- extra : convert_revision : 6a4ac7a189a950390a973fdfce94f56190de92db --- src/mem/cache/cache.cc | 76 ++++++--------------- src/mem/cache/cache_builder.cc | 101 ++++++++++------------------ src/mem/cache/miss/blocking_buffer.hh | 1 + src/mem/cache/prefetch/ghb_prefetcher.cc | 6 +- src/mem/cache/prefetch/stride_prefetcher.cc | 6 +- 5 files changed, 59 insertions(+), 131 deletions(-) (limited to 'src/mem') diff --git a/src/mem/cache/cache.cc b/src/mem/cache/cache.cc index db66c096e..54d1d151f 100644 --- a/src/mem/cache/cache.cc +++ b/src/mem/cache/cache.cc @@ -37,7 +37,6 @@ */ #include "mem/config/cache.hh" -#include "mem/config/compression.hh" #include "mem/cache/tags/cache_tags.hh" @@ -61,11 +60,6 @@ #include "mem/cache/tags/split_lifo.hh" #endif -#include "base/compression/null_compression.hh" -#if defined(USE_LZSS_COMPRESSION) -#include "base/compression/lzss_compression.hh" -#endif - #include "mem/cache/miss/miss_queue.hh" #include "mem/cache/miss/blocking_buffer.hh" @@ -79,68 +73,38 @@ #if defined(USE_CACHE_FALRU) -template class Cache, BlockingBuffer, SimpleCoherence>; -template class Cache, BlockingBuffer, UniCoherence>; -template class Cache, MissQueue, SimpleCoherence>; -template class Cache, MissQueue, UniCoherence>; -#if defined(USE_LZSS_COMPRESSION) -template class Cache, BlockingBuffer, SimpleCoherence>; -template class Cache, BlockingBuffer, UniCoherence>; -template class Cache, MissQueue, SimpleCoherence>; -template class Cache, MissQueue, UniCoherence>; -#endif +template class Cache, BlockingBuffer, SimpleCoherence>; +template class Cache, BlockingBuffer, UniCoherence>; +template class Cache, MissQueue, SimpleCoherence>; +template class Cache, MissQueue, UniCoherence>; #endif #if defined(USE_CACHE_IIC) -template class Cache, BlockingBuffer, SimpleCoherence>; -template class Cache, BlockingBuffer, UniCoherence>; -template class Cache, MissQueue, SimpleCoherence>; -template class Cache, MissQueue, UniCoherence>; -#if defined(USE_LZSS_COMPRESSION) -template class Cache, BlockingBuffer, SimpleCoherence>; -template class Cache, BlockingBuffer, UniCoherence>; -template class Cache, MissQueue, SimpleCoherence>; -template class Cache, MissQueue, UniCoherence>; -#endif +template class Cache, BlockingBuffer, SimpleCoherence>; +template class Cache, BlockingBuffer, UniCoherence>; +template class Cache, MissQueue, SimpleCoherence>; +template class Cache, MissQueue, UniCoherence>; #endif #if defined(USE_CACHE_LRU) -template class Cache, BlockingBuffer, SimpleCoherence>; -template class Cache, BlockingBuffer, UniCoherence>; -template class Cache, MissQueue, SimpleCoherence>; -template class Cache, MissQueue, UniCoherence>; -#if defined(USE_LZSS_COMPRESSION) -template class Cache, BlockingBuffer, SimpleCoherence>; -template class Cache, BlockingBuffer, UniCoherence>; -template class Cache, MissQueue, SimpleCoherence>; -template class Cache, MissQueue, UniCoherence>; -#endif +template class Cache, BlockingBuffer, SimpleCoherence>; +template class Cache, BlockingBuffer, UniCoherence>; +template class Cache, MissQueue, SimpleCoherence>; +template class Cache, MissQueue, UniCoherence>; #endif #if defined(USE_CACHE_SPLIT) -template class Cache, BlockingBuffer, SimpleCoherence>; -template class Cache, BlockingBuffer, UniCoherence>; -template class Cache, MissQueue, SimpleCoherence>; -template class Cache, MissQueue, UniCoherence>; -#if defined(USE_LZSS_COMPRESSION) -template class Cache, BlockingBuffer, SimpleCoherence>; -template class Cache, BlockingBuffer, UniCoherence>; -template class Cache, MissQueue, SimpleCoherence>; -template class Cache, MissQueue, UniCoherence>; -#endif +template class Cache, BlockingBuffer, SimpleCoherence>; +template class Cache, BlockingBuffer, UniCoherence>; +template class Cache, MissQueue, SimpleCoherence>; +template class Cache, MissQueue, UniCoherence>; #endif #if defined(USE_CACHE_SPLIT_LIFO) -template class Cache, BlockingBuffer, SimpleCoherence>; -template class Cache, BlockingBuffer, UniCoherence>; -template class Cache, MissQueue, SimpleCoherence>; -template class Cache, MissQueue, UniCoherence>; -#if defined(USE_LZSS_COMPRESSION) -template class Cache, BlockingBuffer, SimpleCoherence>; -template class Cache, BlockingBuffer, UniCoherence>; -template class Cache, MissQueue, SimpleCoherence>; -template class Cache, MissQueue, UniCoherence>; -#endif +template class Cache, BlockingBuffer, SimpleCoherence>; +template class Cache, BlockingBuffer, UniCoherence>; +template class Cache, MissQueue, SimpleCoherence>; +template class Cache, MissQueue, UniCoherence>; #endif #endif //DOXYGEN_SHOULD_SKIP_THIS diff --git a/src/mem/cache/cache_builder.cc b/src/mem/cache/cache_builder.cc index 03646ec2a..7d4207ae1 100644 --- a/src/mem/cache/cache_builder.cc +++ b/src/mem/cache/cache_builder.cc @@ -37,7 +37,6 @@ // Must be included first to determine which caches we want #include "mem/config/cache.hh" -#include "mem/config/compression.hh" #include "mem/config/prefetch.hh" #include "mem/cache/base_cache.hh" @@ -69,9 +68,7 @@ // Compression Templates #include "base/compression/null_compression.hh" -#if defined(USE_LZSS_COMPRESSION) #include "base/compression/lzss_compression.hh" -#endif // CacheTags Templates #include "mem/cache/tags/cache_tags.hh" @@ -211,77 +208,47 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(BaseCache) END_INIT_SIM_OBJECT_PARAMS(BaseCache) -#define BUILD_CACHE(t, comp, b, c) do { \ - Prefetcher, b> *pf; \ +#define BUILD_CACHE(t, b, c) do { \ + Prefetcher, b> *pf; \ if (pf_policy == "tagged") { \ - BUILD_TAGGED_PREFETCHER(t, comp, b); \ + BUILD_TAGGED_PREFETCHER(t, b); \ } \ else if (pf_policy == "stride") { \ - BUILD_STRIDED_PREFETCHER(t, comp, b); \ + BUILD_STRIDED_PREFETCHER(t, b); \ } \ else if (pf_policy == "ghb") { \ - BUILD_GHB_PREFETCHER(t, comp, b); \ + BUILD_GHB_PREFETCHER(t, b); \ } \ else { \ - BUILD_NULL_PREFETCHER(t, comp, b); \ + BUILD_NULL_PREFETCHER(t, b); \ } \ - Cache, b, c>::Params params(tagStore, mq, coh, \ + Cache, b, c>::Params params(tagStore, mq, coh, \ base_params, \ - /*in_bus, out_bus,*/ pf, \ + pf, \ prefetch_access, hit_latency); \ - Cache, b, c> *retval = \ - new Cache, b, c>(getInstanceName(), /*hier,*/ \ - params); \ -/* if (in_bus == NULL) { \ - retval->setSlaveInterface(new MemoryInterface, b, c> >(getInstanceName(), hier, retval, mem_trace)); \ - } else { \ - retval->setSlaveInterface(new SlaveInterface, b, c>, Bus>(getInstanceName(), hier, retval, in_bus, mem_trace)); \ - } \ - retval->setMasterInterface(new MasterInterface, b, c>, Bus>(getInstanceName(), hier, retval, out_bus)); \ - out_bus->rangeChange(); \ - return retval; \ -*/return retval; \ + Cache, b, c> *retval = \ + new Cache, b, c>(getInstanceName(), params); \ +return retval; \ } while (0) #define BUILD_CACHE_PANIC(x) do { \ panic("%s not compiled into M5", x); \ } while (0) -#if defined(USE_LZSS_COMPRESSION) -#define BUILD_COMPRESSED_CACHE(TAGS, tags, b, c) do { \ - if (compressed_bus || store_compressed){ \ - CacheTags *tagStore = \ - new CacheTags(tags, \ - compression_latency, \ - true, store_compressed, \ - adaptive_compression, \ - prefetch_miss); \ - BUILD_CACHE(TAGS, LZSSCompression, b, c); \ - } else { \ - CacheTags *tagStore = \ - new CacheTags(tags, \ - compression_latency, \ - true, store_compressed, \ - adaptive_compression, \ - prefetch_miss); \ - BUILD_CACHE(TAGS, NullCompression, b, c); \ - } \ - } while (0) -#else -#define BUILD_COMPRESSED_CACHE(TAGS, tags, b, c) do { \ - if (compressed_bus || store_compressed){ \ - BUILD_CACHE_PANIC("compressed caches"); \ +#define BUILD_COMPRESSED_CACHE(TAGS, tags, b, c) \ + do { \ + CompressionAlgorithm *compAlg; \ + if (compressed_bus || store_compressed) { \ + compAlg = new LZSSCompression(); \ } else { \ - CacheTags *tagStore = \ - new CacheTags(tags, \ - compression_latency, \ - true, store_compressed, \ - adaptive_compression \ - prefetch_miss); \ - BUILD_CACHE(TAGS, NullCompression, b, c); \ + compAlg = new NullCompression(); \ } \ + CacheTags *tagStore = \ + new CacheTags(tags, compression_latency, true, \ + store_compressed, adaptive_compression, \ + compAlg, prefetch_miss); \ + BUILD_CACHE(TAGS, b, c); \ } while (0) -#endif #if defined(USE_CACHE_FALRU) #define BUILD_FALRU_CACHE(b,c) do { \ @@ -359,8 +326,8 @@ END_INIT_SIM_OBJECT_PARAMS(BaseCache) } while (0) #if defined(USE_TAGGED) -#define BUILD_TAGGED_PREFETCHER(t, comp, b) pf = new \ - TaggedPrefetcher, b>(prefetcher_size, \ +#define BUILD_TAGGED_PREFETCHER(t, b) pf = new \ + TaggedPrefetcher, b>(prefetcher_size, \ !prefetch_past_page, \ prefetch_serial_squash, \ prefetch_cache_check_push, \ @@ -368,12 +335,12 @@ END_INIT_SIM_OBJECT_PARAMS(BaseCache) prefetch_latency, \ prefetch_degree) #else -#define BUILD_TAGGED_PREFETCHER(t, comp, b) BUILD_CACHE_PANIC("Tagged Prefetcher") +#define BUILD_TAGGED_PREFETCHER(t, b) BUILD_CACHE_PANIC("Tagged Prefetcher") #endif #if defined(USE_STRIDED) -#define BUILD_STRIDED_PREFETCHER(t, comp, b) pf = new \ - StridePrefetcher, b>(prefetcher_size, \ +#define BUILD_STRIDED_PREFETCHER(t, b) pf = new \ + StridePrefetcher, b>(prefetcher_size, \ !prefetch_past_page, \ prefetch_serial_squash, \ prefetch_cache_check_push, \ @@ -382,12 +349,12 @@ END_INIT_SIM_OBJECT_PARAMS(BaseCache) prefetch_degree, \ prefetch_use_cpu_id) #else -#define BUILD_STRIDED_PREFETCHER(t, comp, b) BUILD_CACHE_PANIC("Stride Prefetcher") +#define BUILD_STRIDED_PREFETCHER(t, b) BUILD_CACHE_PANIC("Stride Prefetcher") #endif #if defined(USE_GHB) -#define BUILD_GHB_PREFETCHER(t, comp, b) pf = new \ - GHBPrefetcher, b>(prefetcher_size, \ +#define BUILD_GHB_PREFETCHER(t, b) pf = new \ + GHBPrefetcher, b>(prefetcher_size, \ !prefetch_past_page, \ prefetch_serial_squash, \ prefetch_cache_check_push, \ @@ -396,12 +363,12 @@ END_INIT_SIM_OBJECT_PARAMS(BaseCache) prefetch_degree, \ prefetch_use_cpu_id) #else -#define BUILD_GHB_PREFETCHER(t, comp, b) BUILD_CACHE_PANIC("GHB Prefetcher") +#define BUILD_GHB_PREFETCHER(t, b) BUILD_CACHE_PANIC("GHB Prefetcher") #endif #if defined(USE_TAGGED) -#define BUILD_NULL_PREFETCHER(t, comp, b) pf = new \ - TaggedPrefetcher, b>(prefetcher_size, \ +#define BUILD_NULL_PREFETCHER(t, b) pf = new \ + TaggedPrefetcher, b>(prefetcher_size, \ !prefetch_past_page, \ prefetch_serial_squash, \ prefetch_cache_check_push, \ @@ -409,7 +376,7 @@ END_INIT_SIM_OBJECT_PARAMS(BaseCache) prefetch_latency, \ prefetch_degree) #else -#define BUILD_NULL_PREFETCHER(t, comp, b) BUILD_CACHE_PANIC("NULL Prefetcher (uses Tagged)") +#define BUILD_NULL_PREFETCHER(t, b) BUILD_CACHE_PANIC("NULL Prefetcher (uses Tagged)") #endif CREATE_SIM_OBJECT(BaseCache) diff --git a/src/mem/cache/miss/blocking_buffer.hh b/src/mem/cache/miss/blocking_buffer.hh index 934a843a6..a952c688c 100644 --- a/src/mem/cache/miss/blocking_buffer.hh +++ b/src/mem/cache/miss/blocking_buffer.hh @@ -38,6 +38,7 @@ #include +#include "base/misc.hh" // for fatal() #include "mem/cache/miss/mshr.hh" #include "base/statistics.hh" diff --git a/src/mem/cache/prefetch/ghb_prefetcher.cc b/src/mem/cache/prefetch/ghb_prefetcher.cc index 247ec6e8b..dd1b8aee4 100644 --- a/src/mem/cache/prefetch/ghb_prefetcher.cc +++ b/src/mem/cache/prefetch/ghb_prefetcher.cc @@ -38,8 +38,6 @@ #include "mem/cache/tags/lru.hh" -#include "base/compression/null_compression.hh" - #include "mem/cache/miss/miss_queue.hh" #include "mem/cache/miss/blocking_buffer.hh" @@ -48,7 +46,7 @@ // Template Instantiations #ifndef DOXYGEN_SHOULD_SKIP_THIS -template class GHBPrefetcher, MissQueue>; -template class GHBPrefetcher, BlockingBuffer>; +template class GHBPrefetcher, MissQueue>; +template class GHBPrefetcher, BlockingBuffer>; #endif //DOXYGEN_SHOULD_SKIP_THIS diff --git a/src/mem/cache/prefetch/stride_prefetcher.cc b/src/mem/cache/prefetch/stride_prefetcher.cc index 93a096468..c3b428dab 100644 --- a/src/mem/cache/prefetch/stride_prefetcher.cc +++ b/src/mem/cache/prefetch/stride_prefetcher.cc @@ -38,8 +38,6 @@ #include "mem/cache/tags/lru.hh" -#include "base/compression/null_compression.hh" - #include "mem/cache/miss/miss_queue.hh" #include "mem/cache/miss/blocking_buffer.hh" @@ -48,7 +46,7 @@ // Template Instantiations #ifndef DOXYGEN_SHOULD_SKIP_THIS -template class StridePrefetcher, MissQueue>; -template class StridePrefetcher, BlockingBuffer>; +template class StridePrefetcher, MissQueue>; +template class StridePrefetcher, BlockingBuffer>; #endif //DOXYGEN_SHOULD_SKIP_THIS -- cgit v1.2.3