aboutsummaryrefslogtreecommitdiff
path: root/src/gpgpu-sim/gpu-cache.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpgpu-sim/gpu-cache.h')
-rw-r--r--src/gpgpu-sim/gpu-cache.h54
1 files changed, 42 insertions, 12 deletions
diff --git a/src/gpgpu-sim/gpu-cache.h b/src/gpgpu-sim/gpu-cache.h
index 2a37876..26369c3 100644
--- a/src/gpgpu-sim/gpu-cache.h
+++ b/src/gpgpu-sim/gpu-cache.h
@@ -49,6 +49,7 @@ enum cache_request_status {
MISS,
RESERVATION_FAIL,
SECTOR_MISS,
+ MSHR_HIT,
NUM_CACHE_REQUEST_STATUS
};
@@ -128,6 +129,8 @@ struct cache_block_t {
mem_access_sector_mask_t sector_mask) = 0;
virtual void set_modified_on_fill(bool m_modified,
mem_access_sector_mask_t sector_mask) = 0;
+ virtual void set_readable_on_fill(bool readable,
+ mem_access_sector_mask_t sector_mask) = 0;
virtual unsigned get_modified_size() = 0;
virtual void set_m_readable(bool readable,
mem_access_sector_mask_t sector_mask) = 0;
@@ -147,6 +150,7 @@ struct line_cache_block : public cache_block_t {
m_status = INVALID;
m_ignore_on_fill_status = false;
m_set_modified_on_fill = false;
+ m_set_readable_on_fill = false;
m_readable = true;
}
void allocate(new_addr_type tag, new_addr_type block_addr, unsigned time,
@@ -159,12 +163,16 @@ struct line_cache_block : public cache_block_t {
m_status = RESERVED;
m_ignore_on_fill_status = false;
m_set_modified_on_fill = false;
+ m_set_readable_on_fill = false;
}
void fill(unsigned time, mem_access_sector_mask_t sector_mask) {
// if(!m_ignore_on_fill_status)
// assert( m_status == RESERVED );
m_status = m_set_modified_on_fill ? MODIFIED : VALID;
+
+ if (m_set_readable_on_fill)
+ m_readable = true;
m_fill_time = time;
}
@@ -197,6 +205,10 @@ struct line_cache_block : public cache_block_t {
mem_access_sector_mask_t sector_mask) {
m_set_modified_on_fill = m_modified;
}
+ virtual void set_readable_on_fill(bool readable,
+ mem_access_sector_mask_t sector_mask) {
+ m_set_readable_on_fill = readable;
+ }
virtual unsigned get_modified_size() {
return SECTOR_CHUNCK_SIZE * SECTOR_SIZE; // i.e. cache line size
}
@@ -218,6 +230,7 @@ struct line_cache_block : public cache_block_t {
cache_block_state m_status;
bool m_ignore_on_fill_status;
bool m_set_modified_on_fill;
+ bool m_set_readable_on_fill;
bool m_readable;
};
@@ -232,6 +245,7 @@ struct sector_cache_block : public cache_block_t {
m_status[i] = INVALID;
m_ignore_on_fill_status[i] = false;
m_set_modified_on_fill[i] = false;
+ m_set_readable_on_fill[i] = false;
m_readable[i] = true;
}
m_line_alloc_time = 0;
@@ -261,6 +275,7 @@ struct sector_cache_block : public cache_block_t {
m_status[sidx] = RESERVED;
m_ignore_on_fill_status[sidx] = false;
m_set_modified_on_fill[sidx] = false;
+ m_set_readable_on_fill[sidx] = false;
// set line stats
m_line_alloc_time = time; // only set this for the first allocated sector
@@ -283,6 +298,8 @@ struct sector_cache_block : public cache_block_t {
else
m_set_modified_on_fill[sidx] = false;
+ m_set_readable_on_fill[sidx] = false;
+
m_status[sidx] = RESERVED;
m_ignore_on_fill_status[sidx] = false;
// m_set_modified_on_fill[sidx] = false;
@@ -300,6 +317,11 @@ struct sector_cache_block : public cache_block_t {
// assert( m_status[sidx] == RESERVED );
m_status[sidx] = m_set_modified_on_fill[sidx] ? MODIFIED : VALID;
+
+ if (m_set_readable_on_fill[sidx]) {
+ m_readable[sidx] = true;
+ m_set_readable_on_fill[sidx] = false;
+ }
m_sector_fill_time[sidx] = time;
m_line_fill_time = time;
@@ -366,6 +388,11 @@ struct sector_cache_block : public cache_block_t {
m_set_modified_on_fill[sidx] = m_modified;
}
+ virtual void set_readable_on_fill(bool readable,
+ mem_access_sector_mask_t sector_mask) {
+ unsigned sidx = get_sector_index(sector_mask);
+ m_set_readable_on_fill[sidx] = readable;
+ }
virtual void set_m_readable(bool readable,
mem_access_sector_mask_t sector_mask) {
unsigned sidx = get_sector_index(sector_mask);
@@ -400,6 +427,7 @@ struct sector_cache_block : public cache_block_t {
cache_block_state m_status[SECTOR_CHUNCK_SIZE];
bool m_ignore_on_fill_status[SECTOR_CHUNCK_SIZE];
bool m_set_modified_on_fill[SECTOR_CHUNCK_SIZE];
+ bool m_set_readable_on_fill[SECTOR_CHUNCK_SIZE];
bool m_readable[SECTOR_CHUNCK_SIZE];
unsigned get_sector_index(mem_access_sector_mask_t sector_mask) {
@@ -686,17 +714,11 @@ class cache_config {
m_line_sz * m_nset * m_assoc, m_nset, m_assoc, m_line_sz);
}
- virtual unsigned set_index(new_addr_type addr) const {
- if (m_set_index_function != LINEAR_SET_FUNCTION) {
- printf(
- "\nGPGPU-Sim cache configuration error: Hashing or "
- "custom set index function selected in configuration "
- "file for a cache that has not overloaded the set_index "
- "function\n");
- abort();
- }
- return (addr >> m_line_sz_log2) & (m_nset - 1);
- }
+ virtual unsigned set_index(new_addr_type addr) const;
+
+ unsigned hash_function(new_addr_type addr, unsigned m_nset,
+ unsigned m_line_sz_log2, unsigned m_nset_log2,
+ unsigned m_index_function) const;
new_addr_type tag(new_addr_type addr) const {
// For generality, the tag includes both index and tag. This allows for more
@@ -793,10 +815,18 @@ class cache_config {
class l1d_cache_config : public cache_config {
public:
l1d_cache_config() : cache_config() {}
- virtual unsigned set_index(new_addr_type addr) const;
unsigned set_bank(new_addr_type addr) const;
+ void init(char *config, FuncCache status) {
+ m_banks_byte_interleaving_log2 = LOGB2(l1_banks_byte_interleaving);
+ m_l1_banks_log2 = LOGB2(l1_banks);
+ cache_config::init(config, status);
+ }
unsigned l1_latency;
unsigned l1_banks;
+ unsigned m_l1_banks_log2;
+ unsigned l1_banks_byte_interleaving;
+ unsigned m_banks_byte_interleaving_log2;
+ unsigned l1_banks_hashing_function;
};
class l2_cache_config : public cache_config {