41 #ifndef __BASE__CP_ANNOTATE_HH__ 42 #define __BASE__CP_ANNOTATE_HH__ 48 #include <unordered_map> 54 #include "debug/AnnotateQ.hh" 55 #include "config/cp_annotate.hh" 56 #include "config/the_isa.hh" 61 #include "params/CPA.hh" 86 int32_t sm_id, int32_t
flags) {
return; }
89 Addr st_string) {
return; }
93 int32_t
count) {
return; }
95 int32_t
count) {
return; }
97 int32_t
count) {
return; }
99 int32_t
count) {
return; }
101 Addr sm_string, int32_t
count) {
return; }
103 Addr sm_string, int32_t
count) {
return; }
105 int32_t size, int32_t
flags) {
return; }
107 int32_t size) {
return; }
109 Addr lsm_id,
Addr sm_string) {
return; }
113 Addr sm_string) {
return; }
115 std::string
st) {
return; }
117 std::string
q, uint64_t qid,
System *q_sys = NULL,
118 int32_t
count = 1) {
return; }
120 std::string
q, uint64_t qid,
System *q_sys = NULL,
121 int32_t
count = 1) {
return; }
123 std::string
q, uint64_t qid,
System *q_sys = NULL,
124 int32_t
count = 1) {
return; }
126 std::string
q, uint64_t qid,
System *q_sys = NULL,
127 int32_t
count = 1) {
return; }
129 std::string
q, uint64_t qid,
System *q_sys = NULL,
130 int32_t
count = 1) {
return; }
132 std::string
q, uint64_t qid,
System *q_sys = NULL,
133 int32_t
count = 1) {
return; }
142 struct hash<std::pair<std::string, uint64_t> >
148 return hash<std::string>()(x.first);
157 typedef CPAParams Params;
162 OP_WAIT_EMPTY = 0x02,
166 OP_SIZE_QUEUE = 0x08,
199 return dynamic_cast<const Params *
>(_params);
219 typedef std::shared_ptr<AnnotateData> AnnDataPtr;
222 struct AnnotateHeader {
249 typedef std::unordered_map<std::string, int> SCache;
254 typedef std::unordered_map<Id, int> IdHCache;
261 typedef std::map<System*, std::pair<std::string, int> > NameCache;
265 typedef std::map<StackId, std::vector<int> > SmStack;
269 typedef std::map<StackId, bool> SwExpl;
271 typedef std::map<int,int> IMap;
276 typedef std::map<int, int>
LinkMap;
279 typedef std::unordered_map<Id, AnnDataPtr> ScHCache;
297 IdCache qCache, smCache;
315 void doDq(
System *sys,
int flags,
int cpu,
int sm, std::string
q,
int qi,
317 void doQ(
System *sys,
int flags,
int cpu,
int sm, std::string q,
int qi,
320 void doSwSmEnd(
System *sys,
int cpuid, std::string sm, uint64_t frame);
325 getSm(
int sysi, std::string
si, uint64_t
id)
328 Id smid = Id(si,
id);
330 smi = smCache[sysi-1][smid];
332 smCache[sysi-1][smid] = smi = ++numSm;
334 smMap.push_back(std::make_pair(sysi, smid));
342 getSt(std::string sm, std::string
s)
348 smi = smtCache[
sm] = ++numSmt;
350 while (stCache.size() < smi) {
352 stCache.push_back(SCache());
357 sti = stCache[smi-1][
s];
359 stCache[smi-1][
s] = sti = ++numSt[smi-1];
367 NameCache::iterator
i = nameCache.find(s);
368 if (i == nameCache.end()) {
369 nameCache[
s] = std::make_pair(s->
name(), ++numSys);
370 i = nameCache.find(s);
375 qCache.push_back(IdHCache());
376 smCache.push_back(IdHCache());
377 scLinks.push_back(ScHCache());
379 return i->second.second;
385 getQ(
int sys, std::string q, uint64_t
id)
390 qi = qCache[sys-1][qid];
392 qi = qCache[sys-1][qid] = ++numQs;
396 qData.push_back(AnnotateList());
398 qMap.push_back(std::make_pair(sys, qid));
403 void swBegin(
System *sys,
int cpuid, std::string
st, uint64_t frame,
404 bool expl =
false,
int flags =
FL_NONE);
406 AnnDataPtr add(
int t,
int f,
int c,
int sm,
int stq, int32_t data=0);
420 std::map<std::string, Loader::SymbolTable*> userApp;
423 static CPA *
cpa() {
return _cpa; }
442 inline void hwBegin(flags f,
System *sys, uint64_t frame, std::string sm,
448 int sysi = getSys(sys);
449 int smi = getSm(sysi, sm, frame);
450 add(OP_BEGIN,
FL_HW | f, 0, smi, getSt(sm, st));
452 warn(
"BAD state encountered: at cycle %d: %s\n",
curTick(), st);
455 inline void hwQ(flags f,
System *sys, uint64_t frame, std::string sm,
456 std::string q, uint64_t qid,
System *q_sys = NULL, int32_t count = 1)
461 int sysi = getSys(sys);
462 int qi = getQ(q_sys ? getSys(q_sys) : sysi, q, qid);
464 "hwQ: %s[%#x] cur size %d %d bytes: %d adding: %d\n",
465 q, qid, qSize[qi-1], qData[qi-1].size(), qBytes[qi-1], count);
466 doQ(sys,
FL_HW | f, 0, getSm(sysi, sm, frame), q, qi, count);
470 inline void hwDq(flags f,
System *sys, uint64_t frame, std::string sm,
471 std::string q, uint64_t qid,
System *q_sys = NULL, int32_t count = 1)
476 int sysi = getSys(sys);
477 int qi = getQ(q_sys ? getSys(q_sys) : sysi, q, qid);
479 "hwDQ: %s[%#x] cur size %d %d bytes: %d removing: %d\n",
480 q, qid, qSize[qi-1], qData[qi-1].size(), qBytes[qi-1], count);
481 doDq(sys,
FL_HW | f, 0, getSm(sysi,sm, frame), q, qi, count);
484 inline void hwPq(flags f,
System *sys, uint64_t frame, std::string sm,
485 std::string q, uint64_t qid,
System *q_sys = NULL, int32_t count = 1)
490 int sysi = getSys(sys);
491 int qi = getQ(q_sys ? getSys(q_sys) : sysi, q, qid);
493 "hwPQ: %s[%#x] cur size %d %d bytes: %d peeking: %d\n",
494 q, qid, qSize[qi-1], qData[qi-1].size(), qBytes[qi-1], count);
495 add(OP_PEEK,
FL_HW | f, 0, getSm(sysi, sm, frame), qi, count);
498 inline void hwRq(flags f,
System *sys, uint64_t frame, std::string sm,
499 std::string q, uint64_t qid,
System *q_sys = NULL, int32_t count = 1)
504 int sysi = getSys(sys);
505 int qi = getQ(q_sys ? getSys(q_sys) : sysi, q, qid);
507 "hwRQ: %s[%#x] cur size %d %d bytes: %d reserving: %d\n",
508 q, qid, qSize[qi-1], qData[qi-1].size(), qBytes[qi-1], count);
509 add(OP_RESERVE,
FL_HW | f, 0, getSm(sysi, sm, frame), qi, count);
512 inline void hwWf(flags f,
System *sys, uint64_t frame, std::string sm,
513 std::string q, uint64_t qid,
System *q_sys = NULL, int32_t count = 1)
518 int sysi = getSys(sys);
519 int qi = getQ(q_sys ? getSys(q_sys) : sysi, q, qid);
520 add(OP_WAIT_FULL,
FL_HW | f, 0, getSm(sysi, sm, frame), qi, count);
523 inline void hwWe(flags f,
System *sys, uint64_t frame, std::string sm,
524 std::string q, uint64_t qid,
System *q_sys = NULL, int32_t count = 1)
529 int sysi = getSys(sys);
530 int qi = getQ(q_sys ? getSys(q_sys) : sysi, q, qid);
531 add(OP_WAIT_EMPTY,
FL_HW | f, 0, getSm(sysi, sm, frame), qi, count);
556 #endif // !CP_ANNOTATE 558 #endif //__BASE__CP_ANNOTATE_HH__
void swExplictBegin(ThreadContext *tc, int32_t flags, Addr st_string)
void swWf(ThreadContext *tc, Addr id, Addr q_string, Addr sm_string, int32_t count)
void hwDq(flags f, System *sys, uint64_t frame, std::string sm, std::string q, uint64_t qid, System *q_sys=NULL, int32_t count=1)
void swWe(ThreadContext *tc, Addr id, Addr q_string, Addr sm_string, int32_t count)
void swSq(ThreadContext *tc, Addr id, Addr q_string, int32_t size, int32_t flags)
void swSmBegin(ThreadContext *tc, Addr sm_string, int32_t sm_id, int32_t flags)
void hwQ(flags f, System *sys, uint64_t frame, std::string sm, std::string q, uint64_t qid, System *q_sys=NULL, int32_t count=1)
Overload hash function for BasicBlockRange type.
void hwWe(flags f, System *sys, uint64_t frame, std::string sm, std::string q, uint64_t qid, System *q_sys=NULL, int32_t count=1)
ThreadContext is the external interface to all thread state for anything outside of the CPU...
void hwBegin(flags f, System *sys, uint64_t frame, std::string sm, std::string st)
uint64_t swGetId(ThreadContext *tc)
void swAutoBegin(ThreadContext *tc, Addr next_pc)
Tick curTick()
The current simulated tick.
void swAq(ThreadContext *tc, Addr id, Addr q_string, int32_t size)
void swQ(ThreadContext *tc, Addr id, Addr q_string, int32_t count)
std::map< std::pair< SwitchID, SwitchID >, LinkEntry > LinkMap
uint64_t Tick
Tick count type.
void swPq(ThreadContext *tc, Addr id, Addr q_string, int32_t count)
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
void swSmEnd(ThreadContext *tc, Addr sm_string)
void hwWf(flags f, System *sys, uint64_t frame, std::string sm, std::string q, uint64_t qid, System *q_sys=NULL, int32_t count=1)
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void swSyscallLink(ThreadContext *tc, Addr lsm_string, Addr sm_string)
void swLink(ThreadContext *tc, Addr lsm_string, Addr lsm_id, Addr sm_string)
Basic support for object serialization.
void swDq(ThreadContext *tc, Addr id, Addr q_string, int32_t count)
void swEnd(ThreadContext *tc)
void hwPq(flags f, System *sys, uint64_t frame, std::string sm, std::string q, uint64_t qid, System *q_sys=NULL, int32_t count=1)
virtual const std::string name() const
std::ostream CheckpointOut
void swIdentify(ThreadContext *tc, Addr smi_string)
void unserialize(ThreadContext &tc, CheckpointIn &cp)
void dump()
Dump all statistics data to the registered outputs.
void swRq(ThreadContext *tc, Addr id, Addr q_string, int32_t count)
void hwRq(flags f, System *sys, uint64_t frame, std::string sm, std::string q, uint64_t qid, System *q_sys=NULL, int32_t count=1)
Abstract superclass for simulation objects.