serialization for binning. it is WAAAAAAAY past my bedtime.
cpu/exec_context.cc: sim/system.cc: sim/system.hh: serialization for binning --HG-- extra : convert_revision : f8417794a3a5ec7f2addc9c2da0f48e851899112
This commit is contained in:
parent
2ef27db62c
commit
4fa703f2ec
|
@ -104,6 +104,29 @@ ExecContext::serialize(ostream &os)
|
||||||
regs.serialize(os);
|
regs.serialize(os);
|
||||||
// thread_num and cpu_id are deterministic from the config
|
// thread_num and cpu_id are deterministic from the config
|
||||||
SERIALIZE_SCALAR(func_exe_inst);
|
SERIALIZE_SCALAR(func_exe_inst);
|
||||||
|
|
||||||
|
bool ctx = false;
|
||||||
|
if (swCtx) {
|
||||||
|
ctx = true;
|
||||||
|
SERIALIZE_SCALAR(ctx);
|
||||||
|
SERIALIZE_SCALAR(swCtx->calls);
|
||||||
|
std::stack<fnCall *> *stack = &(swCtx->callStack);
|
||||||
|
fnCall *top;
|
||||||
|
int size = stack->size();
|
||||||
|
SERIALIZE_SCALAR(size);
|
||||||
|
|
||||||
|
for (int j=0; j<size; ++j) {
|
||||||
|
top = stack->top();
|
||||||
|
paramOut(os, csprintf("stackpos[%d]",j), top->name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SERIALIZE_SCALAR(ctx);
|
||||||
|
}
|
||||||
|
if (system->bin) {
|
||||||
|
Statistics::MainBin *cur = Statistics::MainBin::curBin();
|
||||||
|
string bin_name = cur->name();
|
||||||
|
SERIALIZE_SCALAR(bin_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,6 +137,31 @@ ExecContext::unserialize(Checkpoint *cp, const std::string §ion)
|
||||||
regs.unserialize(cp, section);
|
regs.unserialize(cp, section);
|
||||||
// thread_num and cpu_id are deterministic from the config
|
// thread_num and cpu_id are deterministic from the config
|
||||||
UNSERIALIZE_SCALAR(func_exe_inst);
|
UNSERIALIZE_SCALAR(func_exe_inst);
|
||||||
|
|
||||||
|
bool ctx;
|
||||||
|
UNSERIALIZE_SCALAR(ctx);
|
||||||
|
if (ctx) {
|
||||||
|
swCtx = new SWContext;
|
||||||
|
UNSERIALIZE_SCALAR(swCtx->calls);
|
||||||
|
int size;
|
||||||
|
UNSERIALIZE_SCALAR(size);
|
||||||
|
fnCall *call = new fnCall[size];
|
||||||
|
for (int i=0; i<size; ++i) {
|
||||||
|
paramIn(cp, section, csprintf("stackpos[%d]",i), call[i].name);
|
||||||
|
call[i].myBin = system->getBin(call[i].name);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=size-1; i>=0; --i) {
|
||||||
|
swCtx->callStack.push(&(call[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (system->bin) {
|
||||||
|
string bin_name;
|
||||||
|
UNSERIALIZE_SCALAR(bin_name);
|
||||||
|
system->getBin(bin_name)->activate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ System::getBin(const std::string &name)
|
||||||
std::map<const std::string, Statistics::MainBin *>::const_iterator i;
|
std::map<const std::string, Statistics::MainBin *>::const_iterator i;
|
||||||
i = fnBins.find(name);
|
i = fnBins.find(name);
|
||||||
if (i == fnBins.end())
|
if (i == fnBins.end())
|
||||||
panic("trying to getBin that is not on system map!");
|
panic("trying to getBin %s that is not on system map!", name);
|
||||||
return (*i).second;
|
return (*i).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,5 +125,64 @@ System::findContext(Addr pcb)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
System::serialize(std::ostream &os)
|
||||||
|
{
|
||||||
|
if (bin == true) {
|
||||||
|
map<const Addr, SWContext *>::const_iterator iter, end;
|
||||||
|
iter = swCtxMap.begin();
|
||||||
|
end = swCtxMap.end();
|
||||||
|
|
||||||
|
int numCtxs = swCtxMap.size();
|
||||||
|
SERIALIZE_SCALAR(numCtxs);
|
||||||
|
SWContext *ctx;
|
||||||
|
for (int i = 0; iter != end; ++i) {
|
||||||
|
paramOut(os, csprintf("Addr[%d]",i), (*iter).first);
|
||||||
|
ctx = (*iter).second;
|
||||||
|
paramOut(os, csprintf("calls[%d]",i), ctx->calls);
|
||||||
|
|
||||||
|
stack<fnCall *> *stack = &(ctx->callStack);
|
||||||
|
fnCall *top;
|
||||||
|
int size = stack->size();
|
||||||
|
paramOut(os, csprintf("stacksize[%d]",i), size);
|
||||||
|
for (int j=0; j<size; ++j) {
|
||||||
|
top = stack->top();
|
||||||
|
paramOut(os, csprintf("ctx[%d].stackpos[%d]",i,j), top->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
System::unserialize(Checkpoint *cp, const std::string §ion)
|
||||||
|
{
|
||||||
|
if (bin == true) {
|
||||||
|
int numCtxs;
|
||||||
|
UNSERIALIZE_SCALAR(numCtxs);
|
||||||
|
|
||||||
|
SWContext *ctxs = new SWContext[numCtxs];
|
||||||
|
Addr addr;
|
||||||
|
int size;
|
||||||
|
for(int i = 0; i < numCtxs; ++i) {
|
||||||
|
paramIn(cp, section, csprintf("Addr[%d]",i), addr);
|
||||||
|
paramIn(cp, section, csprintf("calls[%d]",i), ctxs[i].calls);
|
||||||
|
|
||||||
|
paramIn(cp, section, csprintf("stacksize[%d]",i), size);
|
||||||
|
fnCall *call = new fnCall[size];
|
||||||
|
for (int j = 0; j < size; ++j) {
|
||||||
|
paramIn(cp, section, csprintf("ctx[%d].stackpos[%d]",i,j),
|
||||||
|
call[j].name);
|
||||||
|
call[j].myBin = getBin(call[j].name);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j=size-1; j>=0; --j) {
|
||||||
|
ctxs[i].callStack.push(&(call[j]));
|
||||||
|
}
|
||||||
|
|
||||||
|
addContext(addr, &(ctxs[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DEFINE_SIM_OBJECT_CLASS_NAME("System", System)
|
DEFINE_SIM_OBJECT_CLASS_NAME("System", System)
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,10 @@ class System : public SimObject
|
||||||
|
|
||||||
virtual void dumpState(ExecContext *xc) const = 0;
|
virtual void dumpState(ExecContext *xc) const = 0;
|
||||||
|
|
||||||
|
virtual void serialize(std::ostream &os);
|
||||||
|
virtual void unserialize(Checkpoint *cp, const std::string §ion);
|
||||||
|
//
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const uint64_t init_param;
|
const uint64_t init_param;
|
||||||
MemoryController *memCtrl;
|
MemoryController *memCtrl;
|
||||||
|
|
Loading…
Reference in a new issue