From c591d13a90aad7d99bb40aef9e44d6bfce0b74c0 Mon Sep 17 00:00:00 2001 From: Tim Rogers Date: Sun, 10 Feb 2013 20:40:34 -0800 Subject: Merging //depot/gpgpu_sim_research/fermi_locality/... to //depot/gpgpu_sim_research/fermi/... Adding in some protected constructors to the core cache classes. This allows us to customize caches (for example having them use a custom tag array) more easily. Also I made the in-class tag_array object in the baseline_cache into a pointer. This allows derived classes to easily create custom tag arrays. I think in general, class extendibility is increased when pointers are used instead of in-object storage. [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 15223] --- src/gpgpu-sim/gpu-cache.h | 81 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 5 deletions(-) (limited to 'src/gpgpu-sim/gpu-cache.h') diff --git a/src/gpgpu-sim/gpu-cache.h b/src/gpgpu-sim/gpu-cache.h index dabcc18..fb59c01 100644 --- a/src/gpgpu-sim/gpu-cache.h +++ b/src/gpgpu-sim/gpu-cache.h @@ -394,7 +394,15 @@ class baseline_cache : public cache_t { public: baseline_cache( const char *name, const cache_config &config, int core_id, int type_id, mem_fetch_interface *memport, enum mem_fetch_status status ) - : m_config(config), m_tag_array(config,core_id,type_id), m_mshrs(config.m_mshr_entries,config.m_mshr_max_merge) + : m_config(config), m_tag_array(new tag_array(config,core_id,type_id)), m_mshrs(config.m_mshr_entries,config.m_mshr_max_merge) + { + init( name, config, memport, status ); + } + + void init( const char *name, + const cache_config &config, + mem_fetch_interface *memport, + enum mem_fetch_status status ) { m_name = name; assert(config.m_mshr_type == ASSOC); @@ -407,6 +415,11 @@ public: n_simt_to_mem=0; } + virtual ~baseline_cache() + { + delete m_tag_array; + } + virtual enum cache_request_status access( new_addr_type addr, mem_fetch *mf, unsigned time, std::list &events ) = 0; /// Sends next request to lower level of memory void cycle(); @@ -419,7 +432,7 @@ public: /// Pop next ready access (does not include accesses that "HIT") mem_fetch *next_access(){return m_mshrs.next_access();} // flash invalidate all entries in cache - void flush(){m_tag_array.flush();} + void flush(){m_tag_array->flush();} void print(FILE *fp, unsigned &accesses, unsigned &misses) const; void display_state( FILE *fp ) const; @@ -431,17 +444,33 @@ public: } void get_stats(unsigned &accesses, unsigned &misses) const { - m_tag_array.get_stats(accesses, misses); + m_tag_array->get_stats(accesses, misses); } void set_icnt_power_stats(unsigned &simt_to_mem) const{ simt_to_mem = n_simt_to_mem; } - protected: +protected: + // Constructor that can be used by derived classes with custom tag arrays + baseline_cache( const char *name, + const cache_config &config, + int core_id, + int type_id, + mem_fetch_interface *memport, + enum mem_fetch_status status, + tag_array* new_tag_array ) + : m_config(config), + m_tag_array( new_tag_array ), + m_mshrs(config.m_mshr_entries,config.m_mshr_max_merge) + { + init( name, config, memport, status ); + } + +protected: std::string m_name; const cache_config &m_config; - tag_array m_tag_array; + tag_array* m_tag_array; mshr_table m_mshrs; std::list m_miss_queue; enum mem_fetch_status m_miss_queue_status; @@ -494,6 +523,12 @@ public: /// Access cache for read_only_cache: returns RESERVATION_FAIL if request could not be accepted (for any reason) virtual enum cache_request_status access( new_addr_type addr, mem_fetch *mf, unsigned time, std::list &events ); + + virtual ~read_only_cache(){} + +protected: + read_only_cache( const char *name, const cache_config &config, int core_id, int type_id, mem_fetch_interface *memport, enum mem_fetch_status status, tag_array* new_tag_array ) + : baseline_cache(name,config,core_id,type_id,memport,status, new_tag_array){} }; /// Data cache - Implements common functions for L1 and L2 data cache @@ -503,6 +538,13 @@ public: int core_id, int type_id, mem_fetch_interface *memport, mem_fetch_allocator *mfcreator, enum mem_fetch_status status ) : baseline_cache(name,config,core_id,type_id,memport,status) + { + init( mfcreator ); + } + + virtual ~data_cache() {} + + void init( mem_fetch_allocator *mfcreator ) { m_memfetch_creator=mfcreator; @@ -530,6 +572,20 @@ public: } } +protected: + data_cache( const char *name, + const cache_config &config, + int core_id, + int type_id, + mem_fetch_interface *memport, + mem_fetch_allocator *mfcreator, + enum mem_fetch_status status, + tag_array* new_tag_array ) + : baseline_cache(name, config, core_id, type_id, memport,status, new_tag_array) + { + init( mfcreator ); + } + protected: mem_fetch_allocator *m_memfetch_creator; @@ -576,8 +632,21 @@ public: mem_fetch_allocator *mfcreator, enum mem_fetch_status status ) : data_cache(name,config,core_id,type_id,memport,mfcreator,status){} + virtual ~l1_cache(){} + virtual enum cache_request_status access( new_addr_type addr, mem_fetch *mf, unsigned time, std::list &events ); +protected: + l1_cache( const char *name, + const cache_config &config, + int core_id, + int type_id, + mem_fetch_interface *memport, + mem_fetch_allocator *mfcreator, + enum mem_fetch_status status, + tag_array* new_tag_array ) + : data_cache(name,config,core_id,type_id,memport,mfcreator,status, new_tag_array){} + }; /// Models second level shared cache with global write-back and write-allocate policies @@ -588,6 +657,8 @@ public: mem_fetch_allocator *mfcreator, enum mem_fetch_status status ) : data_cache(name,config,core_id,type_id,memport,mfcreator,status){} + virtual ~l2_cache() {} + virtual enum cache_request_status access( new_addr_type addr, mem_fetch *mf, unsigned time, std::list &events ); }; -- cgit v1.3