43 #ifndef __BASE__CP_ANNOTATE_HH__
44 #define __BASE__CP_ANNOTATE_HH__
50 #include <unordered_map>
56 #include "debug/AnnotateQ.hh"
57 #include "config/cp_annotate.hh"
58 #include "config/the_isa.hh"
63 #include "params/CPA.hh"
105 std::string
st) {
return; }
107 std::string
q, uint64_t qid,
System *q_sys = NULL,
108 int32_t
count = 1) {
return; }
110 std::string
q, uint64_t qid,
System *q_sys = NULL,
111 int32_t
count = 1) {
return; }
113 std::string
q, uint64_t qid,
System *q_sys = NULL,
114 int32_t
count = 1) {
return; }
116 std::string
q, uint64_t qid,
System *q_sys = NULL,
117 int32_t
count = 1) {
return; }
119 std::string
q, uint64_t qid,
System *q_sys = NULL,
120 int32_t
count = 1) {
return; }
122 std::string
q, uint64_t qid,
System *q_sys = NULL,
123 int32_t
count = 1) {
return; }
132 struct hash<std::pair<std::string, uint64_t> >
138 return hash<std::string>()(x.first);
147 typedef CPAParams Params;
152 OP_WAIT_EMPTY = 0x02,
156 OP_SIZE_QUEUE = 0x08,
189 return dynamic_cast<const Params *
>(_params);
209 typedef std::shared_ptr<AnnotateData> AnnDataPtr;
212 struct AnnotateHeader {
239 typedef std::unordered_map<std::string, int> SCache;
244 typedef std::unordered_map<Id, int> IdHCache;
251 typedef std::map<System*, std::pair<std::string, int> > NameCache;
255 typedef std::map<StackId, std::vector<int> > SmStack;
259 typedef std::map<StackId, bool> SwExpl;
261 typedef std::map<int,int> IMap;
266 typedef std::map<int, int>
LinkMap;
269 typedef std::unordered_map<Id, AnnDataPtr> ScHCache;
287 IdCache qCache, smCache;
305 void doDq(
System *sys,
int flags,
int cpu,
int sm, std::string
q,
int qi,
307 void doQ(
System *sys,
int flags,
int cpu,
int sm, std::string
q,
int qi,
310 void doSwSmEnd(
System *sys,
int cpuid, std::string
sm, uint64_t frame);
315 getSm(
int sysi, std::string
si, uint64_t
id)
318 Id smid = Id(si,
id);
320 smi = smCache[sysi-1][smid];
322 smCache[sysi-1][smid] = smi = ++numSm;
324 smMap.push_back(std::make_pair(sysi, smid));
332 getSt(std::string
sm, std::string
s)
338 smi = smtCache[
sm] = ++numSmt;
340 while (stCache.size() < smi) {
342 stCache.push_back(SCache());
347 sti = stCache[smi-1][
s];
349 stCache[smi-1][
s] = sti = ++numSt[smi-1];
357 NameCache::iterator
i = nameCache.find(s);
358 if (i == nameCache.end()) {
359 nameCache[
s] = std::make_pair(s->
name(), ++numSys);
360 i = nameCache.find(s);
365 qCache.push_back(IdHCache());
366 smCache.push_back(IdHCache());
367 scLinks.push_back(ScHCache());
369 return i->second.second;
375 getQ(
int sys, std::string
q, uint64_t
id)
380 qi = qCache[sys-1][qid];
382 qi = qCache[sys-1][qid] = ++numQs;
386 qData.push_back(AnnotateList());
388 qMap.push_back(std::make_pair(sys, qid));
393 void swBegin(
System *sys,
int cpuid, std::string
st, uint64_t frame,
396 AnnDataPtr add(
int t,
int f,
int c,
int sm,
int stq, int32_t
data=0);
410 std::map<std::string, SymbolTable*> userApp;
413 static CPA *
cpa() {
return _cpa; }
438 int sysi = getSys(sys);
439 int smi = getSm(sysi, sm, frame);
440 add(OP_BEGIN,
FL_HW | f, 0, smi, getSt(sm, st));
442 warn(
"BAD state encountered: at cycle %d: %s\n",
curTick(), st);
445 inline void hwQ(
flags f,
System *sys, uint64_t frame, std::string sm,
446 std::string q, uint64_t qid,
System *q_sys = NULL, int32_t
count = 1)
451 int sysi = getSys(sys);
452 int qi = getQ(q_sys ? getSys(q_sys) : sysi, q, qid);
454 "hwQ: %s[%#x] cur size %d %d bytes: %d adding: %d\n",
455 q, qid, qSize[qi-1], qData[qi-1].
size(), qBytes[qi-1],
count);
456 doQ(sys,
FL_HW | f, 0, getSm(sysi, sm, frame), q, qi,
count);
461 std::string q, uint64_t qid,
System *q_sys = NULL, int32_t
count = 1)
466 int sysi = getSys(sys);
467 int qi = getQ(q_sys ? getSys(q_sys) : sysi, q, qid);
469 "hwDQ: %s[%#x] cur size %d %d bytes: %d removing: %d\n",
470 q, qid, qSize[qi-1], qData[qi-1].
size(), qBytes[qi-1],
count);
471 doDq(sys,
FL_HW | f, 0, getSm(sysi,sm, frame), q, qi,
count);
475 std::string q, uint64_t qid,
System *q_sys = NULL, int32_t
count = 1)
480 int sysi = getSys(sys);
481 int qi = getQ(q_sys ? getSys(q_sys) : sysi, q, qid);
483 "hwPQ: %s[%#x] cur size %d %d bytes: %d peeking: %d\n",
484 q, qid, qSize[qi-1], qData[qi-1].
size(), qBytes[qi-1],
count);
485 add(OP_PEEK,
FL_HW | f, 0, getSm(sysi, sm, frame), qi,
count);
489 std::string q, uint64_t qid,
System *q_sys = NULL, int32_t
count = 1)
494 int sysi = getSys(sys);
495 int qi = getQ(q_sys ? getSys(q_sys) : sysi, q, qid);
497 "hwRQ: %s[%#x] cur size %d %d bytes: %d reserving: %d\n",
498 q, qid, qSize[qi-1], qData[qi-1].
size(), qBytes[qi-1],
count);
499 add(OP_RESERVE,
FL_HW | f, 0, getSm(sysi, sm, frame), qi,
count);
503 std::string q, uint64_t qid,
System *q_sys = NULL, int32_t
count = 1)
508 int sysi = getSys(sys);
509 int qi = getQ(q_sys ? getSys(q_sys) : sysi, q, qid);
510 add(OP_WAIT_FULL,
FL_HW | f, 0, getSm(sysi, sm, frame), qi,
count);
514 std::string q, uint64_t qid,
System *q_sys = NULL, int32_t
count = 1)
519 int sysi = getSys(sys);
520 int qi = getQ(q_sys ? getSys(q_sys) : sysi, q, qid);
521 add(OP_WAIT_EMPTY,
FL_HW | f, 0, getSm(sysi, sm, frame), qi,
count);
546 #endif // !CP_ANNOTATE
548 #endif //__BASE__CP_ANNOTATE_HH__
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 swLink(ThreadContext *tc)
void swPq(ThreadContext *tc)
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)
void swIdentify(ThreadContext *tc)
void swSmEnd(ThreadContext *tc)
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)
void swWf(ThreadContext *tc)
uint64_t swGetId(ThreadContext *tc)
void swAutoBegin(ThreadContext *tc, Addr next_pc)
void swDq(ThreadContext *tc)
Tick curTick()
The current simulated tick.
void swSq(ThreadContext *tc)
std::map< std::pair< SwitchID, SwitchID >, LinkEntry > LinkMap
uint64_t Tick
Tick count type.
void swWe(ThreadContext *tc)
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.
Basic support for object serialization.
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 swSyscallLink(ThreadContext *tc)
void swRq(ThreadContext *tc)
void swExplictBegin(ThreadContext *tc)
void serialize(CheckpointOut &cp) const override
void dump()
Dump all statistics data to the registered outputs.
void swAq(ThreadContext *tc)
void unserialize(CheckpointIn &cp) override
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.
void swSmBegin(ThreadContext *tc)
void swQ(ThreadContext *tc)