[gem5-dev] Change in gem5/gem5[hotfix-vector-stats]: base-stats: fix storage initializing

2021-09-22 Thread Bobby R. Bruce (Gerrit) via gem5-dev
Bobby R. Bruce has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/50747 )


Change subject: base-stats: fix storage initializing
..

base-stats: fix storage initializing

Commit (70194795c3f41cc3f1e361b3cac24f839d86dd67) introduced std::vector  
with resize() to initializing all storages. This method caused data  
duplication in statistics. Storage is now initialized using loops.


Change-Id: I4350863a83671fc10cc02b5cb7d3b38e6cf4f565
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/50747
Reviewed-by: Bobby R. Bruce 
Reviewed-by: Hoa Nguyen 
Maintainer: Bobby R. Bruce 
Tested-by: kokoro 
---
M src/base/statistics.hh
1 file changed, 12 insertions(+), 3 deletions(-)

Approvals:
  Hoa Nguyen: Looks good to me, approved
  Bobby R. Bruce: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/base/statistics.hh b/src/base/statistics.hh
index 18f52cb..8fc71eb 100644
--- a/src/base/statistics.hh
+++ b/src/base/statistics.hh
@@ -952,7 +952,10 @@
 fatal_if(s <= 0, "Storage size must be positive");
 fatal_if(check(), "Stat has already been initialized");

-storage.resize(s, new Storage(this->info()->getStorageParams()));
+storage.reserve(s);
+for (size_type i = 0; i < s; ++i)
+storage.push_back(new  
Storage(this->info()->getStorageParams()));

+
 this->setInit();
 }

@@ -1178,7 +1181,10 @@
 info->x = _x;
 info->y = _y;

-storage.resize(x * y, new Storage(info->getStorageParams()));
+storage.reserve(x * y);
+for (size_type i = 0; i < x * y; ++i)
+storage.push_back(new  
Storage(this->info()->getStorageParams()));

+
 this->setInit();

 return self;
@@ -1387,7 +1393,10 @@
 fatal_if(s <= 0, "Storage size must be positive");
 fatal_if(check(), "Stat has already been initialized");

-storage.resize(s, new Storage(this->info()->getStorageParams()));
+storage.reserve(s);
+for (size_type i = 0; i < s; ++i)
+storage.push_back(new  
Storage(this->info()->getStorageParams()));

+
 this->setInit();
 }


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/50747
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: hotfix-vector-stats
Gerrit-Change-Id: I4350863a83671fc10cc02b5cb7d3b38e6cf4f565
Gerrit-Change-Number: 50747
Gerrit-PatchSet: 2
Gerrit-Owner: Bobby R. Bruce 
Gerrit-Reviewer: Bobby R. Bruce 
Gerrit-Reviewer: Hoa Nguyen 
Gerrit-Reviewer: kokoro 
Gerrit-CC: Meng Chen 
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

[gem5-dev] Change in gem5/gem5[hotfix-vector-stats]: base-stats: fix storage initializing

2021-09-21 Thread Bobby R. Bruce (Gerrit) via gem5-dev
Bobby R. Bruce has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/50747 )



Change subject: base-stats: fix storage initializing
..

base-stats: fix storage initializing

Commit (70194795c3f41cc3f1e361b3cac24f839d86dd67) introduced std::vector  
with resize() to initializing all storages. This method caused data  
duplication in statistics. Storage is now initialized using loops.


Change-Id: I4350863a83671fc10cc02b5cb7d3b38e6cf4f565
---
M src/base/statistics.hh
1 file changed, 12 insertions(+), 3 deletions(-)



diff --git a/src/base/statistics.hh b/src/base/statistics.hh
index 18f52cb..8fc71eb 100644
--- a/src/base/statistics.hh
+++ b/src/base/statistics.hh
@@ -952,7 +952,10 @@
 fatal_if(s <= 0, "Storage size must be positive");
 fatal_if(check(), "Stat has already been initialized");

-storage.resize(s, new Storage(this->info()->getStorageParams()));
+storage.reserve(s);
+for (size_type i = 0; i < s; ++i)
+storage.push_back(new  
Storage(this->info()->getStorageParams()));

+
 this->setInit();
 }

@@ -1178,7 +1181,10 @@
 info->x = _x;
 info->y = _y;

-storage.resize(x * y, new Storage(info->getStorageParams()));
+storage.reserve(x * y);
+for (size_type i = 0; i < x * y; ++i)
+storage.push_back(new  
Storage(this->info()->getStorageParams()));

+
 this->setInit();

 return self;
@@ -1387,7 +1393,10 @@
 fatal_if(s <= 0, "Storage size must be positive");
 fatal_if(check(), "Stat has already been initialized");

-storage.resize(s, new Storage(this->info()->getStorageParams()));
+storage.reserve(s);
+for (size_type i = 0; i < s; ++i)
+storage.push_back(new  
Storage(this->info()->getStorageParams()));

+
 this->setInit();
 }


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/50747
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: hotfix-vector-stats
Gerrit-Change-Id: I4350863a83671fc10cc02b5cb7d3b38e6cf4f565
Gerrit-Change-Number: 50747
Gerrit-PatchSet: 1
Gerrit-Owner: Bobby R. Bruce 
Gerrit-CC: Meng Chen 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s