38 #include <unordered_map> 44 #include "debug/Checkpoint.hh" 68 mainEventQueue.push_back(
72 return mainEventQueue[
index];
89 return csprintf(
"Event_%d", instance);
91 return csprintf(
"Event_%x", (uintptr_t)
this);
102 if (!curr || *event < *curr) {
121 if (!head || *event <= *head) {
130 while (curr && *curr < *event) {
158 while (event != next) {
160 panic(
"event not found!");
175 panic(
"event not found!");
177 assert(event->
queue ==
this);
181 if (*head == *event) {
189 while (curr && *curr < *event) {
194 if (!curr || *curr != *event)
195 panic(
"event not found!");
206 std::lock_guard<EventQueue>
lock(*
this);
224 if (!
event->squashed()) {
226 setCurTick(
event->when());
229 if (
event->isExitEvent()) {
248 short _flags = flags;
255 assert(!scheduled());
269 assert(initialized());
271 flags.set(Initialized);
276 if (flags.isSet(Scheduled) && !flags.isSet(Squashed)) {
277 flags.clear(Squashed | Scheduled);
279 DPRINTF(Checkpoint,
"Event '%s' need to be scheduled @%d\n",
296 cprintf(
"============================================================\n");
298 cprintf(
"------------------------------------------------------------\n");
303 Event *nextBin = head;
305 Event *nextInBin = nextBin;
315 cprintf(
"============================================================\n");
321 std::unordered_map<long, bool> map;
326 Event *nextBin = head;
328 Event *nextInBin = nextBin;
330 if (nextInBin->
when() < time) {
331 cprintf(
"time goes backwards!");
334 }
else if (nextInBin->
when() == time &&
341 if (map[reinterpret_cast<long>(nextInBin)]) {
346 map[
reinterpret_cast<long>(nextInBin)] =
true;
348 time = nextInBin->
when();
372 mainEventQueue[
i]->dump();
396 description(), action, when());
403 cprintf(
"Flags: %#x\n", flags);
405 cprintf(
"Created: %d\n", whenCreated);
409 cprintf(
"Scheduled at %d\n", whenScheduled);
411 cprintf(
"Scheduled for %d, priority %d\n", when(), _priority);
418 : objName(
n), head(NULL), _curTick(0)
425 async_queue_mutex.lock();
426 async_queue.push_back(event);
427 async_queue_mutex.unlock();
434 async_queue_mutex.lock();
436 while (!async_queue.empty()) {
437 insert(async_queue.front());
438 async_queue.pop_front();
441 async_queue_mutex.unlock();
#define panic(...)
This implements a cprintf based panic() function.
void serialize(CheckpointOut &cp) const override
Serialize an object.
EventQueue * getEventQueue(uint32_t index)
Function for returning eventq queue for the provided index.
void dump() const
Dump the current event data.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
const std::string & name()
Tick when() const
Get the time that the event is scheduled.
static const FlagsType Managed
void asyncInsert(Event *event)
Function for adding events to the async queue.
virtual const std::string name() const
static Event * insertBefore(Event *event, Event *curr)
vector< EventQueue * > mainEventQueue
Array for main event queues.
Overload hash function for BasicBlockRange type.
void insert(Event *event)
Insert / remove event from the queue.
bool inParallelMode
Current mode of execution: parallel / serial.
EventQueue(const EventQueue &)
static const FlagsType Squashed
#define UNSERIALIZE_SCALAR(scalar)
void remove(Event *event)
Tick curTick()
The current simulated tick.
std::string csprintf(const char *format, const Args &...args)
Queue of events sorted in time order.
static const FlagsType Scheduled
virtual const char * description() const
Return a C string describing the event.
uint64_t Tick
Tick count type.
EventQueue * curEventQueue()
int64_t Counter
Statistics counter type.
Priority priority() const
Get the event priority.
void checkpointReschedule(Event *event)
Reschedule an event after a checkpoint.
#define SERIALIZE_SCALAR(scalar)
Event * replaceHead(Event *s)
function for replacing the head of the event queue, so that a different set of events can run without...
void handleAsyncInsertions()
Function for moving events from the async_queue to the main queue.
std::ostream CheckpointOut
#define DPRINTF_UNCONDITIONAL(x,...)
uint32_t numMainEventQueues
Current number of allocated main event queues.
static Event * removeItem(Event *event, Event *last)
virtual void trace(const char *action)
trace event activity
__thread EventQueue * _curEventQueue
The current event queue for the running thread.
static Counter instanceCounter
Global counter to generate unique IDs for Event instances.
EventQueue * queue
queue to which this event belongs (though it may or may not be scheduled on this queue yet) ...
Tick simQuantum
Simulation Quantum for multiple eventq simulation.
void cprintf(const char *format, const Args &...args)
static const FlagsType IsMainQueue