summaryrefslogtreecommitdiff
path: root/src/base/stats
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2008-10-09 04:58:23 -0700
committerNathan Binkert <nate@binkert.org>2008-10-09 04:58:23 -0700
commit7cc2a88038ccfd828a0caa7aa9d1b758d096d37d (patch)
tree9f58474948f0d6dac4abb2e48cff075cdf6caa42 /src/base/stats
parenta52dce6d623f6cb289004d4af12be0769966dadf (diff)
downloadgem5-7cc2a88038ccfd828a0caa7aa9d1b758d096d37d.tar.xz
stats: use properly signed types for looping and comparison
Diffstat (limited to 'src/base/stats')
-rw-r--r--src/base/stats/mysql.cc26
-rw-r--r--src/base/stats/mysql.hh8
-rw-r--r--src/base/stats/text.cc38
-rw-r--r--src/base/stats/types.hh3
4 files changed, 39 insertions, 36 deletions
diff --git a/src/base/stats/mysql.cc b/src/base/stats/mysql.cc
index c3498dc60..8d263d2b9 100644
--- a/src/base/stats/mysql.cc
+++ b/src/base/stats/mysql.cc
@@ -568,7 +568,7 @@ MySql::configure(const VectorData &data)
InsertSubData subdata;
subdata.stat = statid;
subdata.y = 0;
- for (int i = 0; i < data.subnames.size(); ++i) {
+ for (off_type i = 0; i < data.subnames.size(); ++i) {
subdata.x = i;
subdata.name = data.subnames[i];
subdata.descr = data.subdescs.empty() ? "" : data.subdescs[i];
@@ -615,7 +615,7 @@ MySql::configure(const VectorDistData &data)
InsertSubData subdata;
subdata.stat = statid;
subdata.y = 0;
- for (int i = 0; i < data.subnames.size(); ++i) {
+ for (off_type i = 0; i < data.subnames.size(); ++i) {
subdata.x = i;
subdata.name = data.subnames[i];
subdata.descr = data.subdescs.empty() ? "" : data.subdescs[i];
@@ -639,7 +639,7 @@ MySql::configure(const Vector2dData &data)
InsertSubData subdata;
subdata.stat = statid;
subdata.y = -1;
- for (int i = 0; i < data.subnames.size(); ++i) {
+ for (off_type i = 0; i < data.subnames.size(); ++i) {
subdata.x = i;
subdata.name = data.subnames[i];
subdata.descr = data.subdescs.empty() ? "" : data.subdescs[i];
@@ -653,7 +653,7 @@ MySql::configure(const Vector2dData &data)
subdata.stat = statid;
subdata.x = -1;
subdata.descr = "";
- for (int i = 0; i < data.y_subnames.size(); ++i) {
+ for (off_type i = 0; i < data.y_subnames.size(); ++i) {
subdata.y = i;
subdata.name = data.y_subnames[i];
if (!subdata.name.empty())
@@ -760,8 +760,8 @@ MySql::output(const VectorData &data)
newdata.y = 0;
const VCounter &cvec = data.value();
- int size = data.size();
- for (int x = 0; x < size; x++) {
+ size_type size = data.size();
+ for (off_type x = 0; x < size; x++) {
newdata.x = x;
newdata.data = cvec[x];
newdata.insert();
@@ -808,8 +808,8 @@ MySql::output(const DistDataData &data)
newdata.data = data.overflow;
newdata.insert();
- int size = data.cvec.size();
- for (int x = 0; x < size; x++) {
+ size_type size = data.cvec.size();
+ for (off_type x = 0; x < size; x++) {
newdata.x = x;
newdata.data = data.cvec[x];
newdata.insert();
@@ -837,8 +837,8 @@ MySql::output(const VectorDistData &data)
newdata.stat = find(data.id);
- int size = data.data.size();
- for (int y = 0; y < size; ++y) {
+ size_type size = data.data.size();
+ for (off_type y = 0; y < size; ++y) {
newdata.y = y;
output(data.data[y]);
}
@@ -852,10 +852,10 @@ MySql::output(const Vector2dData &data)
newdata.stat = find(data.id);
- int index = 0;
- for (int x = 0; x < data.x; x++) {
+ off_type index = 0;
+ for (off_type x = 0; x < data.x; x++) {
newdata.x = x;
- for (int y = 0; y < data.y; y++) {
+ for (off_type y = 0; y < data.y; y++) {
newdata.y = y;
newdata.data = data.cvec[index++];
newdata.insert();
diff --git a/src/base/stats/mysql.hh b/src/base/stats/mysql.hh
index 5caac69de..6e47719ce 100644
--- a/src/base/stats/mysql.hh
+++ b/src/base/stats/mysql.hh
@@ -69,9 +69,9 @@ class InsertData
{
private:
char *query;
- int size;
+ size_type size;
bool first;
- static const int maxsize = 1024*1024;
+ static const size_type maxsize = 1024*1024;
public:
MySqlRun *run;
@@ -95,9 +95,9 @@ class InsertEvent
{
private:
char *query;
- int size;
+ size_type size;
bool first;
- static const int maxsize = 1024*1024;
+ static const size_type maxsize = 1024*1024;
typedef std::map<std::string, uint32_t> event_map_t;
event_map_t events;
diff --git a/src/base/stats/text.cc b/src/base/stats/text.cc
index a39bfe242..84336f5e4 100644
--- a/src/base/stats/text.cc
+++ b/src/base/stats/text.cc
@@ -239,11 +239,11 @@ struct VectorPrint
void
VectorPrint::operator()(std::ostream &stream) const
{
- int _size = vec.size();
+ size_type _size = vec.size();
Result _total = 0.0;
if (flags & (pdf | cdf)) {
- for (int i = 0; i < _size; ++i) {
+ for (off_type i = 0; i < _size; ++i) {
_total += vec[i];
}
}
@@ -266,7 +266,7 @@ VectorPrint::operator()(std::ostream &stream) const
print.value = vec[0];
print(stream);
} else if (!compat) {
- for (int i = 0; i < _size; ++i) {
+ for (off_type i = 0; i < _size; ++i) {
if (havesub && (i >= subnames.size() || subnames[i].empty()))
continue;
@@ -298,7 +298,7 @@ VectorPrint::operator()(std::ostream &stream) const
Result _cdf = 0.0;
if (flags & dist) {
ccprintf(stream, "%s.start_dist\n", name);
- for (int i = 0; i < _size; ++i) {
+ for (off_type i = 0; i < _size; ++i) {
print.name = havesub ? subnames[i] : to_string(i);
print.desc = subdescs.empty() ? desc : subdescs[i];
print.flags |= __substat;
@@ -318,7 +318,7 @@ VectorPrint::operator()(std::ostream &stream) const
}
ccprintf(stream, "%s.end_dist\n", name);
} else {
- for (int i = 0; i < _size; ++i) {
+ for (off_type i = 0; i < _size; ++i) {
if (havesub && subnames[i].empty())
continue;
@@ -366,7 +366,7 @@ struct DistPrint
Counter min;
Counter max;
Counter bucket_size;
- int size;
+ size_type size;
bool fancy;
void operator()(ostream &stream) const;
@@ -407,7 +407,7 @@ DistPrint::operator()(ostream &stream) const
Result total = 0.0;
total += underflow;
- for (int i = 0; i < size; ++i)
+ for (off_type i = 0; i < size; ++i)
total += vec[i];
total += overflow;
@@ -448,7 +448,7 @@ DistPrint::operator()(ostream &stream) const
}
if (!compat) {
- for (int i = 0; i < size; ++i) {
+ for (off_type i = 0; i < size; ++i) {
stringstream namestr;
namestr << name;
@@ -473,7 +473,7 @@ DistPrint::operator()(ostream &stream) const
print.flags = flags | __substat;
- for (int i = 0; i < size; ++i) {
+ for (off_type i = 0; i < size; ++i) {
if ((flags & nozero && vec[i] == 0.0) ||
(flags & nonan && isnan(vec[i])))
continue;
@@ -560,7 +560,7 @@ Text::visit(const VectorData &data)
if (noOutput(data))
return;
- int size = data.size();
+ size_type size = data.size();
VectorPrint print;
print.name = data.name;
@@ -573,11 +573,11 @@ Text::visit(const VectorData &data)
print.total = data.total();
if (!data.subnames.empty()) {
- for (int i = 0; i < size; ++i) {
+ for (off_type i = 0; i < size; ++i) {
if (!data.subnames[i].empty()) {
print.subnames = data.subnames;
print.subnames.resize(size);
- for (int i = 0; i < size; ++i) {
+ for (off_type i = 0; i < size; ++i) {
if (!data.subnames[i].empty() &&
!data.subdescs[i].empty()) {
print.subdescs = data.subdescs;
@@ -609,22 +609,22 @@ Text::visit(const Vector2dData &data)
print.precision = data.precision;
if (!data.subnames.empty()) {
- for (int i = 0; i < data.x; ++i)
+ for (off_type i = 0; i < data.x; ++i)
if (!data.subnames[i].empty())
havesub = true;
}
VResult tot_vec(data.y);
Result super_total = 0.0;
- for (int i = 0; i < data.x; ++i) {
+ for (off_type i = 0; i < data.x; ++i) {
if (havesub && (i >= data.subnames.size() || data.subnames[i].empty()))
continue;
- int iy = i * data.y;
+ off_type iy = i * data.y;
VResult yvec(data.y);
Result total = 0.0;
- for (int j = 0; j < data.y; ++j) {
+ for (off_type j = 0; j < data.y; ++j) {
yvec[j] = data.cvec[iy + j];
tot_vec[j] += yvec[j];
total += yvec[j];
@@ -668,7 +668,7 @@ Text::visit(const DistData &data)
print.underflow = data.data.underflow;
print.overflow = data.data.overflow;
print.vec.resize(data.data.cvec.size());
- for (int i = 0; i < print.vec.size(); ++i)
+ for (off_type i = 0; i < print.vec.size(); ++i)
print.vec[i] = (Result)data.data.cvec[i];
print.sum = data.data.sum;
print.squares = data.data.squares;
@@ -689,7 +689,7 @@ Text::visit(const VectorDistData &data)
if (noOutput(data))
return;
- for (int i = 0; i < data.size(); ++i) {
+ for (off_type i = 0; i < data.size(); ++i) {
DistPrint print;
print.name = data.name + "_" +
@@ -705,7 +705,7 @@ Text::visit(const VectorDistData &data)
print.underflow = data.data[i].underflow;
print.overflow = data.data[i].overflow;
print.vec.resize(data.data[i].cvec.size());
- for (int j = 0; j < print.vec.size(); ++j)
+ for (off_type j = 0; j < print.vec.size(); ++j)
print.vec[j] = (Result)data.data[i].cvec[j];
print.sum = data.data[i].sum;
print.squares = data.data[i].squares;
diff --git a/src/base/stats/types.hh b/src/base/stats/types.hh
index 1ae29afbd..6f56aec9a 100644
--- a/src/base/stats/types.hh
+++ b/src/base/stats/types.hh
@@ -47,6 +47,9 @@ typedef double Result;
/** vector of results. */
typedef std::vector<Result> VResult;
+typedef unsigned int size_type;
+typedef unsigned int off_type;
+
/* namespace Stats */ }
#endif // __BASE_STATS_TYPES_HH__