Merge zizzer.eecs.umich.edu:/bk/m5
into zans.eecs.umich.edu:/z/binkertn/research/m5/stats --HG-- extra : convert_revision : cc1611895ad790cdaff75f752f10c048a5bff323
This commit is contained in:
@@ -129,8 +129,8 @@ class Database
|
||||
typedef list<Stat *> list_t;
|
||||
typedef map<const Stat *, StatData *> map_t;
|
||||
|
||||
list<GenBin *> bins;
|
||||
map<const GenBin *, std::string > bin_names;
|
||||
list<MainBin *> bins;
|
||||
map<const MainBin *, std::string > bin_names;
|
||||
list_t binnedStats;
|
||||
|
||||
list_t allStats;
|
||||
@@ -148,7 +148,7 @@ class Database
|
||||
void reset();
|
||||
void regStat(Stat *stat);
|
||||
StatData *print(Stat *stat);
|
||||
void regBin(GenBin *bin, std::string name);
|
||||
void regBin(MainBin *bin, std::string name);
|
||||
};
|
||||
|
||||
Database::Database()
|
||||
@@ -171,14 +171,14 @@ Database::dump(ostream &stream)
|
||||
}
|
||||
#endif //FS_MEASURE
|
||||
|
||||
list<GenBin *>::iterator j = bins.begin();
|
||||
list<GenBin *>::iterator bins_end=bins.end();
|
||||
list<MainBin *>::iterator j = bins.begin();
|
||||
list<MainBin *>::iterator bins_end=bins.end();
|
||||
|
||||
if (!bins.empty()) {
|
||||
ccprintf(stream, "PRINTING BINNED STATS\n");
|
||||
while (j != bins_end) {
|
||||
(*j)->activate();
|
||||
map<const GenBin *, std::string>::const_iterator iter;
|
||||
map<const MainBin *, std::string>::const_iterator iter;
|
||||
iter = bin_names.find(*j);
|
||||
if (iter == bin_names.end())
|
||||
panic("a binned stat not found in names map!");
|
||||
@@ -274,10 +274,10 @@ Database::reset()
|
||||
|
||||
MainBin *orig = MainBin::curBin();
|
||||
|
||||
list<GenBin *>::iterator bi = bins.begin();
|
||||
list<GenBin *>::iterator be = bins.end();
|
||||
list<MainBin *>::iterator bi = bins.begin();
|
||||
list<MainBin *>::iterator be = bins.end();
|
||||
while (bi != be) {
|
||||
GenBin *bin = *bi;
|
||||
MainBin *bin = *bi;
|
||||
bin->activate();
|
||||
|
||||
i = allStats.begin();
|
||||
@@ -308,7 +308,7 @@ Database::regStat(Stat *stat)
|
||||
}
|
||||
|
||||
void
|
||||
Database::regBin(GenBin *bin, std::string name)
|
||||
Database::regBin(MainBin *bin, std::string name)
|
||||
{
|
||||
if (bin_names.find(bin) != bin_names.end())
|
||||
panic("shouldn't register bin twice");
|
||||
@@ -910,36 +910,35 @@ FancyDisplay(ostream &stream, const string &name, const string &desc,
|
||||
PrintOne(stream, total, "**Ignore: " + name + NAMESEP + "TOT", desc, precision, flags);
|
||||
}
|
||||
|
||||
BinBase::BinBase()
|
||||
: mem(NULL), memsize(-1)
|
||||
} // namespace Detail
|
||||
|
||||
MainBin::MainBin(const std::string &name)
|
||||
: _name(name), mem(NULL), memsize(-1)
|
||||
{
|
||||
Detail::StatDB().regBin(this, name);
|
||||
}
|
||||
|
||||
BinBase::~BinBase()
|
||||
MainBin::~MainBin()
|
||||
{
|
||||
if (mem)
|
||||
delete [] mem;
|
||||
}
|
||||
|
||||
char *
|
||||
BinBase::memory()
|
||||
MainBin::memory(off_t off)
|
||||
{
|
||||
if (!mem) {
|
||||
mem = new char[memsize];
|
||||
memset(mem, 0, memsize);
|
||||
}
|
||||
|
||||
return mem;
|
||||
}
|
||||
if (memsize == -1)
|
||||
memsize = CeilPow2((size_t) offset());
|
||||
|
||||
void
|
||||
GenBin::regBin(GenBin *bin, std::string name)
|
||||
{
|
||||
Detail::StatDB().regBin(bin, name);
|
||||
assert(offset() <= size());
|
||||
return mem + off;
|
||||
}
|
||||
|
||||
} // namespace Detail
|
||||
|
||||
void
|
||||
check()
|
||||
{
|
||||
|
||||
@@ -2170,64 +2170,43 @@ class Temp
|
||||
operator NodePtr() { return node;}
|
||||
};
|
||||
|
||||
} // namespace Detail
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Binning Interface
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
class BinBase
|
||||
struct MainBin
|
||||
{
|
||||
private:
|
||||
std::string _name;
|
||||
char *mem;
|
||||
|
||||
protected:
|
||||
off_t memsize;
|
||||
off_t size() const { return memsize; }
|
||||
char *memory();
|
||||
char *memory(off_t off);
|
||||
|
||||
public:
|
||||
BinBase();
|
||||
virtual ~BinBase();
|
||||
};
|
||||
|
||||
} // namespace Detail
|
||||
|
||||
class GenBin : public Detail::BinBase
|
||||
{
|
||||
public:
|
||||
GenBin() : BinBase() {}
|
||||
virtual ~GenBin() {};
|
||||
|
||||
virtual void activate() = 0;
|
||||
virtual std::string name() const = 0;
|
||||
void regBin(GenBin *bin, std::string name);
|
||||
};
|
||||
|
||||
template <class BinType>
|
||||
struct StatBin : public GenBin
|
||||
{
|
||||
private:
|
||||
std::string _name;
|
||||
|
||||
public:
|
||||
std::string name() const { return _name;}
|
||||
|
||||
static StatBin *&curBin() {
|
||||
static StatBin *current = NULL;
|
||||
static MainBin *&curBin()
|
||||
{
|
||||
static MainBin *current = NULL;
|
||||
return current;
|
||||
}
|
||||
|
||||
static void setCurBin(StatBin *bin) { curBin() = bin; }
|
||||
static StatBin *current() { assert(curBin()); return curBin(); }
|
||||
static void setCurBin(MainBin *bin) { curBin() = bin; }
|
||||
static MainBin *current() { assert(curBin()); return curBin(); }
|
||||
|
||||
static off_t &offset() {
|
||||
static off_t &offset()
|
||||
{
|
||||
static off_t offset = 0;
|
||||
return offset;
|
||||
}
|
||||
|
||||
static off_t new_offset(size_t size) {
|
||||
static off_t new_offset(size_t size)
|
||||
{
|
||||
size_t mask = sizeof(u_int64_t) - 1;
|
||||
off_t off = offset();
|
||||
|
||||
@@ -2236,23 +2215,24 @@ struct StatBin : public GenBin
|
||||
return off;
|
||||
}
|
||||
|
||||
explicit StatBin(std::string name) : GenBin() { _name = name; this->regBin(this, name); }
|
||||
public:
|
||||
MainBin(const std::string &name);
|
||||
~MainBin();
|
||||
|
||||
char *memory(off_t off) {
|
||||
if (memsize == -1) {
|
||||
memsize = CeilPow2((size_t) offset());
|
||||
}
|
||||
assert(offset() <= size());
|
||||
return Detail::BinBase::memory() + off;
|
||||
const std::string &
|
||||
name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
virtual void activate() {
|
||||
void
|
||||
activate()
|
||||
{
|
||||
setCurBin(this);
|
||||
#ifdef FS_MEASURE
|
||||
DPRINTF(TCPIP, "activating %s Bin\n", name());
|
||||
#endif
|
||||
}
|
||||
static void activate(StatBin &bin) { setCurBin(&bin); }
|
||||
|
||||
class BinBase
|
||||
{
|
||||
@@ -2261,10 +2241,12 @@ struct StatBin : public GenBin
|
||||
|
||||
public:
|
||||
BinBase() : offset(-1) {}
|
||||
void allocate(size_t size) {
|
||||
void allocate(size_t size)
|
||||
{
|
||||
offset = new_offset(size);
|
||||
}
|
||||
char *access() {
|
||||
char *access()
|
||||
{
|
||||
assert(offset != -1);
|
||||
return current()->memory(offset);
|
||||
}
|
||||
@@ -2284,7 +2266,9 @@ struct StatBin : public GenBin
|
||||
|
||||
int size() const { return 1; }
|
||||
|
||||
Storage *data(Params ¶ms) {
|
||||
Storage *
|
||||
data(Params ¶ms)
|
||||
{
|
||||
assert(initialized());
|
||||
char *ptr = access();
|
||||
char *flags = ptr + sizeof(Storage);
|
||||
@@ -2294,7 +2278,9 @@ struct StatBin : public GenBin
|
||||
}
|
||||
return reinterpret_cast<Storage *>(ptr);
|
||||
}
|
||||
void reset()
|
||||
|
||||
void
|
||||
reset()
|
||||
{
|
||||
char *ptr = access();
|
||||
char *flags = ptr + size() * sizeof(Storage);
|
||||
@@ -2320,7 +2306,8 @@ struct StatBin : public GenBin
|
||||
VectorBin() : _size(0) {}
|
||||
|
||||
bool initialized() const { return _size > 0; }
|
||||
void init(int s, Params ¶ms) {
|
||||
void init(int s, Params ¶ms)
|
||||
{
|
||||
assert(!initialized());
|
||||
assert(s > 0);
|
||||
_size = s;
|
||||
@@ -2329,7 +2316,8 @@ struct StatBin : public GenBin
|
||||
|
||||
int size() const { return _size; }
|
||||
|
||||
Storage *data(int index, Params ¶ms) {
|
||||
Storage *data(int index, Params ¶ms)
|
||||
{
|
||||
assert(initialized());
|
||||
assert(index >= 0 && index < size());
|
||||
char *ptr = access();
|
||||
@@ -2357,9 +2345,6 @@ struct StatBin : public GenBin
|
||||
};
|
||||
};
|
||||
|
||||
class MainBinType {};
|
||||
typedef StatBin<MainBinType> MainBin;
|
||||
|
||||
struct NoBin
|
||||
{
|
||||
template <class Storage>
|
||||
@@ -2379,11 +2364,13 @@ struct NoBin
|
||||
}
|
||||
|
||||
bool initialized() const { return true; }
|
||||
void init(Params ¶ms) {
|
||||
void init(Params ¶ms)
|
||||
{
|
||||
new (ptr) Storage(params);
|
||||
}
|
||||
int size() const{ return 1; }
|
||||
Storage *data(Params ¶ms) {
|
||||
Storage *data(Params ¶ms)
|
||||
{
|
||||
assert(initialized());
|
||||
return reinterpret_cast<Storage *>(ptr);
|
||||
}
|
||||
@@ -2420,7 +2407,8 @@ struct NoBin
|
||||
}
|
||||
|
||||
bool initialized() const { return ptr != NULL; }
|
||||
void init(int s, Params ¶ms) {
|
||||
void init(int s, Params ¶ms)
|
||||
{
|
||||
assert(s > 0 && "size must be positive!");
|
||||
assert(!initialized());
|
||||
_size = s;
|
||||
@@ -2431,7 +2419,8 @@ struct NoBin
|
||||
|
||||
int size() const { return _size; }
|
||||
|
||||
Storage *data(int index, Params ¶ms) {
|
||||
Storage *data(int index, Params ¶ms)
|
||||
{
|
||||
assert(initialized());
|
||||
assert(index >= 0 && index < size());
|
||||
return reinterpret_cast<Storage *>(ptr + index * sizeof(Storage));
|
||||
|
||||
@@ -92,7 +92,7 @@ class FnEvent : public PCEvent
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
Statistics::GenBin *myBin;
|
||||
Statistics::MainBin *myBin;
|
||||
};
|
||||
#endif //FS_MEASURE
|
||||
#endif // __TRU64_EVENTS_HH__
|
||||
|
||||
@@ -105,10 +105,10 @@ printSystems()
|
||||
}
|
||||
|
||||
#ifdef FS_MEASURE
|
||||
Statistics::GenBin *
|
||||
Statistics::MainBin *
|
||||
System::getBin(const std::string &name)
|
||||
{
|
||||
std::map<const std::string, Statistics::GenBin *>::const_iterator i;
|
||||
std::map<const std::string, Statistics::MainBin *>::const_iterator i;
|
||||
i = fnBins.find(name);
|
||||
if (i == fnBins.end())
|
||||
panic("trying to getBin that is not on system map!");
|
||||
|
||||
@@ -52,7 +52,7 @@ class System : public SimObject
|
||||
{
|
||||
#ifdef FS_MEASURE
|
||||
protected:
|
||||
std::map<const std::string, Statistics::GenBin *> fnBins;
|
||||
std::map<const std::string, Statistics::MainBin *> fnBins;
|
||||
std::map<const Addr, SWContext *> swCtxMap;
|
||||
#endif //FS_MEASURE
|
||||
|
||||
@@ -85,7 +85,7 @@ class System : public SimObject
|
||||
virtual bool breakpoint() = 0;
|
||||
|
||||
#ifdef FS_MEASURE
|
||||
Statistics::GenBin * getBin(const std::string &name);
|
||||
Statistics::MainBin * getBin(const std::string &name);
|
||||
virtual bool findCaller(std::string, std::string) const = 0;
|
||||
|
||||
SWContext *findContext(Addr pcb);
|
||||
|
||||
Reference in New Issue
Block a user