35#ifndef __SIM_EVENTQ_HH__
36#define __SIM_EVENTQ_HH__
54#include "debug/Event.hh"
103 typedef ::gem5::Flags<FlagsType>
Flags;
355 virtual void trace(
const char *action);
427 virtual const std::string
name()
const;
525 return l.when() <
r.when() ||
526 (
l.when() ==
r.when() &&
l.priority() <
r.priority());
535 return l.when() >
r.when() ||
536 (
l.when() ==
r.when() &&
l.priority() >
r.priority());
545 return l.when() <
r.when() ||
546 (
l.when() ==
r.when() &&
l.priority() <=
r.priority());
555 return l.when() >
r.when() ||
556 (
l.when() ==
r.when() &&
l.priority() >=
r.priority());
565 return l.when() ==
r.when() &&
l.priority() ==
r.priority();
574 return l.when() !=
r.when() ||
l.priority() !=
r.priority();
760 assert(!
event->scheduled());
761 assert(
event->initialized());
763 event->setWhen(when,
this);
781 event->trace(
"scheduled");
792 assert(
event->scheduled());
793 assert(
event->initialized());
802 event->trace(
"descheduled");
817 assert(always ||
event->scheduled());
818 assert(
event->initialized());
821 if (
event->scheduled()) {
827 event->setWhen(when,
this);
833 event->trace(
"rescheduled");
1094 static_assert(std::is_same_v<void, MemberFunctionReturn_t<F>>);
1095 static_assert(std::is_same_v<MemberFunctionArgsTuple_t<F>, std::tuple<>>);
1098 [[deprecated(
"Use reference version of this constructor instead")]]
1116 Named(object.
name() +
".wrapped_event"),
1132template <
class T,
void (T::* F)()>
1133using EventWrapper [[deprecated(
"Use MemberEventWrapper instead")]]
1150 const std::string &
name,
1170 return _name +
".wrapped_function_event";
1184#define SERIALIZE_EVENT(event) event.serializeSection(cp, #event);
1191#define UNSERIALIZE_EVENT(event) \
1193 event.unserializeSection(cp, #event); \
1194 eventQueue()->checkpointReschedule(&event); \
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Common base class for GlobalEvent and GlobalSyncEvent.
Common base class for Event and GlobalEvent, so they can share flag and priority definitions and acce...
static const FlagsType Squashed
::gem5::Flags< FlagsType > Flags
static const FlagsType IsMainQueue
static const FlagsType Initialized
static const FlagsType Managed
static const FlagsType Scheduled
static const FlagsType AutoDelete
static const FlagsType PublicWrite
static const FlagsType PublicRead
static const FlagsType InitMask
static const FlagsType Reserved0
This used to be AutoSerialize.
static const FlagsType IsExitEvent
std::function< void(void)> callback
void setCurTick(Tick newVal)
EventQueue * eventq
A pointer to this object's event queue.
ScopedRelease(EventQueue *_eq)
Temporarily release the event queue service lock.
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.
UncontendedMutex service_mutex
Lock protecting event handling.
Priority _priority
event priority
static Event * removeItem(Event *event, Event *last)
virtual void acquireImpl()
bool isFlagSet(Flags _flags) const
virtual BaseGlobalEvent * globalEvent()
If this is part of a GlobalEvent, return the pointer to the Global Event.
void setWhen(Tick when, EventQueue *q)
EventQueue * queue
queue to which this event belongs (though it may or may not be scheduled on this queue yet)
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 setFlags(Flags _flags)
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.
Event(Priority p=Default_Pri, Flags f=0)
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 clearFlags(Flags _flags)
Wrap a member function inside MemberEventWrapper to use it as an event callback.
MemberEventWrapper(CLASS &object, bool del=false, Priority p=Default_Pri)
Construct a new MemberEventWrapper object.
const char * description() const override
Return a C string describing the event.
MemberFunctionClass_t< F > CLASS
MemberEventWrapper(CLASS *object, bool del=false, Priority p=Default_Pri)
Interface for things with names.
virtual std::string name() const
Basic support for object serialization.
EventManager(EventQueue *eq)
void dump() const
This is a debugging function which will print everything on the event queue.
const std::string name() const
ScopedMigration(EventQueue *_new_eq, bool _doMigrate=true)
Temporarily migrate execution to a different event queue.
void reschedule(Event *event, Tick when, bool always=false)
Reschedule the specified event.
static const Priority Delayed_Writeback_Pri
For some reason "delayed" inter-cluster writebacks are scheduled before regular writebacks (which hav...
void schedule(Event *event, Tick when, bool global=false)
Schedule the given event on this queue.
static const Priority Debug_Break_Pri
Breakpoints should happen before anything else (except enabling trace output), so we don't miss any a...
void schedule(Event *event, Tick when)
void deschedule(Event *event)
Deschedule the specified event.
void deschedule(Event &event)
static const Priority Maximum_Pri
Maximum priority.
EventFunctionWrapper(const std::function< void(void)> &callback, const std::string &name, bool del=false, Priority p=Default_Pri)
This function wraps a function into an event, to be executed later.
bool isAutoDelete() const
The function returns true if the object is automatically deleted after the event is processed.
void name(const std::string &st)
void wakeupEventQueue(Tick when=(Tick) -1)
This function is not needed by the usual gem5 event loop but may be necessary in derived EventQueues ...
void serviceEvents(Tick when)
process all events up to the given timestamp.
void deschedule(Event *event)
virtual const std::string name() const
virtual const std::string name() const
bool scheduled() const
Determine if the current event is scheduled.
void reschedule(Event *event, Tick when, bool always=false)
void squash()
Squash the current event.
Tick getCurTick() const
While curTick() is useful for any object assigned to this event queue, if an object that is assigned ...
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...
void schedule(Event &event, Tick when)
EventManager(EventManager &em)
Event manger manages events in the event queue.
void dump() const
Dump the current event data.
Priority priority() const
Get the event priority.
bool isManaged() const
Check whether this event will auto-delete.
static const Priority Sim_Exit_Pri
If we want to exit on this cycle, it's the very last thing we do.
EventManager(EventManager *em)
static const Priority Progress_Event_Pri
Progress events come at the end.
const char * description() const
Return a C string describing the event.
void reschedule(Event &event, Tick when, bool always=false)
bool empty() const
Returns true if no events are queued.
static const Priority CPU_Tick_Pri
CPU ticks must come after other associated CPU events (such as writebacks).
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...
virtual const char * description() const
Return a C string describing the event.
Tick when() const
Get the time that the event is scheduled.
static const Priority Default_Pri
Default is zero for historical reasons.
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 Serialize_Pri
Serailization needs to occur before tick events also, so that a serialize/unserialize is identical to...
EventQueue * eventQueue() const
static const Priority CPU_Exit_Pri
If we want to exit a thread in a CPU, it comes after CPU_Tick_Pri.
static const Priority Stat_Event_Pri
Statistics events (dump, reset, etc.) come after everything else, but before exit.
bool squashed() const
Check whether the event is squashed.
static const Priority Minimum_Pri
Event priorities, to provide tie-breakers for events scheduled at the same cycle.
bool isExitEvent() const
See if this is a SimExitEvent (without resorting to RTTI)
static const Priority DVFS_Update_Pri
DVFS update event leads to stats dump therefore given a lower priority to ensure all relevant states ...
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.
bool noneSet(Type mask) const
Verifies whether no bits matching the given mask are set.
#define gem5_assert(cond,...)
The assert macro will function like a normal assert, but will use panic instead of straight abort().
__thread Tick * _curTickPtr
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.
bool operator>(const Time &l, const Time &r)
static bool operator==(const PCStateBase &a, const PCStateBase &b)
Tick curTick()
The universal simulation clock.
typename MemberFunctionSignature< decltype(F)>::class_t MemberFunctionClass_t
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.
static bool operator!=(const PCStateBase &a, const PCStateBase &b)
bool operator>=(const Time &l, const Time &r)
bool operator<(const Time &l, const Time &r)
EventQueue * curEventQueue()
bool operator<=(const Time &l, const Time &r)
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.