The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::Scheduleable Class Reference

A class that defines the basic scheduling interface to the Scheduler. Not intended to be used by modelers directly, but certainly can be. More...

#include <Scheduleable.hpp>

Inheritance diagram for sparta::Scheduleable:
Collaboration diagram for sparta::Scheduleable:

Classes

class  PrecedenceSetup
 An internal class used in Scheduleble to cache a pointer to the scheduler. More...
 

Public Types

typedef uint32_t PrecedenceGroup
 Typedef defining the precedence group ID.
 

Public Member Functions

 Scheduleable (const SpartaHandler &consumer_event_handler, Clock::Cycle delay, SchedulingPhase sched_phase, bool is_unique_event=false)
 Construct a Scheduleable object.
 
virtual ~Scheduleable ()=default
 Destructor.
 
 Scheduleable (const Scheduleable &)=default
 Allow copies.
 
 Scheduleable (Scheduleable &&) noexcept=default
 Allow moves. Marked as noexcept to force containers to use it.
 
SchedulergetScheduler (const bool must_exist=true)
 Get the scheduler this Scheduleable is assigned to.
 
const SchedulergetScheduler (const bool must_exist=true) const
 Get the scheduler this Scheduleable is assigned to.
 
void setDelay (Clock::Cycle delay)
 Set a fixed delay for this event.
 
void addDelay (Clock::Cycle delay)
 Add to the delay for this event.
 
Clock::Cycle getDelay () const
 Get the delay associated with this event.
 
void setContinuing (bool continuing)
 This event, if continuing == true, will keep the simulation running.
 
bool isContinuing () const
 Is this Event continuing?
 
const SpartaHandler & getHandler () const
 Get the consumer handler/callback associated with this event.
 
SpartaHandler & getHandler ()
 Get the consumer handler/callback associated with this event.
 
void setHandler (const SpartaHandler &handler)
 Set the consumer handler/callback associated with this event.
 
void schedule ()
 Schedule this event with its pre-set delay using the pre-set Clock.
 
void schedule (const Clock *clk)
 Schedule this event with its pre-set delay using the given clock.
 
void schedule (Clock::Cycle delay)
 Schedule an event in the future using the pre-set Clock.
 
virtual void scheduleRelativeTick (const Scheduler::Tick rel_tick, Scheduler *const scheduler)
 Schedule this event on a relative scheduler tick.
 
void schedule (Clock::Cycle delay, const Clock *clk)
 Schedule an event in the future using the given Clock.
 
bool isScheduled () const
 Return true if this scheduleable was scheduled at all.
 
bool isOrphan () const
 Return true if this scheduleable is not associated with a vertex.
 
bool isScheduled (Clock::Cycle rel_cycle) const
 Return true if this Scheduleable was scheduled on the given relative cycle.
 
SchedulingPhase getSchedulingPhase () const
 Get the internal phase number.
 
const char * getLabel () const
 Get the internal label.
 
void setLabel (const char *label)
 Set a new label for this Scheduleable – used in debugging.
 
Vertex * getVertex ()
 get the internal Vertex of this scheduleable
 
void precedes (Scheduleable &consumer, const std::string &reason="")
 Have this Scheduleable precede another.
 
void precedes (Vertex &consumer, const std::string &reason="") const
 Have this Scheduleable precede a Vertex.
 
void precedes (Scheduleable *consumer, const std::string &reason="")
 Have this Scheduleablee precede another.
 
void precedes (Vertex *consumer, const std::string &reason="") const
 Have this Scheduleable precede a Vertex.
 
void setGOP (bool gop)
 
void setGroupID (const PrecedenceGroup gid)
 
bool unlink (Scheduleable *w)
 Unlink this scheduleables vertex from another scheduleables vertex.
 
PrecedenceGroup getGroupID () const
 Get the group ID.
 
void cancel ()
 Cancel all the times that this Scheduleable was placed on the Scheduler.
 
void cancel (Clock::Cycle rel_cycle)
 Cancel this Scheduleable at the given time, if placed on the Scheduler.
 
void setScheduleableClock (const Clock *clk)
 Set the clock and scheduler of this Scheduleable.
 
void setScheduler (Scheduler *sched)
 Set the Scheduler of this Scheduleable, and set the local vertex_ to a new vertex from the Vertex Factory.
 
void setVertex ()
 Set the local vertex_ to a new vertex from the Vertex Factory. This needs to happen before the Scheduleable goes through the DAGs linking process in onSchedulerAssignment.
 

Static Public Attributes

