37#include <unordered_map>
43#include "debug/Checkpoint.hh"
96 if (!curr || *
event < *curr) {
150 while (curr && *curr < *
event) {
178 while (
event != next) {
180 panic(
"event not found!");
195 panic(
"event not found!");
197 assert(
event->queue ==
this);
209 while (curr && *curr < *
event) {
214 if (!curr || *curr != *
event)
215 panic(
"event not found!");
226 std::lock_guard<EventQueue>
lock(*
this);
244 if (!
event->squashed()) {
248 event->trace(
"executed");
250 if (
event->isExitEvent()) {
269 short _flags =
flags;
300 DPRINTF(Checkpoint,
"Event '%s' need to be scheduled @%d\n",
317 cprintf(
"============================================================\n");
319 cprintf(
"------------------------------------------------------------\n");
326 Event *nextInBin = nextBin;
336 cprintf(
"============================================================\n");
342 std::unordered_map<long, bool> map;
349 Event *nextInBin = nextBin;
351 if (nextInBin->
when() < time) {
352 cprintf(
"time goes backwards!");
355 }
else if (nextInBin->
when() == time &&
362 if (map[
reinterpret_cast<long>(nextInBin)]) {
367 map[
reinterpret_cast<long>(nextInBin)] =
true;
369 time = nextInBin->
when();
422 return csprintf(
"%#x", (uintptr_t)
this);
432 cprintf(
"Created: %d\n", whenCreated);
436 cprintf(
"Scheduled at %d\n", whenScheduled);
445 : objName(
n), head(NULL), _curTick(0)
static const FlagsType Squashed
static const FlagsType IsMainQueue
static const FlagsType Initialized
static const FlagsType Managed
static const FlagsType Scheduled
Queue of events sorted in time order.
EventQueue(const EventQueue &)
void handleAsyncInsertions()
Function for moving events from the async_queue to the main queue.
std::list< Event * > async_queue
List of events added by other threads to this event queue.
void setCurTick(Tick newVal)
void asyncInsert(Event *event)
Function for adding events to the async queue.
friend void curEventQueue(EventQueue *)
void lock()
Provide an interface for locking/unlocking the event queue.
void checkpointReschedule(Event *event)
Reschedule an event after a checkpoint.
void insert(Event *event)
Insert / remove event from the queue.
Event * replaceHead(Event *s)
function for replacing the head of the event queue, so that a different set of events can run without...
void remove(Event *event)
UncontendedMutex async_queue_mutex
Mutex to protect async queue.
Priority _priority
event priority
static Event * removeItem(Event *event, Event *last)
virtual void acquireImpl()
virtual void releaseImpl()
void acquire()
Memory management hooks for events that have the Managed flag set.
static Event * insertBefore(Event *event, Event *curr)
void release()
Managed event removed from the event queue.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
static Counter instanceCounter
Global counter to generate unique IDs for Event instances.
Counter instance
This event's unique ID.
Tick _when
timestamp when event should be processed
const std::string instanceString() const
Return the instance number as a string.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void dump() const
This is a debugging function which will print everything on the event queue.
virtual void trace(const char *action)
This function isn't really useful if TRACING_ON is not defined.
virtual const std::string name() const
bool scheduled() const
Determine if the current event is scheduled.
void dump() const
Dump the current event data.
Priority priority() const
Get the event priority.
bool empty() const
Returns true if no events are queued.
virtual const char * description() const
Return a C string describing the event.
Tick when() const
Get the time that the event is scheduled.
void set(Type mask)
Set all flag's bits matching the given mask.
bool isSet(Type mask) const
Verifies whether any bit matching the given mask is set.
void clear()
Clear all flag's bits.
#define panic(...)
This implements a cprintf based panic() function.
Bitfield< 3, 0 > priority
double Counter
All counters are of 64-bit values.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Tick simQuantum
Simulation Quantum for multiple eventq simulation.
void cprintf(const char *format, const Args &...args)
Tick curTick()
The universal simulation clock.
std::ostream CheckpointOut
__thread EventQueue * _curEventQueue
The current event queue for the running thread.
uint64_t Tick
Tick count type.
uint32_t numMainEventQueues
Current number of allocated main event queues.
std::string csprintf(const char *format, const Args &...args)
bool inParallelMode
Current mode of execution: parallel / serial.
EventQueue * getEventQueue(uint32_t index)
Function for returning eventq queue for the provided index.
std::vector< EventQueue * > mainEventQueue
Array for main event queues.
#define UNSERIALIZE_SCALAR(scalar)
#define SERIALIZE_SCALAR(scalar)