base-stats: Remove info dependency from stats storage

Info depends on the storage type, not the other way around.

Change-Id: Ie3deca17b859a217c0c7bd833c017d9436eee4b0
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27083
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
This commit is contained in:
Daniel R. Carvalho
2020-02-18 23:13:39 +01:00
committed by Daniel Carvalho
parent e9bdc92039
commit b63a802033
6 changed files with 116 additions and 156 deletions

View File

@@ -439,7 +439,7 @@ class DataWrapVec : public DataWrap<Derived, InfoProxyType>
size_t size = self.size();
for (off_type i = 0; i < size; ++i)
self.data(i)->prepare(info);
self.data(i)->prepare(info->storageParams);
}
void
@@ -450,7 +450,7 @@ class DataWrapVec : public DataWrap<Derived, InfoProxyType>
size_t size = self.size();
for (off_type i = 0; i < size; ++i)
self.data(i)->reset(info);
self.data(i)->reset(info->storageParams);
}
};
@@ -550,7 +550,7 @@ class ScalarBase : public DataWrap<Derived, ScalarInfoProxy>
void
doInit()
{
new (storage) Storage(this->info());
new (storage) Storage(this->info()->storageParams);
this->setInit();
}
@@ -623,8 +623,8 @@ class ScalarBase : public DataWrap<Derived, ScalarInfoProxy>
bool zero() const { return result() == 0.0; }
void reset() { data()->reset(this->info()); }
void prepare() { data()->prepare(this->info()); }
void reset() { data()->reset(this->info()->storageParams); }
void prepare() { data()->prepare(this->info()->storageParams); }
};
class ProxyInfo : public ScalarInfo
@@ -957,7 +957,7 @@ class VectorBase : public DataWrapVec<Derived, VectorInfoProxy>
storage = reinterpret_cast<Storage *>(ptr);
for (off_type i = 0; i < _size; ++i)
new (&storage[i]) Storage(this->info());
new (&storage[i]) Storage(this->info()->storageParams);
this->setInit();
}
@@ -1196,7 +1196,7 @@ class Vector2dBase : public DataWrapVec2d<Derived, Vector2dInfoProxy>
storage = reinterpret_cast<Storage *>(ptr);
for (off_type i = 0; i < _size; ++i)
new (&storage[i]) Storage(info);
new (&storage[i]) Storage(info->storageParams);
this->setInit();
@@ -1244,7 +1244,7 @@ class Vector2dBase : public DataWrapVec2d<Derived, Vector2dInfoProxy>
size_type size = this->size();
for (off_type i = 0; i < size; ++i)
data(i)->prepare(info);
data(i)->prepare(info->storageParams);
info->cvec.resize(size);
for (off_type i = 0; i < size; ++i)
@@ -1260,7 +1260,7 @@ class Vector2dBase : public DataWrapVec2d<Derived, Vector2dInfoProxy>
Info *info = this->info();
size_type size = this->size();
for (off_type i = 0; i < size; ++i)
data(i)->reset(info);
data(i)->reset(info->storageParams);
}
bool
@@ -1316,7 +1316,7 @@ class DistBase : public DataWrap<Derived, DistInfoProxy>
void
doInit()
{
new (storage) Storage(this->info());
new (storage) Storage(this->info()->storageParams);
this->setInit();
}
@@ -1352,7 +1352,7 @@ class DistBase : public DataWrap<Derived, DistInfoProxy>
prepare()
{
Info *info = this->info();
data()->prepare(info, info->data);
data()->prepare(info->storageParams, info->data);
}
/**
@@ -1361,7 +1361,7 @@ class DistBase : public DataWrap<Derived, DistInfoProxy>
void
reset()
{
data()->reset(this->info());
data()->reset(this->info()->storageParams);
}
/**
@@ -1413,7 +1413,7 @@ class VectorDistBase : public DataWrapVec<Derived, VectorDistInfoProxy>
Info *info = this->info();
for (off_type i = 0; i < _size; ++i)
new (&storage[i]) Storage(info);
new (&storage[i]) Storage(info->storageParams);
this->setInit();
}
@@ -1464,7 +1464,7 @@ class VectorDistBase : public DataWrapVec<Derived, VectorDistInfoProxy>
size_type size = this->size();
info->data.resize(size);
for (off_type i = 0; i < size; ++i)
data(i)->prepare(info, info->data[i]);
data(i)->prepare(info->storageParams, info->data[i]);
}
bool
@@ -2461,7 +2461,7 @@ class SparseHistBase : public DataWrap<Derived, SparseHistInfoProxy>
void
doInit()
{
new (storage) Storage(this->info());
new (storage) Storage(this->info()->storageParams);
this->setInit();
}
@@ -2497,7 +2497,7 @@ class SparseHistBase : public DataWrap<Derived, SparseHistInfoProxy>
prepare()
{
Info *info = this->info();
data()->prepare(info, info->data);
data()->prepare(info->storageParams, info->data);
}
/**
@@ -2506,7 +2506,7 @@ class SparseHistBase : public DataWrap<Derived, SparseHistInfoProxy>
void
reset()
{
data()->reset(this->info());
data()->reset(this->info()->storageParams);
}
};

View File

@@ -43,6 +43,6 @@ if env['HAVE_HDF5']:
GTest('group.test', 'group.test.cc', 'group.cc', 'info.cc',
with_tag('gem5 trace'))
GTest('info.test', 'info.test.cc', 'info.cc', '../debug.cc', '../str.cc')
GTest('storage.test', 'storage.test.cc', '../debug.cc', '../str.cc', 'info.cc',
GTest('storage.test', 'storage.test.cc', '../debug.cc', '../str.cc',
'storage.cc', '../../sim/cur_tick.cc')
GTest('units.test', 'units.test.cc')

View File

@@ -188,26 +188,6 @@ class VectorInfo : public Info
virtual Result total() const = 0;
};
enum DistType { Deviation, Dist, Hist };
struct DistData
{
DistType type;
Counter min;
Counter max;
Counter bucket_size;
Counter min_val;
Counter max_val;
Counter underflow;
Counter overflow;
VCounter cvec;
Counter sum;
Counter squares;
Counter logs;
Counter samples;
};
class DistInfo : public Info
{
public:
@@ -258,14 +238,6 @@ class FormulaInfo : public VectorInfo
virtual std::string str() const = 0;
};
/** Data structure of sparse histogram */
struct SparseHistData
{
MCounter cmap;
Counter samples;
};
class SparseHistInfo : public Info
{
public:

View File

@@ -36,7 +36,6 @@
#include "base/cast.hh"
#include "base/compiler.hh"
#include "base/logging.hh"
#include "base/stats/info.hh"
#include "base/stats/types.hh"
#include "sim/cur_tick.hh"
@@ -68,7 +67,7 @@ class StatStor
* Builds this storage element and calls the base constructor of the
* datatype.
*/
StatStor(Info *info)
StatStor(const StorageParams* const storage_params)
: data(Counter())
{ }
@@ -105,12 +104,12 @@ class StatStor
/**
* Prepare stat data for dumping or serialization
*/
void prepare(Info *info) { }
void prepare(const StorageParams* const storage_params) { }
/**
* Reset stat value to default
*/
void reset(Info *info) { data = Counter(); }
void reset(const StorageParams* const storage_params) { data = Counter(); }
/**
* @return true if zero value
@@ -143,7 +142,7 @@ class AvgStor
/**
* Build and initializes this stat storage.
*/
AvgStor(Info *info)
AvgStor(const StorageParams* const storage_params)
: current(0), lastReset(0), total(0), last(0)
{ }
@@ -198,7 +197,7 @@ class AvgStor
* Prepare stat data for dumping or serialization
*/
void
prepare(Info *info)
prepare(const StorageParams* const storage_params)
{
total += current * (curTick() - last);
last = curTick();
@@ -208,7 +207,7 @@ class AvgStor
* Reset stat value to default
*/
void
reset(Info *info)
reset(const StorageParams* const storage_params)
{
total = 0.0;
last = curTick();
@@ -286,10 +285,10 @@ class DistStor
}
};
DistStor(Info *info)
: cvec(safe_cast<const Params *>(info->storageParams)->buckets)
DistStor(const StorageParams* const storage_params)
: cvec(safe_cast<const Params *>(storage_params)->buckets)
{
reset(info);
reset(storage_params);
}
/**
@@ -316,9 +315,9 @@ class DistStor
}
void
prepare(Info *info, DistData &data)
prepare(const StorageParams* const storage_params, DistData &data)
{
const Params *params = safe_cast<const Params *>(info->storageParams);
const Params *params = safe_cast<const Params *>(storage_params);
assert(params->type == Dist);
data.type = params->type;
@@ -344,9 +343,9 @@ class DistStor
* Reset stat value to default
*/
void
reset(Info *info)
reset(const StorageParams* const storage_params)
{
const Params *params = safe_cast<const Params *>(info->storageParams);
const Params *params = safe_cast<const Params *>(storage_params);
min_track = params->min;
max_track = params->max;
bucket_size = params->bucket_size;
@@ -472,10 +471,10 @@ class HistStor
}
};
HistStor(Info *info)
: cvec(safe_cast<const Params *>(info->storageParams)->buckets)
HistStor(const StorageParams* const storage_params)
: cvec(safe_cast<const Params *>(storage_params)->buckets)
{
reset(info);
reset(storage_params);
}
/**
@@ -508,9 +507,9 @@ class HistStor
}
void
prepare(Info *info, DistData &data)
prepare(const StorageParams* const storage_params, DistData &data)
{
const Params *params = safe_cast<const Params *>(info->storageParams);
const Params *params = safe_cast<const Params *>(storage_params);
assert(params->type == Hist);
data.type = params->type;
@@ -536,9 +535,9 @@ class HistStor
* Reset stat value to default
*/
void
reset(Info *info)
reset(const StorageParams* const storage_params)
{
const Params *params = safe_cast<const Params *>(info->storageParams);
const Params *params = safe_cast<const Params *>(storage_params);
min_bucket = 0;
max_bucket = params->buckets - 1;
bucket_size = 1;
@@ -577,7 +576,7 @@ class SampleStor
/**
* Create and initialize this storage.
*/
SampleStor(Info *info)
SampleStor(const StorageParams* const storage_params)
: sum(Counter()), squares(Counter()), samples(Counter())
{ }
@@ -609,9 +608,9 @@ class SampleStor
bool zero() const { return samples == Counter(); }
void
prepare(Info *info, DistData &data)
prepare(const StorageParams* const storage_params, DistData &data)
{
const Params *params = safe_cast<const Params *>(info->storageParams);
const Params *params = safe_cast<const Params *>(storage_params);
assert(params->type == Deviation);
data.type = params->type;
@@ -624,7 +623,7 @@ class SampleStor
* Reset stat value to default
*/
void
reset(Info *info)
reset(const StorageParams* const storage_params)
{
sum = Counter();
squares = Counter();
@@ -653,7 +652,7 @@ class AvgSampleStor
/**
* Create and initialize this storage.
*/
AvgSampleStor(Info *info)
AvgSampleStor(const StorageParams* const storage_params)
: sum(Counter()), squares(Counter())
{}
@@ -683,9 +682,9 @@ class AvgSampleStor
bool zero() const { return sum == Counter(); }
void
prepare(Info *info, DistData &data)
prepare(const StorageParams* const storage_params, DistData &data)
{
const Params *params = safe_cast<const Params *>(info->storageParams);
const Params *params = safe_cast<const Params *>(storage_params);
assert(params->type == Deviation);
data.type = params->type;
@@ -698,7 +697,7 @@ class AvgSampleStor
* Reset stat value to default
*/
void
reset(Info *info)
reset(const StorageParams* const storage_params)
{
sum = Counter();
squares = Counter();
@@ -727,9 +726,9 @@ class SparseHistStor
Params() : DistParams(Hist) {}
};
SparseHistStor(Info *info)
SparseHistStor(const StorageParams* const storage_params)
{
reset(info);
reset(storage_params);
}
/**
@@ -761,7 +760,7 @@ class SparseHistStor
}
void
prepare(Info *info, SparseHistData &data)
prepare(const StorageParams* const storage_params, SparseHistData &data)
{
MCounter::iterator it;
data.cmap.clear();
@@ -776,7 +775,7 @@ class SparseHistStor
* Reset stat value to default
*/
void
reset(Info *info)
reset(const StorageParams* const storage_params)
{
cmap.clear();
samples = 0;

View File

@@ -55,28 +55,6 @@ struct ValueSamples
}
};
/**
* A mocked info class.
* @todo There is no real dependency on the info class, so this must be
* removed on a cleanup.
*/
class MockInfo : public statistics::Info
{
public:
MockInfo(statistics::StorageParams* storage_params)
: statistics::Info()
{
this->storageParams = storage_params;
}
~MockInfo() = default;
bool check() const override { return true; }
void prepare() override { }
void reset() override { }
bool zero() const override { return true; }
void visit(statistics::Output &visitor) override { }
};
/** Test setting and getting a value to the storage. */
TEST(StatsStatStorTest, SetValueResult)
{
@@ -287,18 +265,17 @@ TEST(StatsDistStorDeathTest, BucketSize0)
TEST(StatsDistStorTest, ZeroReset)
{
statistics::DistStor::Params params(0, 99, 10);
MockInfo info(&params);
statistics::DistStor stor(&info);
statistics::DistStor stor(&params);
statistics::Counter val = 10;
statistics::Counter num_samples = 5;
ASSERT_TRUE(stor.zero());
stor.reset(&info);
stor.reset(&params);
stor.sample(val, num_samples);
ASSERT_FALSE(stor.zero());
stor.reset(&info);
stor.reset(&params);
ASSERT_TRUE(stor.zero());
}
@@ -314,15 +291,14 @@ TEST(StatsDistStorTest, Size)
statistics::DistData data;
statistics::DistStor::Params params(0, 19, 1);
MockInfo info(&params);
statistics::DistStor stor(&info);
statistics::DistStor stor(&params);
ASSERT_EQ(stor.size(), size);
stor.sample(val, num_samples);
ASSERT_EQ(stor.size(), size);
stor.prepare(&info, data);
stor.prepare(&params, data);
ASSERT_EQ(stor.size(), size);
stor.reset(&info);
stor.reset(&params);
ASSERT_EQ(stor.size(), size);
stor.zero();
ASSERT_EQ(stor.size(), size);
@@ -371,8 +347,7 @@ void
prepareCheckDistStor(statistics::DistStor::Params& params,
ValueSamples* values, int num_values, statistics::DistData& expected_data)
{
MockInfo info(&params);
statistics::DistStor stor(&info);
statistics::DistStor stor(&params);
statistics::Counter val;
statistics::DistData data;
@@ -393,7 +368,7 @@ prepareCheckDistStor(statistics::DistStor::Params& params,
expected_data.squares += values[i].value * val;
expected_data.samples += values[i].numSamples;
}
stor.prepare(&info, data);
stor.prepare(&params, data);
// DistStor does not use log
checkExpectedDistData(data, expected_data, true);
@@ -463,8 +438,7 @@ TEST(StatsDistStorTest, SamplePrepareMultiple)
TEST(StatsDistStorTest, Reset)
{
statistics::DistStor::Params params(0, 99, 5);
MockInfo info(&params);
statistics::DistStor stor(&info);
statistics::DistStor stor(&params);
// Populate storage with random samples
ValueSamples values[] = {{10, 5}, {1234, 2}, {12345678, 99}, {-10, 4},
@@ -475,9 +449,9 @@ TEST(StatsDistStorTest, Reset)
}
// Reset storage, and make sure all data has been cleared
stor.reset(&info);
stor.reset(&params);
statistics::DistData data;
stor.prepare(&info, data);
stor.prepare(&params, data);
statistics::DistData expected_data;
expected_data.type = statistics::Dist;
@@ -519,18 +493,17 @@ TEST(StatsHistStorDeathTest, NotEnoughBuckets1)
TEST(StatsHistStorTest, ZeroReset)
{
statistics::HistStor::Params params(10);
MockInfo info(&params);
statistics::HistStor stor(&info);
statistics::HistStor stor(&params);
statistics::Counter val = 10;
statistics::Counter num_samples = 5;
ASSERT_TRUE(stor.zero());
stor.reset(&info);
stor.reset(&params);
stor.sample(val, num_samples);
ASSERT_FALSE(stor.zero());
stor.reset(&info);
stor.reset(&params);
ASSERT_TRUE(stor.zero());
}
@@ -547,15 +520,14 @@ TEST(StatsHistStorTest, Size)
for (int i = 0; i < (sizeof(sizes) / sizeof(statistics::size_type)); i++) {
statistics::HistStor::Params params(sizes[i]);
MockInfo info(&params);
statistics::HistStor stor(&info);
statistics::HistStor stor(&params);
ASSERT_EQ(stor.size(), sizes[i]);
stor.sample(val, num_samples);
ASSERT_EQ(stor.size(), sizes[i]);
stor.prepare(&info, data);
stor.prepare(&params, data);
ASSERT_EQ(stor.size(), sizes[i]);
stor.reset(&info);
stor.reset(&params);
ASSERT_EQ(stor.size(), sizes[i]);
stor.zero();
ASSERT_EQ(stor.size(), sizes[i]);
@@ -576,8 +548,7 @@ void
prepareCheckHistStor(statistics::HistStor::Params& params,
ValueSamples* values, int num_values, statistics::DistData& expected_data)
{
MockInfo info(&params);
statistics::HistStor stor(&info);
statistics::HistStor stor(&params);
statistics::Counter val;
statistics::DistData data;
@@ -606,7 +577,7 @@ prepareCheckHistStor(statistics::HistStor::Params& params,
}
expected_data.samples += values[i].numSamples;
}
stor.prepare(&info, data);
stor.prepare(&params, data);
checkExpectedDistData(data, expected_data, no_log);
}
@@ -889,8 +860,7 @@ TEST(StatsHistStorTest, SamplePrepareMultipleGrowEvenBuckets)
TEST(StatsHistStorTest, Reset)
{
statistics::HistStor::Params params(4);
MockInfo info(&params);
statistics::HistStor stor(&info);
statistics::HistStor stor(&params);
// Setup expected data for the hand-carved values given. This adds quite
// a few positive and negative samples, and the bucket size will grow to
@@ -905,7 +875,7 @@ TEST(StatsHistStorTest, Reset)
// Reset storage, and make sure all data has been cleared:
// Bkt0=[0,1[ , Bkt1=[1,2[, Bkt2=[2,3[, Bkt3=[3,4[
stor.reset(&info);
stor.reset(&params);
statistics::DistData expected_data;
expected_data.type = statistics::Hist;
expected_data.bucket_size = 1;
@@ -921,12 +891,10 @@ TEST(StatsHistStorTest, Reset)
TEST(StatsHistStorDeathTest, AddDifferentSize)
{
statistics::HistStor::Params params(4);
MockInfo info(&params);
statistics::HistStor stor(&info);
statistics::HistStor stor(&params);
statistics::HistStor::Params params2(5);
MockInfo info2(&params2);
statistics::HistStor stor2(&info2);
statistics::HistStor stor2(&params2);
ASSERT_DEATH(stor.add(&stor2), ".+");
}
@@ -935,14 +903,12 @@ TEST(StatsHistStorDeathTest, AddDifferentSize)
TEST(StatsHistStorDeathTest, AddDifferentMin)
{
statistics::HistStor::Params params(4);
MockInfo info(&params);
statistics::HistStor stor(&info);
statistics::HistStor stor(&params);
stor.sample(-1, 3);
// On creation, the storage's min is zero
statistics::HistStor::Params params2(4);
MockInfo info2(&params2);
statistics::HistStor stor2(&info2);
statistics::HistStor stor2(&params2);
ASSERT_DEATH(stor.add(&stor2), ".+");
}
@@ -952,34 +918,33 @@ TEST(StatsHistStorDeathTest, AddDifferentMin)
TEST(StatsHistStorTest, Add)
{
statistics::HistStor::Params params(4);
MockInfo info(&params);
// Setup first storage. Buckets are:
// Bkt0=[0,16[, Bkt1=[16,32[, Bkt2=[32,48[, Bkt3=[58,64[
statistics::HistStor stor(&info);
statistics::HistStor stor(&params);
ValueSamples values[] = {{0, 5}, {3, 2}, {20, 37}, {32, 18}};
int num_values = sizeof(values) / sizeof(ValueSamples);
for (int i = 0; i < num_values; i++) {
stor.sample(values[i].value, values[i].numSamples);
}
statistics::DistData data;
stor.prepare(&info, data);
stor.prepare(&params, data);
// Setup second storage. Buckets are:
// Bkt0=[0,32[, Bkt1=[32,64[, Bkt2=[64,96[, Bkt3=[96,128[
statistics::HistStor stor2(&info);
statistics::HistStor stor2(&params);
ValueSamples values2[] = {{10, 10}, {0, 1}, {80, 4}, {17, 100}, {95, 79}};
int num_values2 = sizeof(values2) / sizeof(ValueSamples);
for (int i = 0; i < num_values2; i++) {
stor2.sample(values2[i].value, values2[i].numSamples);
}
statistics::DistData data2;
stor2.prepare(&info, data2);
stor2.prepare(&params, data2);
// Perform the merge
stor.add(&stor2);
statistics::DistData merge_data;
stor.prepare(&info, merge_data);
stor.prepare(&params, merge_data);
// Setup expected data. Buckets are:
// Bkt0=[0,32[, Bkt1=[32,64[, Bkt2=[64,96[, Bkt3=[96,128[
@@ -1036,11 +1001,10 @@ TEST(StatsSampleStorTest, SamplePrepare)
statistics::DistData data;
statistics::DistData expected_data;
statistics::SampleStor::Params params;
MockInfo info(&params);
// Simple test with one value being sampled
stor.sample(values[0].value, values[0].numSamples);
stor.prepare(&info, data);
stor.prepare(&params, data);
val = values[0].value * values[0].numSamples;
expected_data.type = statistics::Deviation;
expected_data.sum = val;
@@ -1056,7 +1020,7 @@ TEST(StatsSampleStorTest, SamplePrepare)
expected_data.squares = 0;
expected_data.samples = 0;
stor.reset(nullptr);
stor.prepare(&info, data);
stor.prepare(&params, data);
ASSERT_EQ(data.type, expected_data.type);
ASSERT_EQ(data.sum, expected_data.sum);
ASSERT_EQ(data.squares, expected_data.squares);
@@ -1071,7 +1035,7 @@ TEST(StatsSampleStorTest, SamplePrepare)
expected_data.squares += values[i].value * val;
expected_data.samples += values[i].numSamples;
}
stor.prepare(&info, data);
stor.prepare(&params, data);
ASSERT_EQ(data.type, expected_data.type);
ASSERT_EQ(data.sum, expected_data.sum);
ASSERT_EQ(data.squares, expected_data.squares);
@@ -1086,12 +1050,11 @@ TEST(StatsSampleStorTest, Size)
statistics::Counter num_samples = 5;
statistics::DistData data;
statistics::SampleStor::Params params;
MockInfo info(&params);
ASSERT_EQ(stor.size(), 1);
stor.sample(val, num_samples);
ASSERT_EQ(stor.size(), 1);
stor.prepare(&info, data);
stor.prepare(&params, data);
ASSERT_EQ(stor.size(), 1);
stor.reset(nullptr);
ASSERT_EQ(stor.size(), 1);
@@ -1130,11 +1093,10 @@ TEST(StatsAvgSampleStorTest, SamplePrepare)
statistics::DistData data;
statistics::DistData expected_data;
statistics::AvgSampleStor::Params params;
MockInfo info(&params);
// Simple test with one value being sampled
stor.sample(values[0].value, values[0].numSamples);
stor.prepare(&info, data);
stor.prepare(&params, data);
val = values[0].value * values[0].numSamples;
expected_data.type = statistics::Deviation;
expected_data.sum = val;
@@ -1150,7 +1112,7 @@ TEST(StatsAvgSampleStorTest, SamplePrepare)
expected_data.sum = 0;
expected_data.squares = 0;
stor.reset(nullptr);
stor.prepare(&info, data);
stor.prepare(&params, data);
ASSERT_EQ(data.type, expected_data.type);
ASSERT_EQ(data.sum, expected_data.sum);
ASSERT_EQ(data.squares, expected_data.squares);
@@ -1166,7 +1128,7 @@ TEST(StatsAvgSampleStorTest, SamplePrepare)
expected_data.sum += val;
expected_data.squares += values[i].value * val;
}
stor.prepare(&info, data);
stor.prepare(&params, data);
ASSERT_EQ(data.type, expected_data.type);
ASSERT_EQ(data.sum, expected_data.sum);
ASSERT_EQ(data.squares, expected_data.squares);
@@ -1181,12 +1143,11 @@ TEST(StatsAvgSampleStorTest, Size)
statistics::Counter num_samples = 5;
statistics::DistData data;
statistics::AvgSampleStor::Params params;
MockInfo info(&params);
ASSERT_EQ(stor.size(), 1);
stor.sample(val, num_samples);
ASSERT_EQ(stor.size(), 1);
stor.prepare(&info, data);
stor.prepare(&params, data);
ASSERT_EQ(stor.size(), 1);
stor.reset(nullptr);
ASSERT_EQ(stor.size(), 1);

View File

@@ -60,6 +60,34 @@ typedef std::vector<Result> VResult;
typedef unsigned int size_type;
typedef unsigned int off_type;
enum DistType { Deviation, Dist, Hist };
/** General container for distribution data. */
struct DistData
{
DistType type;
Counter min;
Counter max;
Counter bucket_size;
Counter min_val;
Counter max_val;
Counter underflow;
Counter overflow;
VCounter cvec;
Counter sum;
Counter squares;
Counter logs;
Counter samples;
};
/** Data structure of sparse histogram */
struct SparseHistData
{
MCounter cmap;
Counter samples;
};
} // namespace statistics
} // namespace gem5