From 24ffab25f41d76b94fd2012a8897312a73a7165f Mon Sep 17 00:00:00 2001 From: "Mahmoud Khairy A. Abdallah" Date: Wed, 19 May 2021 21:17:40 -0400 Subject: moving shmem option to the base class and change the code to accept turing config --- src/abstract_hardware_model.h | 1 + src/gpgpu-sim/gpu-cache.h | 3 +-- src/gpgpu-sim/shader.cc | 46 +++++++++---------------------------------- src/gpgpu-sim/shader.h | 26 ++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/abstract_hardware_model.h b/src/abstract_hardware_model.h index 17a1cec..b33c50b 100644 --- a/src/abstract_hardware_model.h +++ b/src/abstract_hardware_model.h @@ -374,6 +374,7 @@ class core_config { unsigned mem_warp_parts; mutable unsigned gpgpu_shmem_size; char *gpgpu_shmem_option; + std::vector shmem_opt_list; unsigned gpgpu_shmem_sizeDefault; unsigned gpgpu_shmem_sizePrefL1; unsigned gpgpu_shmem_sizePrefShared; diff --git a/src/gpgpu-sim/gpu-cache.h b/src/gpgpu-sim/gpu-cache.h index d801528..26ed621 100644 --- a/src/gpgpu-sim/gpu-cache.h +++ b/src/gpgpu-sim/gpu-cache.h @@ -577,6 +577,7 @@ class cache_config { } // set * assoc * cacheline size. Then convert Byte to KB + // gpgpu_unified_cache_size is in KB while original_sz is in B unsigned original_size = m_nset * m_assoc * m_line_sz / 1024; if (m_unified_cache_size > 0) { max_cache_multiplier = m_unified_cache_size / original_size; @@ -785,12 +786,10 @@ class cache_config { } unsigned get_max_num_lines() const { assert(m_valid); - // gpgpu_unified_cache_size is in KB while original_sz is in B return max_cache_multiplier * m_nset * original_m_assoc; } unsigned get_max_assoc() const { assert(m_valid); - // gpgpu_unified_cache_size is in KB while original_sz is in B return max_cache_multiplier * original_m_assoc; } void print(FILE *fp) const { diff --git a/src/gpgpu-sim/shader.cc b/src/gpgpu-sim/shader.cc index 75fbe16..bc747d6 100644 --- a/src/gpgpu-sim/shader.cc +++ b/src/gpgpu-sim/shader.cc @@ -3334,56 +3334,28 @@ unsigned int shader_core_config::max_cta(const kernel_info_t &k) const { if (adaptive_cache_config && !k.cache_config_set) { // For more info about adaptive cache, see // https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#shared-memory-7-x - std::vector shmem_list; - for (unsigned i = 0; i < strlen(gpgpu_shmem_option); i++) { - char option[4]; - int j = 0; - while (gpgpu_shmem_option[i] != ',' && i < strlen(gpgpu_shmem_option)) { - if (gpgpu_shmem_option[i] == ' ') { - // skip spaces - i++; - } else { - if (!isdigit(gpgpu_shmem_option[i])) { - // check for non digits, which should not be here - assert(0 && "invalid config: -gpgpu_shmem_option"); - } - option[j] = gpgpu_shmem_option[i]; - j++; - i++; - } - } - // convert KB -> B - shmem_list.push_back((unsigned)atoi(option) * 1024); - } - unsigned total_shmem = kernel_info->smem * result; // Unified cache config is in KB. Converting to B unsigned total_unified = m_L1D_config.m_unified_cache_size * 1024; - std::sort(shmem_list.begin(), shmem_list.end()); - assert(total_shmem >= 0 && total_shmem <= shmem_list.back()); + assert(total_shmem >= 0 && total_shmem <= shmem_opt_list.back()); switch (adaptive_cache_config) { case FIXED: break; case ADAPTIVE_CACHE: { - // For more info about adaptive cache, see bool l1d_configured = false; unsigned max_assoc = m_L1D_config.get_max_assoc(); - if (total_shmem == 0) { - m_L1D_config.set_assoc(max_assoc); - l1d_configured = true; - } else { - for (std::vector::iterator it = shmem_list.begin(); - it < shmem_list.end() - 1; it++) { - if (total_shmem > *it && total_shmem <= *(it + 1)) { - float l1_ratio = 1 - (float) *(it + 1) / total_unified; - m_L1D_config.set_assoc(max_assoc * l1_ratio); - l1d_configured = true; - break; - } + for (std::vector::const_iterator it = shmem_opt_list.begin(); + it < shmem_opt_list.end(); it++) { + if (total_shmem <= *it) { + 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; } diff --git a/src/gpgpu-sim/shader.h b/src/gpgpu-sim/shader.h index a7a2c02..42bbdcb 100644 --- a/src/gpgpu-sim/shader.h +++ b/src/gpgpu-sim/shader.h @@ -1495,6 +1495,32 @@ class shader_core_config : public core_config { } else 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) { + for (unsigned i = 0; i < strlen(gpgpu_shmem_option); i++) { + char option[4]; + int j = 0; + while (gpgpu_shmem_option[i] != ',' && i < strlen(gpgpu_shmem_option)) { + if (gpgpu_shmem_option[i] == ' ') { + // skip spaces + i++; + } else { + if (!isdigit(gpgpu_shmem_option[i])) { + // check for non digits, which should not be here + assert(0 && "invalid config: -gpgpu_shmem_option"); + } + option[j] = gpgpu_shmem_option[i]; + j++; + i++; + } + } + // convert KB -> B + shmem_opt_list.push_back((unsigned)atoi(option) * 1024); + } + 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; -- cgit v1.3 From fedcde3789f7921647caee184c0fa104403c848d Mon Sep 17 00:00:00 2001 From: "Mahmoud Khairy A. Abdallah" Date: Wed, 19 May 2021 21:42:29 -0400 Subject: moving the unified size from the base class config to l1 config --- src/gpgpu-sim/gpu-cache.h | 30 ++++++++++++++++-------------- src/gpgpu-sim/shader.cc | 3 ++- 2 files changed, 18 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/gpgpu-sim/gpu-cache.h b/src/gpgpu-sim/gpu-cache.h index 26ed621..8bd62da 100644 --- a/src/gpgpu-sim/gpu-cache.h +++ b/src/gpgpu-sim/gpu-cache.h @@ -575,15 +575,6 @@ class cache_config { } exit_parse_error(); } - - // set * assoc * cacheline size. Then convert Byte to KB - // gpgpu_unified_cache_size is in KB while original_sz is in B - unsigned original_size = m_nset * m_assoc * m_line_sz / 1024; - if (m_unified_cache_size > 0) { - max_cache_multiplier = m_unified_cache_size / original_size; - } else { - max_cache_multiplier = MAX_DEFAULT_CACHE_SIZE_MULTIBLIER; - } switch (ct) { case 'N': @@ -694,7 +685,6 @@ class cache_config { m_sector_sz_log2 = LOGB2(SECTOR_SIZE); original_m_assoc = m_assoc; - // For more details about difference between FETCH_ON_WRITE and WRITE // VALIDAE policies Read: Jouppi, Norman P. "Cache write policies and // performance". ISCA 93. WRITE_ALLOCATE is the old write policy in @@ -786,11 +776,11 @@ class cache_config { } unsigned get_max_num_lines() const { assert(m_valid); - return max_cache_multiplier * m_nset * original_m_assoc; + return get_max_cache_multiplier() * m_nset * original_m_assoc; } unsigned get_max_assoc() const { assert(m_valid); - return max_cache_multiplier * original_m_assoc; + return get_max_cache_multiplier() * original_m_assoc; } void print(FILE *fp) const { fprintf(fp, "Size = %d B (%d Set x %d-way x %d byte line)\n", @@ -799,6 +789,8 @@ 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;} + unsigned hash_function(new_addr_type addr, unsigned m_nset, unsigned m_line_sz_log2, unsigned m_nset_log2, unsigned m_index_function) const; @@ -840,7 +832,6 @@ class cache_config { char *m_config_stringPrefL1; char *m_config_stringPrefShared; FuncCache cache_status; - unsigned m_unified_cache_size; unsigned m_wr_percent; write_allocate_policy_t get_write_allocate_policy() { return m_write_alloc_policy; @@ -867,7 +858,6 @@ class cache_config { unsigned m_sector_sz_log2; unsigned original_m_assoc; bool m_is_streaming; - unsigned max_cache_multiplier; enum replacement_policy_t m_replacement_policy; // 'L' = LRU, 'F' = FIFO enum write_policy_t @@ -922,6 +912,18 @@ class l1d_cache_config : public cache_config { unsigned l1_banks_byte_interleaving; 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; + } + } }; class l2_cache_config : public cache_config { diff --git a/src/gpgpu-sim/shader.cc b/src/gpgpu-sim/shader.cc index bc747d6..7f27b7b 100644 --- a/src/gpgpu-sim/shader.cc +++ b/src/gpgpu-sim/shader.cc @@ -3335,10 +3335,11 @@ unsigned int shader_core_config::max_cta(const kernel_info_t &k) const { // For more info about adaptive cache, see // https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#shared-memory-7-x unsigned total_shmem = kernel_info->smem * result; + assert(total_shmem >= 0 && total_shmem <= shmem_opt_list.back()); + // Unified cache config is in KB. Converting to B unsigned total_unified = m_L1D_config.m_unified_cache_size * 1024; - assert(total_shmem >= 0 && total_shmem <= shmem_opt_list.back()); switch (adaptive_cache_config) { case FIXED: break; -- cgit v1.3 From 8aee56d7401af9a91a1de3adae1b61329e0d30e5 Mon Sep 17 00:00:00 2001 From: "Mahmoud Khairy A. Abdallah" Date: Wed, 19 May 2021 22:10:53 -0400 Subject: rename set_dirty_byte_mask --- src/gpgpu-sim/gpu-cache.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/gpgpu-sim/gpu-cache.h b/src/gpgpu-sim/gpu-cache.h index 8bd62da..91cde7e 100644 --- a/src/gpgpu-sim/gpu-cache.h +++ b/src/gpgpu-sim/gpu-cache.h @@ -210,13 +210,13 @@ struct line_cache_block : public cache_block_t { m_status = status; } virtual void set_byte_mask(mem_fetch *mf) { - m_byte_mask = m_byte_mask | mf->get_access_byte_mask(); + m_dirty_byte_mask = m_dirty_byte_mask | mf->get_access_byte_mask(); } virtual void set_byte_mask(mem_access_byte_mask_t byte_mask) { - m_byte_mask = m_byte_mask | byte_mask; + m_dirty_byte_mask = m_dirty_byte_mask | byte_mask; } virtual mem_access_byte_mask_t get_dirty_byte_mask() { - return m_byte_mask; + return m_dirty_byte_mask; } virtual mem_access_sector_mask_t get_dirty_sector_mask() { mem_access_sector_mask_t sector_mask; @@ -270,7 +270,7 @@ struct line_cache_block : public cache_block_t { bool m_set_readable_on_fill; bool m_set_byte_mask_on_fill; bool m_readable; - mem_access_byte_mask_t m_byte_mask; + mem_access_byte_mask_t m_dirty_byte_mask; }; struct sector_cache_block : public cache_block_t { @@ -290,7 +290,7 @@ struct sector_cache_block : public cache_block_t { m_line_alloc_time = 0; m_line_last_access_time = 0; m_line_fill_time = 0; - m_byte_mask.reset(); + m_dirty_byte_mask.reset(); } virtual void allocate(new_addr_type tag, new_addr_type block_addr, @@ -405,13 +405,13 @@ struct sector_cache_block : public cache_block_t { } virtual void set_byte_mask(mem_fetch *mf) { - m_byte_mask = m_byte_mask | mf->get_access_byte_mask(); + m_dirty_byte_mask = m_dirty_byte_mask | mf->get_access_byte_mask(); } virtual void set_byte_mask(mem_access_byte_mask_t byte_mask) { - m_byte_mask = m_byte_mask | byte_mask; + m_dirty_byte_mask = m_dirty_byte_mask | byte_mask; } virtual mem_access_byte_mask_t get_dirty_byte_mask() { - return m_byte_mask; + return m_dirty_byte_mask; } virtual mem_access_sector_mask_t get_dirty_sector_mask() { mem_access_sector_mask_t sector_mask; @@ -492,7 +492,7 @@ struct sector_cache_block : public cache_block_t { bool m_set_readable_on_fill[SECTOR_CHUNCK_SIZE]; bool m_set_byte_mask_on_fill; bool m_readable[SECTOR_CHUNCK_SIZE]; - mem_access_byte_mask_t m_byte_mask; + mem_access_byte_mask_t m_dirty_byte_mask; unsigned get_sector_index(mem_access_sector_mask_t sector_mask) { assert(sector_mask.count() == 1); -- cgit v1.3 From b466afea67e6d6faf49f01ecfe378257fbdb93af Mon Sep 17 00:00:00 2001 From: "Mahmoud Khairy A. Abdallah" Date: Wed, 19 May 2021 22:20:04 -0400 Subject: eliminate redundant code in gpu-cache.h --- src/gpgpu-sim/gpu-cache.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src') diff --git a/src/gpgpu-sim/gpu-cache.h b/src/gpgpu-sim/gpu-cache.h index 91cde7e..6698d92 100644 --- a/src/gpgpu-sim/gpu-cache.h +++ b/src/gpgpu-sim/gpu-cache.h @@ -596,16 +596,6 @@ class cache_config { default: exit_parse_error(); } - switch (rp) { - case 'L': - m_replacement_policy = LRU; - break; - case 'F': - m_replacement_policy = FIFO; - break; - default: - exit_parse_error(); - } switch (wp) { case 'R': m_write_policy = READ_ONLY; -- cgit v1.3