static const PrecedenceGroup INVALID_GROUP
 

Protected Member Functions

uint32_t getScheduleableHandleCount_ () const
 
virtual void setGroupID_ (const PrecedenceGroup gid)
 Set the group ID of this Scheduleable's derivatives.
 
virtual void eventCancelled_ ()
 

Protected Attributes

SpartaHandler consumer_event_handler_
 The Consumer callback registered with the Event.
 
const Clocklocal_clk_ = nullptr
 A local clock for speed.
 
PrecedenceSetup scheduler_ {this}
 Cache a pointer to the scheduler used.
 

Friends

class Scheduler
 
class DAG
 
class Unit
 
class ScheduleableHandle
 

Detailed Description

A class that defines the basic scheduling interface to the Scheduler. Not intended to be used by modelers directly, but certainly can be.

This class is used by Event, PayloadEvent, UniqueEvent, etc to schedule an event on the SPARTA scheduler. The main goal of this class is to remain as light-weight as possible to allow a developer to possibly copy derivatives of this class for scheduling (like PayloadEvent proxy classes).

Definition at line 37 of file Scheduleable.hpp.

Member Typedef Documentation

◆ PrecedenceGroup

Typedef defining the precedence group ID.

Definition at line 42 of file Scheduleable.hpp.

Constructor & Destructor Documentation

◆ Scheduleable()

sparta::Scheduleable::Scheduleable ( const SpartaHandler &  consumer_event_handler,
Clock::Cycle  delay,
SchedulingPhase  sched_phase,
bool  is_unique_event = false 
)

Construct a Scheduleable object.

Parameters
consumer_event_handlerThe scheduled callback placed on the Scheduler
delayAny delay of scheduling
sched_phaseThe scheduling phase for this Scheduleable
is_unique_eventIs this Scheduleable uniquely scheduled (not scheduled more than once per tick)?

Member Function Documentation

◆ addDelay()

void sparta::Scheduleable::addDelay ( Clock::Cycle  delay)
inline

Add to the delay for this event.

Parameters
delayThe additional clock cycle delay

Definition at line 95 of file Scheduleable.hpp.

◆ cancel() [1/2]

void sparta::Scheduleable::cancel ( )
inline

Cancel all the times that this Scheduleable was placed on the Scheduler.

Definition at line 327 of file Scheduleable.hpp.

Here is the call graph for this function:

◆ cancel() [2/2]

void sparta::Scheduleable::cancel ( Clock::Cycle  rel_cycle)
inline

Cancel this Scheduleable at the given time, if placed on the Scheduler.

Parameters
rel_cycleThe relative time to look for the event

This will cancel all instances of this event at the given time.

Definition at line 339 of file Scheduleable.hpp.

Here is the call graph for this function:

◆ eventCancelled_()

virtual void sparta::Scheduleable::eventCancelled_ ( )
inlineprotectedvirtual

Called by the Scheduler to let this Scheduleable know it was canceled.

Definition at line 417 of file Scheduleable.hpp.

◆ getDelay()

Clock::Cycle sparta::Scheduleable::getDelay ( ) const
inline

Get the delay associated with this event.

Returns
The delay associated with this event

Definition at line 103 of file Scheduleable.hpp.

◆ getGroupID()

PrecedenceGroup sparta::Scheduleable::getGroupID ( ) const
inline

Get the group ID.

Returns
The group ID

Definition at line 319 of file Scheduleable.hpp.

◆ getHandler() [1/2]

SpartaHandler & sparta::Scheduleable::getHandler ( )
inline

Get the consumer handler/callback associated with this event.

Returns
Reference to the handler (non-const)

Definition at line 139 of file Scheduleable.hpp.

◆ getHandler() [2/2]

const SpartaHandler & sparta::Scheduleable::getHandler ( ) const
inline

Get the consumer handler/callback associated with this event.

Returns
Reference to the handler (const)

Definition at line 131 of file Scheduleable.hpp.

◆ getLabel()

const char * sparta::Scheduleable::getLabel ( ) const
inline

Get the internal label.

Definition at line 237 of file Scheduleable.hpp.

◆ getScheduleableHandleCount_()

uint32_t sparta::Scheduleable::getScheduleableHandleCount_ ( ) const
inlineprotected

Return the number of outstanding handles pointing to this Scheduleable

Definition at line 397 of file Scheduleable.hpp.

◆ getScheduler() [1/2]

Scheduler * sparta::Scheduleable::getScheduler ( const bool  must_exist = true)
inline

