summaryrefslogtreecommitdiff
path: root/src/gpgpu-sim/gpu-cache.h
diff options
context:
space:
mode:
authorTayler Hetherington <[email protected]>2013-06-16 12:26:07 -0800
committerAndrew Boktor <[email protected]>2014-08-14 13:50:47 -0700
commitb90f5f6d42e91fe5e093ed2656c1b64fc3257469 (patch)
treea76344609d30978528796dadbb198226b4c8a53b /src/gpgpu-sim/gpu-cache.h
parent821753ac64ac2b3f4a441d0ed6d8bb0cdffb0fb8 (diff)
Review: 33001. Updating/cleaning up the cache statistics. Moving the statistics from the tag array to the cache access functions. Added cache_stats class to record all memory accesses and access outcomes to each cache. Removed L2CacheAccessBreakdown_t. Cleaned up power_stats to reflect changes in the cache stats. Updated the cache stats printing. This will cause the performance gold files to change as the output format has been changed.
[git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 16452]
Diffstat (limited to 'src/gpgpu-sim/gpu-cache.h')
-rw-r--r--src/gpgpu-sim/gpu-cache.h113
1 files changed, 91 insertions, 22 deletions
diff --git a/src/gpgpu-sim/gpu-cache.h b/src/gpgpu-sim/gpu-cache.h
index 59e56bc..90805be 100644
--- a/src/gpgpu-sim/gpu-cache.h
+++ b/src/gpgpu-sim/gpu-cache.h
@@ -319,7 +319,8 @@ public:
void print( FILE *stream, unsigned &total_access, unsigned &total_misses ) const;
float windowed_miss_rate( ) const;
- void get_stats(unsigned &total_access, unsigned &total_misses) const;
+ void get_stats(unsigned &total_access, unsigned &total_misses, unsigned &total_hit_res, unsigned &total_res_fail) const;
+
void update_cache_parameters(cache_config &config);
protected:
// This constructor is intended for use only from derived classes that wish to
@@ -340,6 +341,7 @@ protected:
unsigned m_access;
unsigned m_miss;
unsigned m_pending_hit; // number of cache miss that hit a line that is allocated but not filled
+ unsigned m_res_fail;
// performance counters for calculating the amount of misses within a time window
unsigned m_prev_snapshot_access;
@@ -405,6 +407,73 @@ private:
/***************************************************************** Caches *****************************************************************/
+///
+/// Simple struct to maintain cache accesses, misses, pending hits, and reservation fails.
+///
+struct cache_sub_stats{
+ unsigned accesses;
+ unsigned misses;
+ unsigned pending_hits;
+ unsigned res_fails;
+
+ cache_sub_stats(){
+ clear();
+ }
+ void clear(){
+ accesses = 0;
+ misses = 0;
+ pending_hits = 0;
+ res_fails = 0;
+ }
+ cache_sub_stats &operator+=(const cache_sub_stats &css){
+ ///
+ /// Overloading += operator to easily accumulate stats
+ ///
+ accesses += css.accesses;
+ misses += css.misses;
+ pending_hits += css.pending_hits;
+ res_fails += css.res_fails;
+ return *this;
+ }
+
+ cache_sub_stats operator+(const cache_sub_stats &cs){
+ ///
+ /// Overloading + operator to easily accumulate stats
+ ///
+ cache_sub_stats ret;
+ ret.accesses = accesses + cs.accesses;
+ ret.misses = misses + cs.misses;
+ ret.pending_hits = pending_hits + cs.pending_hits;
+ ret.res_fails = res_fails + cs.res_fails;
+ return ret;
+ }
+};
+
+///
+/// Cache_stats
+/// Used to record statistics for each cache.
+/// Maintains a record of every 'mem_access_type' and its resulting
+/// 'cache_request_status' : [mem_access_type][cache_request_status]
+///
+class cache_stats {
+public:
+ cache_stats();
+ void clear();
+ void inc_stats(int access_type, int access_outcome);
+ unsigned &operator()(int access_type, int access_outcome);
+ unsigned operator()(int access_type, int access_outcome) const;
+ cache_stats operator+(const cache_stats &cs);
+ cache_stats &operator+=(const cache_stats &cs);
+ void print_stats(FILE *fout, const char *cache_name = "Cache_stats") const;
+
+ unsigned get_stats(enum mem_access_type *access_type, unsigned num_access_type, enum cache_request_status *access_status, unsigned num_access_status) const;
+ void get_sub_stats(struct cache_sub_stats &css) const;
+
+private:
+ bool check_valid(int type, int status) const;
+
+ std::vector<std::vector<unsigned>> m_stats;
+};
class cache_t {
public:
@@ -436,10 +505,6 @@ public:
assert(config.m_mshr_type == ASSOC);
m_memport=memport;
m_miss_queue_status = status;
- m_read_access=0;
- m_write_access=0;
- m_read_miss=0;
- m_write_miss=0;
}
virtual ~baseline_cache()
@@ -470,15 +535,15 @@ public:
void print(FILE *fp, unsigned &accesses, unsigned &misses) const;
void display_state( FILE *fp ) const;
- virtual void get_data_stats(unsigned &read_access, unsigned &read_misses,unsigned &write_access, unsigned &write_misses) const {
- read_access = m_read_access;
- write_access = m_write_access;
- read_misses = m_read_miss;
- write_misses = m_write_miss;
+ // Stat collection
+ const cache_stats &get_stats() const {
+ return m_stats;
}
-
- void get_stats(unsigned &accesses, unsigned &misses) const {
- m_tag_array->get_stats(accesses, misses);
+ unsigned get_stats(enum mem_access_type *access_type, unsigned num_access_type, enum cache_request_status *access_status, unsigned num_access_status) const{
+ return m_stats.get_stats(access_type, num_access_type, access_status, num_access_status);
+ }
+ void get_sub_stats(struct cache_sub_stats &css) const {
+ m_stats.get_sub_stats(css);
}
protected:
@@ -525,6 +590,8 @@ protected:
extra_mf_fields_lookup m_extra_mf_fields;
+ cache_stats m_stats;
+
/// Checks whether this request can be handled on this cycle. num_miss equals max # of misses to be handled on this cycle
bool miss_queue_full(unsigned num_miss){
return ( (m_miss_queue.size()+num_miss) >= m_config.m_miss_queue_size );
@@ -535,12 +602,6 @@ protected:
/// Read miss handler. Check MSHR hit or MSHR available
void send_read_request(new_addr_type addr, new_addr_type block_addr, unsigned cache_index, mem_fetch *mf,
unsigned time, bool &do_miss, bool &wb, cache_block_t &evicted, std::list<cache_event> &events, bool read_only, bool wa);
-
- // Power stats
- unsigned m_read_access;
- unsigned m_write_access;
- unsigned m_read_miss;
- unsigned m_write_miss;
};
/// Read only cache
@@ -600,7 +661,6 @@ public:
}
}
-
protected:
data_cache( const char *name,
cache_config &config,
@@ -736,10 +796,17 @@ public:
mem_fetch *next_access(){return m_result_fifo.pop();}
void display_state( FILE *fp ) const;
- void get_stats(unsigned &accesses, unsigned &misses) const{
- m_tags.get_stats(accesses, misses);
+ // Stat collection
+ const cache_stats &get_stats() const {
+ return m_stats;
+ }
+ unsigned get_stats(enum mem_access_type *access_type, unsigned num_access_type, enum cache_request_status *access_status, unsigned num_access_status) const{
+ return m_stats.get_stats(access_type, num_access_type, access_status, num_access_status);
}
+ void get_sub_stats(struct cache_sub_stats &css) const{
+ m_stats.get_sub_stats(css);
+ }
private:
std::string m_name;
const cache_config &m_config;
@@ -863,6 +930,8 @@ private:
unsigned m_rob_index;
};
+ cache_stats m_stats;
+
typedef std::map<mem_fetch*,extra_mf_fields> extra_mf_fields_lookup;
extra_mf_fields_lookup m_extra_mf_fields;