summaryrefslogtreecommitdiff
path: root/src/gpgpu-sim
diff options
context:
space:
mode:
authorMahmoud Khairy A. Abdallah <[email protected]>2021-05-23 12:59:34 -0400
committerMahmoud Khairy A. Abdallah <[email protected]>2021-05-23 12:59:34 -0400
commit6c9e13db93e4a1614f7401e9675c62ea40b65a3b (patch)
tree3ffd3af47aab1781a7a17e3cb77f093c8f499a3e /src/gpgpu-sim
parentb6409b4605dac8e39ea22ea6977a28c31177e44a (diff)
format code
Diffstat (limited to 'src/gpgpu-sim')
-rw-r--r--src/gpgpu-sim/gpu-cache.cc89
-rw-r--r--src/gpgpu-sim/gpu-cache.h84
-rw-r--r--src/gpgpu-sim/gpu-sim.cc12
-rw-r--r--src/gpgpu-sim/l2cache.cc57
-rw-r--r--src/gpgpu-sim/l2cache.h13
-rw-r--r--src/gpgpu-sim/shader.cc119
-rw-r--r--src/gpgpu-sim/shader.h17
7 files changed, 196 insertions, 195 deletions
diff --git a/src/gpgpu-sim/gpu-cache.cc b/src/gpgpu-sim/gpu-cache.cc
index 7e7d2ad..28d3215 100644
--- a/src/gpgpu-sim/gpu-cache.cc
+++ b/src/gpgpu-sim/gpu-cache.cc
@@ -37,7 +37,8 @@
const char *cache_request_status_str(enum cache_request_status status) {
static const char *static_cache_request_status_str[] = {
- "HIT", "HIT_RESERVED", "MISS", "RESERVATION_FAIL", "SECTOR_MISS", "MSHR_HIT"};
+ "HIT", "HIT_RESERVED", "MISS", "RESERVATION_FAIL",
+ "SECTOR_MISS", "MSHR_HIT"};
assert(sizeof(static_cache_request_status_str) / sizeof(const char *) ==
NUM_CACHE_REQUEST_STATUS);
@@ -63,9 +64,9 @@ unsigned l1d_cache_config::set_bank(new_addr_type addr) const {
// For sector cache, we select one sector per bank (sector interleaving)
// This is what was found in Volta (one sector per bank, sector interleaving)
// otherwise, line interleaving
- return cache_config::hash_function(addr, l1_banks, l1_banks_byte_interleaving_log2,
- l1_banks_log2,
- l1_banks_hashing_function);
+ return cache_config::hash_function(addr, l1_banks,
+ l1_banks_byte_interleaving_log2,
+ l1_banks_log2, l1_banks_hashing_function);
}
unsigned cache_config::set_index(new_addr_type addr) const {
@@ -235,7 +236,7 @@ enum cache_request_status tag_array::probe(new_addr_type addr, unsigned &idx,
mem_fetch *mf, bool is_write,
bool probe_mode) const {
mem_access_sector_mask_t mask = mf->get_access_sector_mask();
- return probe(addr, idx, mask,is_write, probe_mode, mf);
+ return probe(addr, idx, mask, is_write, probe_mode, mf);
}
enum cache_request_status tag_array::probe(new_addr_type addr, unsigned &idx,
@@ -281,8 +282,8 @@ enum cache_request_status tag_array::probe(new_addr_type addr, unsigned &idx,
if (!line->is_reserved_line()) {
// percentage of dirty lines in the cache
// number of dirty lines / total lines in the cache
- float dirty_line_percentage =
- ((float) m_dirty / (m_config.m_nset * m_config.m_assoc )) * 100;
+ float dirty_line_percentage =
+ ((float)m_dirty / (m_config.m_nset * m_config.m_assoc)) * 100;
if (!line->is_modified_line() ||
dirty_line_percentage >= m_config.m_wr_percent) {
// if number of dirty lines in the cache is greater than
@@ -357,7 +358,7 @@ enum cache_request_status tag_array::access(new_addr_type addr, unsigned time,
evicted.set_info(m_lines[idx]->m_block_addr,
m_lines[idx]->get_modified_size(),
m_lines[idx]->get_dirty_byte_mask(),
- m_lines[idx]->get_dirty_sector_mask());
+ m_lines[idx]->get_dirty_sector_mask());
m_dirty--;
}
m_lines[idx]->allocate(m_config.tag(addr), m_config.block_addr(addr),
@@ -372,9 +373,9 @@ enum cache_request_status tag_array::access(new_addr_type addr, unsigned time,
bool before = m_lines[idx]->is_modified_line();
((sector_cache_block *)m_lines[idx])
->allocate_sector(time, mf->get_access_sector_mask());
- if (before && !m_lines[idx]->is_modified_line()) {
- m_dirty--;
- }
+ if (before && !m_lines[idx]->is_modified_line()) {
+ m_dirty--;
+ }
}
break;
case RESERVATION_FAIL:
@@ -391,16 +392,18 @@ enum cache_request_status tag_array::access(new_addr_type addr, unsigned time,
return status;
}
-void tag_array::fill(new_addr_type addr, unsigned time, mem_fetch *mf, bool is_write) {
- fill(addr, time, mf->get_access_sector_mask(), mf->get_access_byte_mask(), is_write);
+void tag_array::fill(new_addr_type addr, unsigned time, mem_fetch *mf,
+ bool is_write) {
+ fill(addr, time, mf->get_access_sector_mask(), mf->get_access_byte_mask(),
+ is_write);
}
void tag_array::fill(new_addr_type addr, unsigned time,
- mem_access_sector_mask_t mask, mem_access_byte_mask_t byte_mask,
- bool is_write) {
+ mem_access_sector_mask_t mask,
+ mem_access_byte_mask_t byte_mask, bool is_write) {
// assert( m_config.m_alloc_policy == ON_FILL );
unsigned idx;
- enum cache_request_status status = probe(addr, idx, mask,is_write);
+ enum cache_request_status status = probe(addr, idx, mask, is_write);
bool before = m_lines[idx]->is_modified_line();
// assert(status==MISS||status==SECTOR_MISS); // MSHR should have prevented
// redundant memory request
@@ -423,7 +426,8 @@ void tag_array::fill(new_addr_type addr, unsigned time,
void tag_array::fill(unsigned index, unsigned time, mem_fetch *mf) {
assert(m_config.m_alloc_policy == ON_MISS);
- m_lines[index]->fill(time, mf->get_access_sector_mask(), mf->get_access_byte_mask());
+ m_lines[index]->fill(time, mf->get_access_sector_mask(),
+ mf->get_access_byte_mask());
m_dirty++;
}
@@ -437,7 +441,7 @@ void tag_array::flush() {
m_lines[i]->set_status(INVALID, mem_access_sector_mask_t().set(j));
}
}
-
+
m_dirty = 0;
is_used = false;
}
@@ -794,8 +798,8 @@ void cache_stats::print_stats(FILE *fout, const char *cache_name) const {
m_stats[type][status]);
if (status != RESERVATION_FAIL && status != MSHR_HIT)
- // MSHR_HIT is a special type of SECTOR_MISS
- // so its already included in the SECTOR_MISS
+ // MSHR_HIT is a special type of SECTOR_MISS
+ // so its already included in the SECTOR_MISS
total_access[type] += m_stats[type][status];
}
}
@@ -1335,10 +1339,10 @@ enum cache_request_status data_cache::wr_miss_wa_naive(
assert(status ==
MISS); // SECTOR_MISS and HIT_RESERVED should not send write back
mem_fetch *wb = m_memfetch_creator->alloc(
- evicted.m_block_addr,m_wrbk_type,
- mf->get_access_warp_mask(), evicted.m_byte_mask,
- evicted.m_sector_mask, evicted.m_modified_size,
- true, m_gpu->gpu_tot_sim_cycle + m_gpu->gpu_sim_cycle,-1,-1,-1,NULL);
+ evicted.m_block_addr, m_wrbk_type, mf->get_access_warp_mask(),
+ evicted.m_byte_mask, evicted.m_sector_mask, evicted.m_modified_size,
+ true, m_gpu->gpu_tot_sim_cycle + m_gpu->gpu_sim_cycle, -1, -1, -1,
+ NULL);
// the evicted block may have wrong chip id when advanced L2 hashing is
// used, so set the right chip address from the original mf
wb->set_chip(mf->get_tlx_addr().chip);
@@ -1388,10 +1392,10 @@ enum cache_request_status data_cache::wr_miss_wa_fetch_on_write(
// (already modified lower level)
if (wb && (m_config.m_write_policy != WRITE_THROUGH)) {
mem_fetch *wb = m_memfetch_creator->alloc(
- evicted.m_block_addr,m_wrbk_type,
- mf->get_access_warp_mask(), evicted.m_byte_mask,
- evicted.m_sector_mask, evicted.m_modified_size,
- true, m_gpu->gpu_tot_sim_cycle + m_gpu->gpu_sim_cycle,-1,-1,-1,NULL);
+ evicted.m_block_addr, m_wrbk_type, mf->get_access_warp_mask(),
+ evicted.m_byte_mask, evicted.m_sector_mask, evicted.m_modified_size,
+ true, m_gpu->gpu_tot_sim_cycle + m_gpu->gpu_sim_cycle, -1, -1, -1,
+ NULL);
// the evicted block may have wrong chip id when advanced L2 hashing is
// used, so set the right chip address from the original mf
wb->set_chip(mf->get_tlx_addr().chip);
@@ -1461,10 +1465,10 @@ enum cache_request_status data_cache::wr_miss_wa_fetch_on_write(
// (already modified lower level)
if (wb && (m_config.m_write_policy != WRITE_THROUGH)) {
mem_fetch *wb = m_memfetch_creator->alloc(
- evicted.m_block_addr,m_wrbk_type,
- mf->get_access_warp_mask(), evicted.m_byte_mask,
- evicted.m_sector_mask, evicted.m_modified_size,
- true, m_gpu->gpu_tot_sim_cycle + m_gpu->gpu_sim_cycle,-1,-1,-1,NULL);
+ evicted.m_block_addr, m_wrbk_type, mf->get_access_warp_mask(),
+ evicted.m_byte_mask, evicted.m_sector_mask, evicted.m_modified_size,
+ true, m_gpu->gpu_tot_sim_cycle + m_gpu->gpu_sim_cycle, -1, -1, -1,
+ NULL);
// the evicted block may have wrong chip id when advanced L2 hashing is
// used, so set the right chip address from the original mf
wb->set_chip(mf->get_tlx_addr().chip);
@@ -1514,7 +1518,6 @@ enum cache_request_status data_cache::wr_miss_wa_lazy_fetch_on_read(
send_write_request(mf, cache_event(WRITE_REQUEST_SENT), time, events);
}
-
bool wb = false;
evicted_block_info evicted;
@@ -1538,7 +1541,7 @@ enum cache_request_status data_cache::wr_miss_wa_lazy_fetch_on_read(
} else {
block->set_m_readable(false, mf->get_access_sector_mask());
if (m_status == HIT_RESERVED)
- block->set_readable_on_fill(true, mf->get_access_sector_mask());
+ block->set_readable_on_fill(true, mf->get_access_sector_mask());
}
if (m_status != RESERVATION_FAIL) {
@@ -1546,10 +1549,10 @@ enum cache_request_status data_cache::wr_miss_wa_lazy_fetch_on_read(
// (already modified lower level)
if (wb && (m_config.m_write_policy != WRITE_THROUGH)) {
mem_fetch *wb = m_memfetch_creator->alloc(
- evicted.m_block_addr,m_wrbk_type,
- mf->get_access_warp_mask(), evicted.m_byte_mask,
- evicted.m_sector_mask, evicted.m_modified_size,
- true, m_gpu->gpu_tot_sim_cycle + m_gpu->gpu_sim_cycle,-1,-1,-1,NULL);
+ evicted.m_block_addr, m_wrbk_type, mf->get_access_warp_mask(),
+ evicted.m_byte_mask, evicted.m_sector_mask, evicted.m_modified_size,
+ true, m_gpu->gpu_tot_sim_cycle + m_gpu->gpu_sim_cycle, -1, -1, -1,
+ NULL);
// the evicted block may have wrong chip id when advanced L2 hashing is
// used, so set the right chip address from the original mf
wb->set_chip(mf->get_tlx_addr().chip);
@@ -1596,7 +1599,7 @@ enum cache_request_status data_cache::rd_hit_base(
m_tag_array->inc_dirty();
}
block->set_status(MODIFIED,
- mf->get_access_sector_mask()); // mark line as
+ mf->get_access_sector_mask()); // mark line as
block->set_byte_mask(mf);
}
return HIT;
@@ -1628,10 +1631,10 @@ enum cache_request_status data_cache::rd_miss_base(
// (already modified lower level)
if (wb && (m_config.m_write_policy != WRITE_THROUGH)) {
mem_fetch *wb = m_memfetch_creator->alloc(
- evicted.m_block_addr,m_wrbk_type,
- mf->get_access_warp_mask(), evicted.m_byte_mask,
- evicted.m_sector_mask, evicted.m_modified_size,
- true, m_gpu->gpu_tot_sim_cycle + m_gpu->gpu_sim_cycle,-1,-1,-1,NULL);
+ evicted.m_block_addr, m_wrbk_type, mf->get_access_warp_mask(),
+ evicted.m_byte_mask, evicted.m_sector_mask, evicted.m_modified_size,
+ true, m_gpu->gpu_tot_sim_cycle + m_gpu->gpu_sim_cycle, -1, -1, -1,
+ NULL);
// the evicted block may have wrong chip id when advanced L2 hashing is
// used, so set the right chip address from the original mf
wb->set_chip(mf->get_tlx_addr().chip);
diff --git a/src/gpgpu-sim/gpu-cache.h b/src/gpgpu-sim/gpu-cache.h
index 007403f..7a2a8d9 100644
--- a/src/gpgpu-sim/gpu-cache.h
+++ b/src/gpgpu-sim/gpu-cache.h
@@ -84,7 +84,7 @@ struct evicted_block_info {
m_block_addr = block_addr;
m_modified_size = modified_size;
}
- void set_info(new_addr_type block_addr, unsigned modified_size,
+ void set_info(new_addr_type block_addr, unsigned modified_size,
mem_access_byte_mask_t byte_mask,
mem_access_sector_mask_t sector_mask) {
m_block_addr = block_addr;
@@ -121,8 +121,8 @@ struct cache_block_t {
virtual void allocate(new_addr_type tag, new_addr_type block_addr,
unsigned time,
mem_access_sector_mask_t sector_mask) = 0;
- virtual void fill(unsigned time, mem_access_sector_mask_t sector_mask,
- mem_access_byte_mask_t byte_mask) = 0;
+ virtual void fill(unsigned time, mem_access_sector_mask_t sector_mask,
+ mem_access_byte_mask_t byte_mask) = 0;
virtual bool is_invalid_line() = 0;
virtual bool is_valid_line() = 0;
@@ -183,15 +183,14 @@ struct line_cache_block : public cache_block_t {
m_set_readable_on_fill = false;
m_set_byte_mask_on_fill = false;
}
- virtual void fill(unsigned time, mem_access_sector_mask_t sector_mask,
- mem_access_byte_mask_t byte_mask) {
+ virtual void fill(unsigned time, mem_access_sector_mask_t sector_mask,
+ mem_access_byte_mask_t byte_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;
+
+ if (m_set_readable_on_fill) m_readable = true;
if (m_set_byte_mask_on_fill) set_byte_mask(byte_mask);
m_fill_time = time;
@@ -358,10 +357,10 @@ struct sector_cache_block : public cache_block_t {
// if(!m_ignore_on_fill_status[sidx])
// 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_readable[sidx] = true;
+ m_set_readable_on_fill[sidx] = false;
}
if (m_set_byte_mask_on_fill) set_byte_mask(byte_mask);
@@ -416,8 +415,7 @@ struct sector_cache_block : public cache_block_t {
virtual mem_access_sector_mask_t get_dirty_sector_mask() {
mem_access_sector_mask_t sector_mask;
for (unsigned i = 0; i < SECTOR_CHUNCK_SIZE; i++) {
- if (m_status[i] == MODIFIED)
- sector_mask.set(i);
+ if (m_status[i] == MODIFIED) sector_mask.set(i);
}
return sector_mask;
}
@@ -575,7 +573,7 @@ class cache_config {
}
exit_parse_error();
}
-
+
switch (ct) {
case 'N':
m_cache_type = NORMAL;
@@ -631,18 +629,19 @@ class cache_config {
if (m_alloc_policy == STREAMING) {
/*
For streaming cache:
- (1) we set the alloc policy to be on-fill to remove all line_alloc_fail stalls.
- if the whole memory is allocated to the L1 cache, then make the allocation to be on_MISS
- otherwise, make it ON_FILL to eliminate line allocation fails.
- i.e. MSHR throughput is the same, independent on the L1 cache size/associativity
- So, we set the allocation policy per kernel basis, see shader.cc, max_cta() function
-
+ (1) we set the alloc policy to be on-fill to remove all line_alloc_fail
+ stalls. if the whole memory is allocated to the L1 cache, then make the
+ allocation to be on_MISS otherwise, make it ON_FILL to eliminate line
+ allocation fails. i.e. MSHR throughput is the same, independent on the L1
+ cache size/associativity So, we set the allocation policy per kernel
+ basis, see shader.cc, max_cta() function
+
(2) We also set the MSHRs to be equal to max
allocated cache lines. This is possible by moving TAG to be shared
between cache line and MSHR enrty (i.e. for each cache line, there is
an MSHR rntey associated with it). This is the easiest think we can
think of to model (mimic) L1 streaming cache in Pascal and Volta
-
+
For more information about streaming cache, see:
http://on-demand.gputechconf.com/gtc/2017/presentation/s7798-luke-durant-inside-volta.pdf
https://ieeexplore.ieee.org/document/8344474/
@@ -697,8 +696,8 @@ class cache_config {
}
// detect invalid configuration
- if ((m_alloc_policy == ON_FILL || m_alloc_policy == STREAMING)
- and m_write_policy == WRITE_BACK) {
+ if ((m_alloc_policy == ON_FILL || m_alloc_policy == STREAMING) and
+ m_write_policy == WRITE_BACK) {
// A writeback cache with allocate-on-fill policy will inevitably lead to
// deadlock: The deadlock happens when an incoming cache-fill evicts a
// dirty line, generating a writeback request. If the memory subsystem is
@@ -746,7 +745,7 @@ class cache_config {
break;
case 'X':
m_set_index_function = BITWISE_XORING_FUNCTION;
- break;
+ break;
default:
exit_parse_error();
}
@@ -779,7 +778,9 @@ class cache_config {
virtual unsigned set_index(new_addr_type addr) const;
- virtual unsigned get_max_cache_multiplier() const { return MAX_DEFAULT_CACHE_SIZE_MULTIBLIER;}
+ virtual unsigned get_max_cache_multiplier() const {
+ return MAX_DEFAULT_CACHE_SIZE_MULTIBLIER;
+ }
unsigned hash_function(new_addr_type addr, unsigned m_nset,
unsigned m_line_sz_log2, unsigned m_nset_log2,
@@ -826,9 +827,7 @@ class cache_config {
write_allocate_policy_t get_write_allocate_policy() {
return m_write_alloc_policy;
}
- write_policy_t get_write_policy() {
- return m_write_policy;
- }
+ write_policy_t get_write_policy() { return m_write_policy; }
protected:
void exit_parse_error() {
@@ -903,17 +902,17 @@ class l1d_cache_config : public cache_config {
unsigned l1_banks_byte_interleaving_log2;
unsigned l1_banks_hashing_function;
unsigned m_unified_cache_size;
- virtual unsigned get_max_cache_multiplier() const {
- // set * assoc * cacheline size. Then convert Byte to KB
- // gpgpu_unified_cache_size is in KB while original_sz is in B
- if (m_unified_cache_size > 0) {
- unsigned original_size = m_nset * original_m_assoc * m_line_sz / 1024;
- assert(m_unified_cache_size % original_size == 0);
- return m_unified_cache_size / original_size;
- } else {
- return MAX_DEFAULT_CACHE_SIZE_MULTIBLIER;
- }
+ virtual unsigned get_max_cache_multiplier() const {
+ // set * assoc * cacheline size. Then convert Byte to KB
+ // gpgpu_unified_cache_size is in KB while original_sz is in B
+ if (m_unified_cache_size > 0) {
+ unsigned original_size = m_nset * original_m_assoc * m_line_sz / 1024;
+ assert(m_unified_cache_size % original_size == 0);
+ return m_unified_cache_size / original_size;
+ } else {
+ return MAX_DEFAULT_CACHE_SIZE_MULTIBLIER;
}
+ }
};
class l2_cache_config : public cache_config {
@@ -936,8 +935,7 @@ class tag_array {
mem_fetch *mf, bool is_write,
bool probe_mode = false) const;
enum cache_request_status probe(new_addr_type addr, unsigned &idx,
- mem_access_sector_mask_t mask,
- bool is_write,
+ mem_access_sector_mask_t mask, bool is_write,
bool probe_mode = false,
mem_fetch *mf = NULL) const;
enum cache_request_status access(new_addr_type addr, unsigned time,
@@ -948,7 +946,7 @@ class tag_array {
void fill(new_addr_type addr, unsigned time, mem_fetch *mf, bool is_write);
void fill(unsigned idx, unsigned time, mem_fetch *mf);
- void fill(new_addr_type addr, unsigned time, mem_access_sector_mask_t mask,
+ void fill(new_addr_type addr, unsigned time, mem_access_sector_mask_t mask,
mem_access_byte_mask_t byte_mask, bool is_write);
unsigned size() const { return m_config.get_num_lines(); }
@@ -967,9 +965,7 @@ class tag_array {
void update_cache_parameters(cache_config &config);
void add_pending_line(mem_fetch *mf);
void remove_pending_line(mem_fetch *mf);
- void inc_dirty() {
- m_dirty++;
- }
+ void inc_dirty() { m_dirty++; }
protected:
// This constructor is intended for use only from derived classes that wish to
diff --git a/src/gpgpu-sim/gpu-sim.cc b/src/gpgpu-sim/gpu-sim.cc
index df30047..56ede05 100644
--- a/src/gpgpu-sim/gpu-sim.cc
+++ b/src/gpgpu-sim/gpu-sim.cc
@@ -249,7 +249,8 @@ void shader_core_config::reg_options(class OptionParser *opp) {
" {<nsets>:<bsize>:<assoc>,<rep>:<wr>:<alloc>:<wr_"
"alloc>,<mshr>:<N>:<merge>,<mq> | none}",
"none");
- option_parser_register(opp,"-gpgpu_l1_cache_write_ratio",OPT_UINT32,&m_L1D_config.m_wr_percent,"L1D write ratio","0");
+ option_parser_register(opp, "-gpgpu_l1_cache_write_ratio", OPT_UINT32,
+ &m_L1D_config.m_wr_percent, "L1D write ratio", "0");
option_parser_register(opp, "-gpgpu_l1_banks", OPT_UINT32,
&m_L1D_config.l1_banks, "The number of L1 cache banks",
"1");
@@ -327,11 +328,12 @@ void shader_core_config::reg_options(class OptionParser *opp) {
option_parser_register(
opp, "-gpgpu_shmem_size", OPT_UINT32, &gpgpu_shmem_size,
"Size of shared memory per shader core (default 16kB)", "16384");
+ option_parser_register(opp, "-gpgpu_shmem_option", OPT_CSTR,
+ &gpgpu_shmem_option,
+ "Option list of shared memory sizes", "0");
option_parser_register(
- opp, "-gpgpu_shmem_option", OPT_CSTR, &gpgpu_shmem_option,
- "Option list of shared memory sizes", "0");
- option_parser_register(
- opp, "-gpgpu_unified_l1d_size", OPT_UINT32, &m_L1D_config.m_unified_cache_size,
+ opp, "-gpgpu_unified_l1d_size", OPT_UINT32,
+ &m_L1D_config.m_unified_cache_size,
"Size of unified data cache(L1D + shared memory) in KB", "0");
option_parser_register(opp, "-gpgpu_adaptive_cache_config", OPT_BOOL,
&adaptive_cache_config, "adaptive_cache_config", "0");
diff --git a/src/gpgpu-sim/l2cache.cc b/src/gpgpu-sim/l2cache.cc
index 0db6bd4..57e8ea9 100644
--- a/src/gpgpu-sim/l2cache.cc
+++ b/src/gpgpu-sim/l2cache.cc
@@ -57,20 +57,18 @@ mem_fetch *partition_mf_allocator::alloc(new_addr_type addr,
return mf;
}
-mem_fetch *partition_mf_allocator::alloc(new_addr_type addr, mem_access_type type,
- const active_mask_t &active_mask,
- const mem_access_byte_mask_t &byte_mask,
- const mem_access_sector_mask_t &sector_mask,
- unsigned size, bool wr,
- unsigned long long cycle,
- unsigned wid, unsigned sid,
- unsigned tpc, mem_fetch *original_mf) const {
- mem_access_t access(type, addr, size, wr, active_mask, byte_mask,
- sector_mask, m_memory_config->gpgpu_ctx);
+mem_fetch *partition_mf_allocator::alloc(
+ new_addr_type addr, mem_access_type type, const active_mask_t &active_mask,
+ const mem_access_byte_mask_t &byte_mask,
+ const mem_access_sector_mask_t &sector_mask, unsigned size, bool wr,
+ unsigned long long cycle, unsigned wid, unsigned sid, unsigned tpc,
+ mem_fetch *original_mf) const {
+ mem_access_t access(type, addr, size, wr, active_mask, byte_mask, sector_mask,
+ m_memory_config->gpgpu_ctx);
mem_fetch *mf =
- new mem_fetch(access, NULL, wr ? WRITE_PACKET_SIZE : READ_PACKET_SIZE, wid,
- sid, tpc, m_memory_config, cycle,original_mf);
- return mf;
+ new mem_fetch(access, NULL, wr ? WRITE_PACKET_SIZE : READ_PACKET_SIZE,
+ wid, sid, tpc, m_memory_config, cycle, original_mf);
+ return mf;
}
memory_partition_unit::memory_partition_unit(unsigned partition_id,
const memory_config *config,
@@ -725,11 +723,12 @@ memory_sub_partition::breakdown_request_to_sector_requests(mem_fetch *mf) {
for (unsigned k = i * SECTOR_SIZE; k < (i + 1) * SECTOR_SIZE; k++) {
mask.set(k);
}
- mem_fetch *n_mf = m_mf_allocator->alloc(mf->get_addr() + SECTOR_SIZE * i,
- mf->get_access_type(),mf->get_access_warp_mask(),
- mf->get_access_byte_mask() & mask,std::bitset<SECTOR_CHUNCK_SIZE>().set(i),
- SECTOR_SIZE,mf->is_write(),m_gpu->gpu_tot_sim_cycle + m_gpu->gpu_sim_cycle,
- mf->get_wid(),mf->get_sid(), mf->get_tpc(),mf);
+ mem_fetch *n_mf = m_mf_allocator->alloc(
+ mf->get_addr() + SECTOR_SIZE * i, mf->get_access_type(),
+ mf->get_access_warp_mask(), mf->get_access_byte_mask() & mask,
+ std::bitset<SECTOR_CHUNCK_SIZE>().set(i), SECTOR_SIZE, mf->is_write(),
+ m_gpu->gpu_tot_sim_cycle + m_gpu->gpu_sim_cycle, mf->get_wid(),
+ mf->get_sid(), mf->get_tpc(), mf);
result.push_back(n_mf);
}
@@ -746,11 +745,12 @@ memory_sub_partition::breakdown_request_to_sector_requests(mem_fetch *mf) {
for (unsigned k = i * SECTOR_SIZE; k < (i + 1) * SECTOR_SIZE; k++) {
mask.set(k);
}
- mem_fetch *n_mf = m_mf_allocator->alloc(mf->get_addr(),
- mf->get_access_type(),mf->get_access_warp_mask(),
- mf->get_access_byte_mask() & mask,std::bitset<SECTOR_CHUNCK_SIZE>().set(i),
- SECTOR_SIZE,mf->is_write(),m_gpu->gpu_tot_sim_cycle + m_gpu->gpu_sim_cycle,
- mf->get_wid(),mf->get_sid(), mf->get_tpc(),mf);
+ mem_fetch *n_mf = m_mf_allocator->alloc(
+ mf->get_addr(), mf->get_access_type(), mf->get_access_warp_mask(),
+ mf->get_access_byte_mask() & mask,
+ std::bitset<SECTOR_CHUNCK_SIZE>().set(i), SECTOR_SIZE, mf->is_write(),
+ m_gpu->gpu_tot_sim_cycle + m_gpu->gpu_sim_cycle, mf->get_wid(),
+ mf->get_sid(), mf->get_tpc(), mf);
result.push_back(n_mf);
}
@@ -761,11 +761,12 @@ memory_sub_partition::breakdown_request_to_sector_requests(mem_fetch *mf) {
for (unsigned k = i * SECTOR_SIZE; k < (i + 1) * SECTOR_SIZE; k++) {
mask.set(k);
}
- mem_fetch *n_mf = m_mf_allocator->alloc(mf->get_addr() + SECTOR_SIZE * i,
- mf->get_access_type(),mf->get_access_warp_mask(),
- mf->get_access_byte_mask() & mask,std::bitset<SECTOR_CHUNCK_SIZE>().set(i),
- SECTOR_SIZE,mf->is_write(),m_gpu->gpu_tot_sim_cycle + m_gpu->gpu_sim_cycle,
- mf->get_wid(),mf->get_sid(), mf->get_tpc(),mf);
+ mem_fetch *n_mf = m_mf_allocator->alloc(
+ mf->get_addr() + SECTOR_SIZE * i, mf->get_access_type(),
+ mf->get_access_warp_mask(), mf->get_access_byte_mask() & mask,
+ std::bitset<SECTOR_CHUNCK_SIZE>().set(i), SECTOR_SIZE,
+ mf->is_write(), m_gpu->gpu_tot_sim_cycle + m_gpu->gpu_sim_cycle,
+ mf->get_wid(), mf->get_sid(), mf->get_tpc(), mf);
result.push_back(n_mf);
}
diff --git a/src/gpgpu-sim/l2cache.h b/src/gpgpu-sim/l2cache.h
index 59432b8..beed765 100644
--- a/src/gpgpu-sim/l2cache.h
+++ b/src/gpgpu-sim/l2cache.h
@@ -52,13 +52,12 @@ class partition_mf_allocator : public mem_fetch_allocator {
unsigned size, bool wr,
unsigned long long cycle) const;
virtual mem_fetch *alloc(new_addr_type addr, mem_access_type type,
- const active_mask_t &active_mask,
- const mem_access_byte_mask_t &byte_mask,
- const mem_access_sector_mask_t &sector_mask,
- unsigned size, bool wr,
- unsigned long long cycle,
- unsigned wid, unsigned sid,
- unsigned tpc, mem_fetch *original_mf) const;
+ const active_mask_t &active_mask,
+ const mem_access_byte_mask_t &byte_mask,
+ const mem_access_sector_mask_t &sector_mask,
+ unsigned size, bool wr, unsigned long long cycle,
+ unsigned wid, unsigned sid, unsigned tpc,
+ mem_fetch *original_mf) const;
private:
const memory_config *m_memory_config;
diff --git a/src/gpgpu-sim/shader.cc b/src/gpgpu-sim/shader.cc
index 51366de..c65affd 100644
--- a/src/gpgpu-sim/shader.cc
+++ b/src/gpgpu-sim/shader.cc
@@ -62,21 +62,19 @@ mem_fetch *shader_core_mem_fetch_allocator::alloc(
return mf;
}
-mem_fetch *shader_core_mem_fetch_allocator::alloc(new_addr_type addr, mem_access_type type,
- const active_mask_t &active_mask,
- const mem_access_byte_mask_t &byte_mask,
- const mem_access_sector_mask_t &sector_mask,
- unsigned size, bool wr,
- unsigned long long cycle,
- unsigned wid, unsigned sid,
- unsigned tpc, mem_fetch *original_mf) const {
- mem_access_t access(type, addr, size, wr, active_mask, byte_mask,
- sector_mask, m_memory_config->gpgpu_ctx);
- mem_fetch *mf =
- new mem_fetch(access, NULL, wr ? WRITE_PACKET_SIZE : READ_PACKET_SIZE, wid,
- m_core_id, m_cluster_id, m_memory_config, cycle,original_mf);
- return mf;
- }
+mem_fetch *shader_core_mem_fetch_allocator::alloc(
+ new_addr_type addr, mem_access_type type, const active_mask_t &active_mask,
+ const mem_access_byte_mask_t &byte_mask,
+ const mem_access_sector_mask_t &sector_mask, unsigned size, bool wr,
+ unsigned long long cycle, unsigned wid, unsigned sid, unsigned tpc,
+ mem_fetch *original_mf) const {
+ mem_access_t access(type, addr, size, wr, active_mask, byte_mask, sector_mask,
+ m_memory_config->gpgpu_ctx);
+ mem_fetch *mf = new mem_fetch(
+ access, NULL, wr ? WRITE_PACKET_SIZE : READ_PACKET_SIZE, wid, m_core_id,
+ m_cluster_id, m_memory_config, cycle, original_mf);
+ return mf;
+}
/////////////////////////////////////////////////////////////////////////////
std::list<unsigned> shader_core_ctx::get_regs_written(const inst_t &fvt) const {
@@ -142,8 +140,8 @@ void shader_core_ctx::create_front_pipeline() {
m_pipeline_reg[ID_OC_INT].get_size());
for (int j = 0; j < m_config->m_specialized_unit.size(); j++) {
if (m_config->m_specialized_unit[j].num_units > 0)
- assert(m_config->gpgpu_num_sched_per_core ==
- m_config->m_specialized_unit[j].id_oc_spec_reg_width);
+ assert(m_config->gpgpu_num_sched_per_core ==
+ m_config->m_specialized_unit[j].id_oc_spec_reg_width);
}
}
@@ -187,15 +185,18 @@ void shader_core_ctx::create_schedulers() {
// must currently occur after all inputs have been initialized.
std::string sched_config = m_config->gpgpu_scheduler_string;
const concrete_scheduler scheduler =
- sched_config.find("lrr") != std::string::npos ? CONCRETE_SCHEDULER_LRR
- : sched_config.find("two_level_active") != std::string::npos
- ? CONCRETE_SCHEDULER_TWO_LEVEL_ACTIVE
- : sched_config.find("gto") != std::string::npos ? CONCRETE_SCHEDULER_GTO
- : sched_config.find("old") != std::string::npos
- ? CONCRETE_SCHEDULER_OLDEST_FIRST
- : sched_config.find("warp_limiting") != std::string::npos
- ? CONCRETE_SCHEDULER_WARP_LIMITING
- : NUM_CONCRETE_SCHEDULERS;
+ sched_config.find("lrr") != std::string::npos
+ ? CONCRETE_SCHEDULER_LRR
+ : sched_config.find("two_level_active") != std::string::npos
+ ? CONCRETE_SCHEDULER_TWO_LEVEL_ACTIVE
+ : sched_config.find("gto") != std::string::npos
+ ? CONCRETE_SCHEDULER_GTO
+ : sched_config.find("old") != std::string::npos
+ ? CONCRETE_SCHEDULER_OLDEST_FIRST
+ : sched_config.find("warp_limiting") !=
+ std::string::npos
+ ? CONCRETE_SCHEDULER_WARP_LIMITING
+ : NUM_CONCRETE_SCHEDULERS;
assert(scheduler != NUM_CONCRETE_SCHEDULERS);
for (unsigned i = 0; i < m_config->gpgpu_num_sched_per_core; i++) {
@@ -1246,20 +1247,21 @@ void scheduler_unit::cycle() {
previous_issued_inst_exec_type = exec_unit_type_t::MEM;
}
} else {
-
// This code need to be refactored
if (pI->op != TENSOR_CORE_OP && pI->op != SFU_OP &&
pI->op != DP_OP && !(pI->op >= SPEC_UNIT_START_ID)) {
bool execute_on_SP = false;
bool execute_on_INT = false;
- bool sp_pipe_avail =
- (m_shader->m_config->gpgpu_num_sp_units > 0) &&
- m_sp_out->has_free(m_shader->m_config->sub_core_model, m_id);
- bool int_pipe_avail =
- (m_shader->m_config->gpgpu_num_int_units > 0) &&
- m_int_out->has_free(m_shader->m_config->sub_core_model, m_id);
-
+ bool sp_pipe_avail =
+ (m_shader->m_config->gpgpu_num_sp_units > 0) &&
+ m_sp_out->has_free(m_shader->m_config->sub_core_model,
+ m_id);
+ bool int_pipe_avail =
+ (m_shader->m_config->gpgpu_num_int_units > 0) &&
+ m_int_out->has_free(m_shader->m_config->sub_core_model,
+ m_id);
+
// if INT unit pipline exist, then execute ALU and INT
// operations on INT unit and SP-FPU on SP unit (like in Volta)
// if INT unit pipline does not exist, then execute all ALU, INT
@@ -1320,10 +1322,10 @@ void scheduler_unit::cycle() {
(pI->op == DP_OP) &&
!(diff_exec_units && previous_issued_inst_exec_type ==
exec_unit_type_t::DP)) {
-
bool dp_pipe_avail =
- (m_shader->m_config->gpgpu_num_dp_units > 0) &&
- m_dp_out->has_free(m_shader->m_config->sub_core_model, m_id);
+ (m_shader->m_config->gpgpu_num_dp_units > 0) &&
+ m_dp_out->has_free(m_shader->m_config->sub_core_model,
+ m_id);
if (dp_pipe_avail) {
m_shader->issue_warp(*m_dp_out, pI, active_mask, warp_id,
@@ -1340,10 +1342,10 @@ void scheduler_unit::cycle() {
(pI->op == SFU_OP) || (pI->op == ALU_SFU_OP)) &&
!(diff_exec_units && previous_issued_inst_exec_type ==
exec_unit_type_t::SFU)) {
-
bool sfu_pipe_avail =
- (m_shader->m_config->gpgpu_num_sfu_units > 0) &&
- m_sfu_out->has_free(m_shader->m_config->sub_core_model, m_id);
+ (m_shader->m_config->gpgpu_num_sfu_units > 0) &&
+ m_sfu_out->has_free(m_shader->m_config->sub_core_model,
+ m_id);
if (sfu_pipe_avail) {
m_shader->issue_warp(*m_sfu_out, pI, active_mask, warp_id,
@@ -1356,11 +1358,10 @@ void scheduler_unit::cycle() {
} else if ((pI->op == TENSOR_CORE_OP) &&
!(diff_exec_units && previous_issued_inst_exec_type ==
exec_unit_type_t::TENSOR)) {
-
bool tensor_core_pipe_avail =
- (m_shader->m_config->gpgpu_num_tensor_core_units > 0) &&
- m_tensor_core_out->has_free(
- m_shader->m_config->sub_core_model, m_id);
+ (m_shader->m_config->gpgpu_num_tensor_core_units > 0) &&
+ m_tensor_core_out->has_free(
+ m_shader->m_config->sub_core_model, m_id);
if (tensor_core_pipe_avail) {
m_shader->issue_warp(*m_tensor_core_out, pI, active_mask,
@@ -2007,8 +2008,10 @@ void ldst_unit::L1_latency_queue_cycle() {
l1_latency_queue[j][0] = NULL;
if (m_config->m_L1D_config.get_write_policy() != WRITE_THROUGH &&
mf_next->get_inst().is_store() &&
- (m_config->m_L1D_config.get_write_allocate_policy() == FETCH_ON_WRITE ||
- m_config->m_L1D_config.get_write_allocate_policy() == LAZY_FETCH_ON_READ) &&
+ (m_config->m_L1D_config.get_write_allocate_policy() ==
+ FETCH_ON_WRITE ||
+ m_config->m_L1D_config.get_write_allocate_policy() ==
+ LAZY_FETCH_ON_READ) &&
!was_writeallocate_sent(events)) {
unsigned dec_ack =
(m_config->m_L1D_config.get_mshr_type() == SECTOR_ASSOC)
@@ -2316,7 +2319,7 @@ void dp_unit ::issue(register_set &source_reg) {
}
void specialized_unit ::issue(register_set &source_reg) {
- warp_inst_t **ready_reg =
+ warp_inst_t **ready_reg =
source_reg.get_ready(m_config->sub_core_model, m_issue_reg_id);
// m_core->incexecstat((*ready_reg));
(*ready_reg)->op_pipe = SPECIALIZED__OP;
@@ -3349,15 +3352,15 @@ unsigned int shader_core_config::max_cta(const kernel_info_t &k) const {
unsigned max_assoc = m_L1D_config.get_max_assoc();
for (std::vector<unsigned>::const_iterator it = shmem_opt_list.begin();
- it < shmem_opt_list.end(); it++) {
+ it < shmem_opt_list.end(); it++) {
if (total_shmem <= *it) {
- float l1_ratio = 1 - ((float) *(it) / total_unified);
+ float l1_ratio = 1 - ((float)*(it) / total_unified);
m_L1D_config.set_assoc(max_assoc * l1_ratio);
l1d_configured = true;
break;
}
}
-
+
assert(l1d_configured && "no shared memory option found");
break;
}
@@ -3365,16 +3368,16 @@ unsigned int shader_core_config::max_cta(const kernel_info_t &k) const {
assert(0);
}
- if(m_L1D_config.is_streaming()) {
- //for streaming cache, if the whole memory is allocated
- //to the L1 cache, then make the allocation to be on_MISS
- //otherwise, make it ON_FILL to eliminate line allocation fails
- //i.e. MSHR throughput is the same, independent on the L1 cache size/associativity
- if(total_shmem == 0) {
+ if (m_L1D_config.is_streaming()) {
+ // for streaming cache, if the whole memory is allocated
+ // to the L1 cache, then make the allocation to be on_MISS
+ // otherwise, make it ON_FILL to eliminate line allocation fails
+ // i.e. MSHR throughput is the same, independent on the L1 cache
+ // size/associativity
+ if (total_shmem == 0) {
m_L1D_config.set_allocation_policy(ON_MISS);
printf("GPGPU-Sim: Reconfigure L1 allocation to ON_MISS\n");
- }
- else {
+ } else {
m_L1D_config.set_allocation_policy(ON_FILL);
printf("GPGPU-Sim: Reconfigure L1 allocation to ON_FILL\n");
}
diff --git a/src/gpgpu-sim/shader.h b/src/gpgpu-sim/shader.h
index 8662313..2d2f051 100644
--- a/src/gpgpu-sim/shader.h
+++ b/src/gpgpu-sim/shader.h
@@ -1496,8 +1496,8 @@ class shader_core_config : public core_config {
break; // we only accept continuous specialized_units, i.e., 1,2,3,4
}
- //parse gpgpu_shmem_option for adpative cache config
- if(adaptive_cache_config) {
+ // parse gpgpu_shmem_option for adpative cache config
+ if (adaptive_cache_config) {
for (unsigned i = 0; i < strlen(gpgpu_shmem_option); i++) {
char option[4];
int j = 0;
@@ -1520,7 +1520,6 @@ class shader_core_config : public core_config {
}
std::sort(shmem_opt_list.begin(), shmem_opt_list.end());
}
-
}
void reg_options(class OptionParser *opp);
unsigned max_cta(const kernel_info_t &k) const;
@@ -1899,13 +1898,11 @@ class shader_core_mem_fetch_allocator : public mem_fetch_allocator {
mem_fetch *alloc(new_addr_type addr, mem_access_type type, unsigned size,
bool wr, unsigned long long cycle) const;
mem_fetch *alloc(new_addr_type addr, mem_access_type type,
- const active_mask_t &active_mask,
- const mem_access_byte_mask_t &byte_mask,
- const mem_access_sector_mask_t &sector_mask,
- unsigned size, bool wr,
- unsigned long long cycle,
- unsigned wid, unsigned sid,
- unsigned tpc, mem_fetch *original_mf) const;
+ const active_mask_t &active_mask,
+ const mem_access_byte_mask_t &byte_mask,
+ const mem_access_sector_mask_t &sector_mask, unsigned size,
+ bool wr, unsigned long long cycle, unsigned wid,
+ unsigned sid, unsigned tpc, mem_fetch *original_mf) const;
mem_fetch *alloc(const warp_inst_t &inst, const mem_access_t &access,
unsigned long long cycle) const {
warp_inst_t inst_copy = inst;