summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJRPAN <[email protected]>2021-05-31 15:55:18 -0400
committerJRPAN <[email protected]>2021-05-31 15:55:18 -0400
commit110aeb12257b030b32cdc47e4cca0ed1089ac855 (patch)
tree8d157bea16f882fc0ff081f1456ab02ba769bad8 /src
parent6ad461a95ac71e0597274c4f750ce03bb3a6871e (diff)
rewrite shmem_option parsing
Diffstat (limited to 'src')
-rw-r--r--src/gpgpu-sim/shader.h24
1 files changed, 5 insertions, 19 deletions
diff --git a/src/gpgpu-sim/shader.h b/src/gpgpu-sim/shader.h
index 2d2f051..4c6de06 100644
--- a/src/gpgpu-sim/shader.h
+++ b/src/gpgpu-sim/shader.h
@@ -1498,25 +1498,11 @@ class shader_core_config : public core_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;
- 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::stringstream ss(gpgpu_shmem_option);
+ while (ss.good()) {
+ std::string option;
+ std::getline(ss, option, ',');
+ shmem_opt_list.push_back((unsigned)std::stoi(option) * 1024);
}
std::sort(shmem_opt_list.begin(), shmem_opt_list.end());
}