summaryrefslogtreecommitdiff
path: root/src/gpgpu-sim/gpu-cache.h
diff options
context:
space:
mode:
authorTim Rogers <[email protected]>2013-02-10 20:40:34 -0800
committerAndrew Boktor <[email protected]>2014-08-14 13:50:04 -0700
commitc591d13a90aad7d99bb40aef9e44d6bfce0b74c0 (patch)
tree1525326dfa44a4d7f28596bbbfdd6e7892a30088 /src/gpgpu-sim/gpu-cache.h
parente4d7bf562e8e90fa4523efc186322bff416c0506 (diff)
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]
Diffstat (limited to 'src/gpgpu-sim/gpu-cache.h')
-rw-r--r--src/gpgpu-sim/gpu-cache.h81
1 files changed, 76 insertions, 5 deletions
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<cache_event> &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<mem_fetch*> 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<cache_event> &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
@@ -504,6 +539,13 @@ public:
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;
// Set read hit function
@@ -531,6 +573,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;
// Functions for data cache access
@@ -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<cache_event> &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<cache_event> &events );
};