struct
#include <src/vt/scheduler/scheduler.h>
Scheduler A core VT component that schedules work generated from other components. The pieces of work waiting to execute may be prioritized, see src/
Tracks work to be completed, orders it by priority, and executes it. Polls components for incoming work.
Base classes
-
template<typename T>struct vt::runtime::component::Component<Scheduler>
Component
class for a generic VT runtime module, CRTP'ed over the component's actual type
Public types
- struct SchedulerLoopGuard
- using SchedulerEventType = SchedulerEvent
- using TriggerType = std::function<void()>
- using TriggerContainerType = std::list<TriggerType>
- using EventTriggerContType = std::vector<TriggerContainerType>
-
using RunnablePtrType = runnable::
RunnableNew* - using UnitType = Unit
Public static functions
- static void checkTermSingleNode()
- Check for termination when running on a single node.
Constructors, destructors, conversion operators
Public functions
- auto name() -> std::string override
- Get the name of the component.
- void preDiagnostic() override
- Pre-diagnostic hook; this fires before finalize but after all work is done and the system is about to shut down.
- void startup() override
- Empty default overridden startup method.
- auto shouldCallProgress(int32_t processed_since_last_progress, TimeType time_since_last_progress) const -> bool
- Check if progress function needs to be called.
- void runSchedulerOnceImpl(bool msg_only = false)
- Turn the scheduler.
- void runProgress(bool msg_only = false, TimeType current_time = TimeType{0.0})
- Run the progress function.
- void runSchedulerWhile(std::function<bool()> cond)
- Runs the scheduler until a condition is met.
- void registerTrigger(SchedulerEventType const& event, TriggerType trigger)
- Register a trigger with the scheduler.
- void registerTriggerOnce(SchedulerEventType const& event, TriggerType trigger)
- Register a trigger once with the scheduler.
- void triggerEvent(SchedulerEventType const& event)
- Trigger an event.
- auto hasSchedRun() const -> bool
- Check if the scheduler has run, polling all components at least once.
-
template<typename RunT>void enqueue(RunT r)
- Enqueue an action to execute later with the default priority
default_priority
. -
template<typename RunT>void enqueue(PriorityType priority, RunT r)
- Enqueue an runnable with a priority to execute later.
- void printMemoryUsage()
- Print current memory usage.
-
template<typename RunT>void enqueue(bool is_term, RunT r)
- Enqueue an action without a message.
-
template<typename MsgT, typename RunT>void enqueue(MsgT* msg, RunT r)
- Enqueue an action associated with a prioritized message. The action will be enqueued with the priority found on the message.
-
template<typename MsgT, typename RunT>void enqueue(messaging::
MsgSharedPtr<MsgT> const& msg, RunT r) - Enqueue an runnable associated with a prioritized message. The action will be enqueued with the priority found on the message.
- auto workQueueSize() const -> std::size_t
- Get the work queue size.
- auto workQueueEmpty() const -> bool
- Query if the work queue is empty.
- auto isIdle() const -> bool
- Check if the scheduler is idle.
- auto isIdleMinusTerm() const -> bool
- Check if the scheduler is idle minus termination messages.
- void suspend(ThreadIDType tid, RunnablePtrType runnable, PriorityType p = default_priority)
- Suspend a thread with an ID and runnable.
- void resume(ThreadIDType tid)
- Resume a thread that is associated with a runnable that is currently suspended.
- auto getRecentTime() -> TimeType
- Return a valid recent time, after checking whether an update is needed.
- void setRecentTimeToStale()
- Set the flag so that recent_time_ will be updated at next get request.
- auto getSchedulerDepth() const -> unsigned int
- Get the current recursive scheduler depth.
-
template<typename SerializerT>void serialize(SerializerT& s)
-
template<typename RunT>void enqueue(] PriorityType priority, RunT r)
Friends
-
template<typename Callable>void vt::runInEpochRooted(Callable&& fn)
-
template<typename Callable>void vt::runInEpochCollective(Callable&& fn)
Function documentation
void vt:: sched:: Scheduler:: preDiagnostic() override
Pre-diagnostic hook; this fires before finalize but after all work is done and the system is about to shut down.
\internalThis is typically used to compute some final timings that the system might use to output time-based diagnostic metrics
bool vt:: sched:: Scheduler:: shouldCallProgress(int32_t processed_since_last_progress,
TimeType time_since_last_progress) const
Check if progress function needs to be called.
Parameters | |
---|---|
processed_since_last_progress in | number of units processed since last progress |
time_since_last_progress in | time since last progress |
Returns | whether progress needs to be called |
void vt:: sched:: Scheduler:: runSchedulerOnceImpl(bool msg_only = false)
Turn the scheduler.
Parameters | |
---|---|
msg_only in | whether to only make progress on the core active messenger |
Polls every component that might generate or complete work, and potentially runs one piece of available work.
void vt:: sched:: Scheduler:: runProgress(bool msg_only = false,
TimeType current_time = TimeType{0.0})
Run the progress function.
Parameters | |
---|---|
msg_only in | whether to only make progress on the core active messenger |
current_time in | current time |
void vt:: sched:: Scheduler:: runSchedulerWhile(std::function<bool()> cond)
Runs the scheduler until a condition is met.
Parameters | |
---|---|
cond in | condition to turn scheduler until met |
Runs the scheduler until a condition is met. This form SHOULD be used instead of "while (..) { runSchedulerOnceImpl(..) }" in all cases of nested scheduler loops, such as during a barrier, in order to ensure proper event unwinding and idle time tracking.
void vt:: sched:: Scheduler:: registerTrigger(SchedulerEventType const& event,
TriggerType trigger)
Register a trigger with the scheduler.
Parameters | |
---|---|
event in | event to trigger on |
trigger in | function to trigger |
void vt:: sched:: Scheduler:: registerTriggerOnce(SchedulerEventType const& event,
TriggerType trigger)
Register a trigger once with the scheduler.
Parameters | |
---|---|
event in | event to trigger on |
trigger in | function to trigger |
void vt:: sched:: Scheduler:: triggerEvent(SchedulerEventType const& event)
Trigger an event.
Parameters | |
---|---|
event in | the event to trigger |
bool vt:: sched:: Scheduler:: hasSchedRun() const
Check if the scheduler has run, polling all components at least once.
Returns | whether the scheduler has advanced |
---|
template<typename RunT>
void vt:: sched:: Scheduler:: enqueue(RunT r)
Enqueue an action to execute later with the default priority default_priority
.
Parameters | |
---|---|
r in | action to execute |
template<typename RunT>
void vt:: sched:: Scheduler:: enqueue(PriorityType priority,
RunT r)
Enqueue an runnable with a priority to execute later.
Parameters | |
---|---|
priority in | the priority of the action |
r in | the runnable to execute later |
template<typename RunT>
void vt:: sched:: Scheduler:: enqueue(bool is_term,
RunT r)
Enqueue an action without a message.
Parameters | |
---|---|
is_term in | whether it is a termination message or not |
r in | the runnable |
template<typename MsgT, typename RunT>
void vt:: sched:: Scheduler:: enqueue(MsgT* msg,
RunT r)
Enqueue an action associated with a prioritized message. The action will be enqueued with the priority found on the message.
Parameters | |
---|---|
msg in | the message |
r in | the runnable to execute later |
template<typename MsgT, typename RunT>
void vt:: sched:: Scheduler:: enqueue(messaging:: MsgSharedPtr<MsgT> const& msg,
RunT r)
Enqueue an runnable associated with a prioritized message. The action will be enqueued with the priority found on the message.
Parameters | |
---|---|
msg in | the message |
r in | the runnable to execute later |
std::size_t vt:: sched:: Scheduler:: workQueueSize() const
Get the work queue size.
Returns | how many units in the queue |
---|
bool vt:: sched:: Scheduler:: workQueueEmpty() const
Query if the work queue is empty.
Returns | whether it is empty |
---|
bool vt:: sched:: Scheduler:: isIdle() const
Check if the scheduler is idle.
Returns | whether this scheduler is idle |
---|
bool vt:: sched:: Scheduler:: isIdleMinusTerm() const
Check if the scheduler is idle minus termination messages.
Returns | whether this scheduler is idle |
---|
void vt:: sched:: Scheduler:: suspend(ThreadIDType tid,
RunnablePtrType runnable,
PriorityType p = default_priority)
Suspend a thread with an ID and runnable.
Parameters | |
---|---|
tid in | the threads ID |
runnable in | the runnable |
p in | the priority for resumption |
void vt:: sched:: Scheduler:: resume(ThreadIDType tid)
Resume a thread that is associated with a runnable that is currently suspended.
Parameters | |
---|---|
tid in | the suspended thread ID |
TimeType vt:: sched:: Scheduler:: getRecentTime()
Return a valid recent time, after checking whether an update is needed.
Returns | a valid recent time |
---|
#include <src/vt/scheduler/scheduler.impl.h>
template<typename RunT>
void vt:: sched:: Scheduler:: enqueue(] PriorityType priority,
RunT r)