36 #include <unordered_map> 42 #include "debug/Checkpoint.hh" 65 mainEventQueue.push_back(
69 return mainEventQueue[
index];
85 return csprintf(
"Event_%s", instanceString());
95 if (!curr || *event < *curr) {
114 if (!head || *event <= *head) {
123 while (curr && *curr < *event) {
151 while (event != next) {
153 panic(
"event not found!");
168 panic(
"event not found!");
170 assert(event->
queue ==
this);
174 if (*head == *event) {
182 while (curr && *curr < *event) {
187 if (!curr || *curr != *event)
188 panic(
"event not found!");
199 std::lock_guard<EventQueue>
lock(*
this);
217 if (!
event->squashed()) {
219 setCurTick(
event->when());
221 event->trace(
"executed");
223 if (
event->isExitEvent()) {
242 short _flags = flags;
249 assert(!scheduled());
263 assert(initialized());
265 flags.set(Initialized);
270 if (flags.isSet(Scheduled) && !flags.isSet(Squashed)) {
271 flags.clear(Squashed | Scheduled);
273 DPRINTF(Checkpoint,
"Event '%s' need to be scheduled @%d\n",
290 cprintf(
"============================================================\n");
292 cprintf(
"------------------------------------------------------------\n");
297 Event *nextBin = head;
299 Event *nextInBin = nextBin;
309 cprintf(
"============================================================\n");
315 std::unordered_map<long, bool> map;
320 Event *nextBin = head;
322 Event *nextInBin = nextBin;
324 if (nextInBin->
when() < time) {
325 cprintf(
"time goes backwards!");
328 }
else if (nextInBin->
when() == time &&
335 if (map[reinterpret_cast<long>(nextInBin)]) {
340 map[
reinterpret_cast<long>(nextInBin)] =
true;
342 time = nextInBin->
when();
366 mainEventQueue[
i]->dump();
390 description(), instanceString(), action, when());
399 return csprintf(
"%#x", (uintptr_t)
this);
407 cprintf(
"Flags: %#x\n", flags);
409 cprintf(
"Created: %d\n", whenCreated);
413 cprintf(
"Scheduled at %d\n", whenScheduled);
415 cprintf(
"Scheduled for %d, priority %d\n", when(), _priority);
422 : objName(
n), head(NULL), _curTick(0)
429 async_queue_mutex.lock();
430 async_queue.push_back(event);
431 async_queue_mutex.unlock();
438 async_queue_mutex.lock();
440 while (!async_queue.empty()) {
441 insert(async_queue.front());
442 async_queue.pop_front();
445 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 unserialize(CheckpointIn &cp) override
Unserialize an object.
const std::string & name()
void dump() const
Dump the current event data.
static const FlagsType Managed
void asyncInsert(Event *event)
Function for adding events to the async queue.
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 &)
Priority priority() const
Get the event priority.
static const FlagsType Squashed
#define UNSERIALIZE_SCALAR(scalar)
void remove(Event *event)
Tick curTick()
The current simulated tick.
virtual const std::string name() const
std::string csprintf(const char *format, const Args &...args)
Queue of events sorted in time order.
const std::string instanceString() const
Return the instance number as a string.
static const FlagsType Scheduled
uint64_t Tick
Tick count type.
void dump() const
This is a debugging function which will print everything on the event queue.
EventQueue * curEventQueue()
virtual const char * description() const
Return a C string describing the event.
int64_t Counter
Statistics counter type.
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...
virtual void trace(const char *action)
This function isn't really useful if TRACING_ON is not defined.
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)
__thread EventQueue * _curEventQueue
The current event queue for the running thread.
Tick when() const
Get the time that the event is scheduled.
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