Get the scheduler this Scheduleable is assigned to.

Definition at line 72 of file Scheduleable.hpp.

◆ getScheduler() [2/2]

const Scheduler * sparta::Scheduleable::getScheduler ( const bool  must_exist = true) const
inline

Get the scheduler this Scheduleable is assigned to.

Definition at line 78 of file Scheduleable.hpp.

◆ getSchedulingPhase()

SchedulingPhase sparta::Scheduleable::getSchedulingPhase ( ) const
inline

Get the internal phase number.

Definition at line 232 of file Scheduleable.hpp.

◆ getVertex()

Vertex * sparta::Scheduleable::getVertex ( )
inline

get the internal Vertex of this scheduleable

Definition at line 246 of file Scheduleable.hpp.

◆ isContinuing()

bool sparta::Scheduleable::isContinuing ( ) const
inline

Is this Event continuing?

Returns
true if it will keep the scheduler alive

Definition at line 123 of file Scheduleable.hpp.

◆ isScheduled() [1/2]

bool sparta::Scheduleable::isScheduled ( ) const
inline

Return true if this scheduleable was scheduled at all.

Returns
true if scheduled at all

This is an expensive call as it searches all time quantums for instances of this Scheduleable object. Use with care.

Definition at line 214 of file Scheduleable.hpp.

Here is the call graph for this function:

◆ isScheduled() [2/2]

bool sparta::Scheduleable::isScheduled ( Clock::Cycle  rel_cycle) const
inline

Return true if this Scheduleable was scheduled on the given relative cycle.

Parameters
rel_cycleThe relative clock cycle to check

Definition at line 226 of file Scheduleable.hpp.

Here is the call graph for this function:

◆ precedes() [1/4]

void sparta::Scheduleable::precedes ( Scheduleable consumer,
const std::string &  reason = "" 
)

Have this Scheduleable precede another.

Parameters
consumerThe Scheduleable to follow this Scheduleable
reasonThe reason for the precedence

this will preceed, or come before, the consumer

◆ precedes() [2/4]

void sparta::Scheduleable::precedes ( Scheduleable consumer,
const std::string &  reason = "" 
)
inline

Have this Scheduleablee precede another.

Parameters
consumerThe Scheduleable to follow this Scheduleable
reasonThe reason for the precedence

this will preceed, or come before, the consumer

Definition at line 278 of file Scheduleable.hpp.

Here is the call graph for this function:

◆ precedes() [3/4]

void sparta::Scheduleable::precedes ( Vertex &  consumer,
const std::string &  reason = "" 
) const

Have this Scheduleable precede a Vertex.

Parameters
consumerThe Vertex to follow this Scheduleable
reasonThe reason for the precedence

this will preceed, or come before, the consumer

◆ precedes() [4/4]

void sparta::Scheduleable::precedes ( Vertex *  consumer,
const std::string &  reason = "" 
) const
inline

Have this Scheduleable precede a Vertex.

Parameters
consumerThe Vertex to follow this Scheduleable
reasonThe reason for the precedence

this will preceed, or come before, the consumer

Definition at line 290 of file Scheduleable.hpp.

Here is the call graph for this function:

◆ schedule() [1/4]

void sparta::Scheduleable::schedule ( )
inline

Schedule this event with its pre-set delay using the pre-set Clock.

Definition at line 156 of file Scheduleable.hpp.

Here is the call graph for this function:

◆ schedule() [2/4]

void sparta::Scheduleable::schedule ( Clock::Cycle  delay)
inline

Schedule an event in the future using the pre-set Clock.

Parameters
delayThe relative time (in Clock::Cycle) to schedule from "now"

Definition at line 176 of file Scheduleable.hpp.

Here is the call graph for this function:

◆ schedule() [3/4]

void sparta::Scheduleable::schedule ( Clock::Cycle  delay,
const Clock clk 
)
inline

Schedule an event in the future using the given Clock.

Parameters
delayThe relative time (in Ticks) to schedule from "now"
clkThe clock this Event will use to schedule itself

Definition at line 201 of file Scheduleable.hpp.

Here is the call graph for this function:

◆ schedule() [4/4]

void sparta::Scheduleable::schedule ( const Clock clk)
inline

Schedule this event with its pre-set delay using the given clock.

Parameters
clkPointer to the clock to use

Definition at line 166 of file Scheduleable.hpp.

Here is the call graph for this function:

◆ scheduleRelativeTick()

