38 #ifndef __SIM_EVENTQ_HH__ 39 #define __SIM_EVENTQ_HH__ 52 #include "debug/Event.hh" 97 typedef ::Flags<FlagsType>
Flags;
214 static Counter instanceCounter;
263 return flags.
isSet(_flags);
288 virtual void trace(
const char *action);
346 : nextBin(nullptr), nextInBin(nullptr), _when(0), _priority(
p),
351 instance = ++instanceCounter;
361 virtual const std::string
name()
const;
366 virtual const char *description()
const;
382 virtual void process() = 0;
557 doMigrate((&new_eq != &old_eq)&&_doMigrate)
610 virtual const std::string
name()
const {
return objName; }
619 void deschedule(
Event *event);
623 void reschedule(
Event *event,
Tick when,
bool always =
false);
639 if (nextTick() > when)
654 bool empty()
const {
return head == NULL; }
658 bool debugVerify()
const;
661 void handleAsyncInsertions();
700 void lock() { service_mutex.lock(); }
701 void unlock() { service_mutex.unlock(); }
715 void checkpointReschedule(
Event *event);
720 deschedule(getHead());
787 template <
class T,
void (T::* F)()>
813 return object->name() +
".wrapped_event";
827 const std::string &
name,
830 :
Event(
p), callback(callback), _name(name)
841 return _name +
".wrapped_function_event";
844 const char *
description()
const {
return "EventFunctionWrapped"; }
847 #endif // __SIM_EVENTQ_HH__
EventQueue * eventq
A pointer to this object's event queue.
virtual void wakeup(Tick when=(Tick) -1)
Function to signal that the event loop should be woken up because an event has been scheduled by an a...
EventFunctionWrapper(const std::function< void(void)> &callback, const std::string &name, bool del=false, Priority p=Default_Pri)
static const Priority Progress_Event_Pri
Progress events come at the end.
bool isManaged() const
Check whether this event will auto-delete.
uint32_t numMainEventQueues
Current number of allocated main event queues.
bool isAutoDelete() const
const std::string & name()
void deschedule(Event *event)
Deschedule the specified event.
void wakeupEventQueue(Tick when=(Tick) -1)
virtual void acquireImpl()
Tick when() const
Get the time that the event is scheduled.
static const FlagsType Managed
Counter instance
This event's unique ID.
::Flags< FlagsType > Flags
static const Priority CPU_Tick_Pri
CPU ticks must come after other associated CPU events (such as writebacks).
void deschedule(Event *event)
static const Priority CPU_Switch_Pri
CPU switches schedule the new CPU's tick event for the same cycle (after unscheduling the old CPU's t...
EventManager(EventManager *em)
void setCurTick(Tick newVal)
Tick _when
timestamp when event should be processed
void schedule(Event *event, Tick when)
Priority _priority
event priority
static const Priority Debug_Break_Pri
Breakpoints should happen before anything else (except enabling trace output), so we don't miss any a...
std::function< void(void)> callback
static const FlagsType Initialized
ScopedMigration(EventQueue *_new_eq, bool _doMigrate=true)
static const FlagsType PublicRead
EventQueue * getEventQueue(uint32_t index)
Function for returning eventq queue for the provided index.
void acquire()
Memory management hooks for events that have the Managed flag set.
void setWhen(Tick when, EventQueue *q)
void deschedule(Event &event)
bool operator>(const Event &l, const Event &r)
bool squashed() const
Check whether the event is squashed.
static const FlagsType AutoDelete
static const FlagsType Squashed
static const Priority Serialize_Pri
Serailization needs to occur before tick events also, so that a serialize/unserialize is identical to...
Tick curTick()
The current simulated tick.
Temporarily migrate execution to a different event queue.
void reschedule(Event *event, Tick when, bool always=false)
Reschedule the specified event.
bool scheduled() const
Determine if the current event is scheduled.
Queue of events sorted in time order.
const char * description() const
Return a C string describing the event.
static const FlagsType Scheduled
uint64_t Tick
Tick count type.
Tick simQuantum
Simulation Quantum for multiple eventq simulation.
EventWrapper(T *obj, bool del=false, Priority p=Default_Pri)
virtual BaseGlobalEvent * globalEvent()
If this is part of a GlobalEvent, return the pointer to the Global Event.
static const Priority Sim_Exit_Pri
If we want to exit on this cycle, it's the very last thing we do.
const char * description() const
Return a C string describing the event.
void reschedule(Event *event, Tick when, bool always=false)
EventQueue * curEventQueue()
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
bool operator>=(const Event &l, const Event &r)
void serviceEvents(Tick when)
void setFlags(Flags _flags)
Accessor for flags.
const std::string name() const
EventManager(EventQueue *eq)
static const FlagsType Reserved0
This used to be AutoSerialize.
void setCurTick(Tick newVal)
void squash()
Squash the current event.
bool operator<=(const Event &l, const Event &r)
Flags getFlags() const
Accessor for flags.
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
virtual void releaseImpl()
int64_t Counter
Statistics counter type.
bool isFlagSet(Flags _flags) const
bool operator!=(const Event &l, const Event &r)
std::mutex async_queue_mutex
Mutex to protect async queue.
std::mutex service_mutex
Lock protecting event handling.
Basic support for object serialization.
bool inParallelMode
Current mode of execution: parallel / serial.
Priority priority() const
Get the event priority.
void clearFlags(Flags _flags)
void reschedule(Event &event, Tick when, bool always=false)
bool isExitEvent() const
See if this is a SimExitEvent (without resorting to RTTI)
EventQueue * eventQueue() const
Event(Priority p=Default_Pri, Flags f=0)
const std::string name() const
std::ostream CheckpointOut
void schedule(Event *event, Tick when, bool global=false)
Schedule the given event on this queue.
ScopedRelease(EventQueue *_eq)
void schedule(Event &event, Tick when)
static const Priority Default_Pri
Default is zero for historical reasons.
static const Priority Minimum_Pri
Event priorities, to provide tie-breakers for events scheduled at the same cycle. ...
__thread EventQueue * _curEventQueue
The current event queue for the running thread.
void unserialize(ThreadContext &tc, CheckpointIn &cp)
virtual const std::string name() const
void release()
Managed event removed from the event queue.
static const FlagsType PublicWrite
void lock()
Provide an interface for locking/unlocking the event queue.
void dump()
Dump all statistics data to the registered outputs.
Common base class for GlobalEvent and GlobalSyncEvent.
static const Priority DVFS_Update_Pri
DVFS update event leads to stats dump therefore given a lower priority to ensure all relevant states ...
Common base class for Event and GlobalEvent, so they can share flag and priority definitions and acce...
Temporarily release the event queue service lock.
void name(const std::string &st)
static const Priority Delayed_Writeback_Pri
For some reason "delayed" inter-cluster writebacks are scheduled before regular writebacks (which hav...
std::list< Event * > async_queue
List of events added by other threads to this event queue.
EventWrapper(T &obj, bool del=false, Priority p=Default_Pri)
std::vector< EventQueue * > mainEventQueue
Array for main event queues.
static const Priority Debug_Enable_Pri
If we enable tracing on a particular cycle, do that as the very first thing so we don't miss any of t...
static const Priority Stat_Event_Pri
Statistics events (dump, reset, etc.) come after everything else, but before exit.
static const FlagsType IsExitEvent
bool operator<(const Event &l, const Event &r)
EventQueue * queue
queue to which this event belongs (though it may or may not be scheduled on this queue yet) ...
EventManager(EventManager &em)
static const Priority Maximum_Pri
Maximum priority.
bool operator==(const Event &l, const Event &r)
static const FlagsType IsMainQueue
static const Priority CPU_Exit_Pri
If we want to exit a thread in a CPU, it comes after CPU_Tick_Pri.
static const FlagsType InitMask