DPsim
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
DPsim::Scheduler Class Referenceabstract
Inheritance diagram for DPsim::Scheduler:
[legend]
Collaboration diagram for DPsim::Scheduler:
[legend]

Classes

class  Root
 

Public Types

typedef std::unordered_map< CPS::Task::Ptr, std::deque< CPS::Task::Ptr > > Edges
 
typedef std::chrono::steady_clock::duration TaskTime
 Time measurement for the task execution.
 

Public Member Functions

 Scheduler (CPS::Logger::Level logLevel=CPS::Logger::Level::off)
 
virtual void createSchedule (const CPS::Task::List &tasks, const Edges &inEdges, const Edges &outEdges)=0
 Creates the schedule for the given dependency graph.
 
virtual void step (Real time, Int timeStepCount)=0
 Performs a single simulation step.
 
virtual void stop ()
 Called on simulation stop to reliably clean up e.g. running helper threads.
 
void resolveDeps (CPS::Task::List &tasks, Edges &inEdges, Edges &outEdges)
 
TaskTime getAveragedMeasurement (CPS::Task::Ptr task)
 

Static Public Attributes

static CPS::AttributeBase::Ptr external
 

Protected Member Functions

void topologicalSort (const CPS::Task::List &tasks, const Edges &inEdges, const Edges &outEdges, CPS::Task::List &sortedTasks)
 Simple topological sort, filtering out tasks that do not need to be executed.
 
void initMeasurements (const CPS::Task::List &tasks)
 
void updateMeasurement (CPS::Task *task, TaskTime time)
 
void writeMeasurements (CPS::String filename)
 Write measurement data to file.
 
void readMeasurements (CPS::String filename, std::unordered_map< CPS::String, TaskTime::rep > &measurements)
 Read measurement data from file to use it for the scheduling.
 
TaskTime getAveragedMeasurement (CPS::Task *task)
 

Static Protected Member Functions

static void levelSchedule (const CPS::Task::List &tasks, const Edges &inEdges, const Edges &outEdges, std::vector< CPS::Task::List > &levels)
 

Protected Attributes

CPS::Task::Ptr mRoot
 
CPS::Logger::Level mLogLevel
 Log level.
 
CPS::Logger::Log mSLog
 Logger.
 

Detailed Description

Definition at line 27 of file Scheduler.h.

Member Typedef Documentation

◆ Edges

typedef std::unordered_map<CPS::Task::Ptr, std::deque<CPS::Task::Ptr> > DPsim::Scheduler::Edges

Edges describe the dependency from the first task to a list of other tasks or the other way around.

Definition at line 31 of file Scheduler.h.

Member Function Documentation

◆ levelSchedule()

void Scheduler::levelSchedule ( const CPS::Task::List &  tasks,
const Edges inEdges,
const Edges outEdges,
std::vector< CPS::Task::List > &  levels 
)
staticprotected

Separate topologically sorted list of tasks into levels which can be executed in parallel

Definition at line 190 of file Scheduler.cpp.

◆ resolveDeps()

void Scheduler::resolveDeps ( CPS::Task::List &  tasks,
Edges inEdges,
Edges outEdges 
)

Helper function that resolves the task-attribute dependencies to task-task dependencies and inserts a root task

CHECK: Having external be the nullptr can lead to segfaults rather quickly. Maybe make it a special kind of attribute

Definition at line 78 of file Scheduler.cpp.

◆ updateMeasurement()

void Scheduler::updateMeasurement ( CPS::Task task,
TaskTime  time 
)
protected

Not thread-safe for multiple calls with same task, but should only be called once for each task in each step anyway

Definition at line 28 of file Scheduler.cpp.


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