virtual void sparta::Scheduleable::scheduleRelativeTick ( const Scheduler::Tick  rel_tick,
Scheduler *const  scheduler 
)
inlinevirtual

Schedule this event on a relative scheduler tick.

Parameters
rel_tickA relative Scheduler::Tick in the future

This method is typically not used in user-end models. Use the schedule methods instead.

Reimplemented in sparta::AsyncEvent< sched_phase_T >, and sparta::PhasedUniqueEvent.

Definition at line 188 of file Scheduleable.hpp.

Here is the call graph for this function:

◆ setContinuing()

void sparta::Scheduleable::setContinuing ( bool  continuing)
inline

This event, if continuing == true, will keep the simulation running.

If this event is NOT a continuing event, just simply scheduling it will NOT keep simulation running. This is useful for events like heartbeats, etc.

Definition at line 115 of file Scheduleable.hpp.

◆ setDelay()

void sparta::Scheduleable::setDelay ( Clock::Cycle  delay)
inline

Set a fixed delay for this event.

Parameters
delayThe clock cycle delay

Definition at line 87 of file Scheduleable.hpp.

◆ setGOP()

void sparta::Scheduleable::setGOP ( bool  gop)
inline
Parameters
gopWhether this Scheduleable is a GOP or not. A Scheduleable is never a GOP, this is a hack to get around code in Unit.cpp. TODO: elminate Unit.cpp code that used this.

Definition at line 299 of file Scheduleable.hpp.

◆ setGroupID()

void sparta::Scheduleable::setGroupID ( const PrecedenceGroup  gid)
inline
Parameters
gidInternal Group ID of this Scheduleable.

Definition at line 305 of file Scheduleable.hpp.

◆ setGroupID_()

virtual void sparta::Scheduleable::setGroupID_ ( const PrecedenceGroup  gid)
inlineprotectedvirtual

Set the group ID of this Scheduleable's derivatives.

Parameters
gidThe group ID within the DAG this event should use

Called by the DAG when setting up precedence.

Definition at line 408 of file Scheduleable.hpp.

◆ setHandler()

void sparta::Scheduleable::setHandler ( const SpartaHandler &  handler)
inline

Set the consumer handler/callback associated with this event.

Parameters
handlerReference to the new handler

Definition at line 147 of file Scheduleable.hpp.

Here is the call graph for this function:

◆ setScheduleableClock()

void sparta::Scheduleable::setScheduleableClock ( const Clock clk)
inline

Set the clock and scheduler of this Scheduleable.

Parameters
clckThe clock to be associated with this Scheduleable

Definition at line 354 of file Scheduleable.hpp.

Here is the call graph for this function:

◆ setScheduler()

void sparta::Scheduleable::setScheduler ( Scheduler sched)
inline

Set the Scheduler of this Scheduleable, and set the local vertex_ to a new vertex from the Vertex Factory.

Parameters
schedThe Scheduler to be associated with this Scheduleable

Definition at line 366 of file Scheduleable.hpp.

◆ setVertex()

void sparta::Scheduleable::setVertex ( )

Set the local vertex_ to a new vertex from the Vertex Factory. This needs to happen before the Scheduleable goes through the DAGs linking process in onSchedulerAssignment.

Parameters
schedThe Scheduler to be associated with this Scheduleable

Friends And Related Symbol Documentation

◆ DAG

friend class DAG
friend

Definition at line 468 of file Scheduleable.hpp.

◆ ScheduleableHandle

friend class ScheduleableHandle
friend

Definition at line 472 of file Scheduleable.hpp.

◆ Scheduler

friend class Scheduler
friend

Definition at line 413 of file Scheduleable.hpp.

◆ Unit

friend class Unit
friend

Definition at line 470 of file Scheduleable.hpp.

Member Data Documentation

◆ consumer_event_handler_

SpartaHandler sparta::Scheduleable::consumer_event_handler_
protected

The Consumer callback registered with the Event.

Definition at line 390 of file Scheduleable.hpp.

◆ INVALID_GROUP

const PrecedenceGroup sparta::Scheduleable::INVALID_GROUP
static

Definition at line 44 of file Scheduleable.hpp.

◆ local_clk_

const Clock* sparta::Scheduleable::local_clk_ = nullptr
protected

A local clock for speed.

Definition at line 393 of file Scheduleable.hpp.

◆ scheduler_

PrecedenceSetup sparta::Scheduleable::scheduler_ {this}
protected

Cache a pointer to the scheduler used.

Definition at line 465 of file Scheduleable.hpp.


The documentation for this class was generated from the following file: