summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMahmoud Khairy A. Abdallah <[email protected]>2021-05-19 21:17:40 -0400
committerMahmoud Khairy A. Abdallah <[email protected]>2021-05-19 21:17:40 -0400
commit24ffab25f41d76b94fd2012a8897312a73a7165f (patch)
treed6467d667874565a61d92aeb91214bf661ed77af /src
parente3d186bbeade78dec776989ccec2a0c0aea27fb4 (diff)
moving shmem option to the base class and change the code to accept turing config
Diffstat (limited to 'src')
-rw-r--r--src/abstract_hardware_model.h1
-rw-r--r--src/gpgpu-sim/gpu-cache.h3
-rw-r--r--src/gpgpu-sim/shader.cc46
-rw-r--r--src/gpgpu-sim/shader.h26
4 files changed, 37 insertions, 39 deletions
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<unsigned> 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<unsigned> 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<unsigned>::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<unsigned>::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;