Skip to content
Snippets Groups Projects

Improved scheduling

Merged Olivier BICHLER requested to merge scheduling into dev
4 files
+ 279
27
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -29,7 +29,7 @@ class Node;
@@ -29,7 +29,7 @@ class Node;
class GraphView;
class GraphView;
class SequentialScheduler {
class SequentialScheduler {
private:
protected:
struct StaticSchedulingElement {
struct StaticSchedulingElement {
StaticSchedulingElement(
StaticSchedulingElement(
std::shared_ptr<Node> node_,
std::shared_ptr<Node> node_,
@@ -40,6 +40,7 @@ private:
@@ -40,6 +40,7 @@ private:
std::shared_ptr<Node> node;
std::shared_ptr<Node> node;
size_t early;
size_t early;
size_t late;
size_t late;
 
std::vector<std::shared_ptr<StaticSchedulingElement>> earlierThan;
};
};
struct SchedulingElement {
struct SchedulingElement {
@@ -67,7 +68,7 @@ public:
@@ -67,7 +68,7 @@ public:
{
{
// ctor
// ctor
};
};
~SequentialScheduler() = default;
virtual ~SequentialScheduler() = default;
/**
/**
* Generate full static scheduling of the GraphView.
* Generate full static scheduling of the GraphView.
@@ -99,7 +100,7 @@ public:
@@ -99,7 +100,7 @@ public:
/**
/**
* @brief Run the provided Computational Graph with a batch of data
* @brief Run the provided Computational Graph with a batch of data
*/
*/
void forward(bool forwardDims = true, bool verbose = false, std::vector<std::shared_ptr<Aidge::Tensor>> data = {});
virtual void forward(bool forwardDims = true, bool verbose = false, std::vector<std::shared_ptr<Aidge::Tensor>> data = {});
/**
/**
* @brief Save in a Markdown file the static scheduling with early and late relative order for the nodes.
* @brief Save in a Markdown file the static scheduling with early and late relative order for the nodes.
@@ -122,20 +123,20 @@ public:
@@ -122,20 +123,20 @@ public:
return mGraphView;
return mGraphView;
}
}
private:
protected:
/**
/**
* Generate an initial base scheduling for the GraphView.
* Generate an initial base scheduling for the GraphView.
* The scheduling is entirely sequential and garanteed to be valid w.r.t.
* The scheduling is entirely sequential and garanteed to be valid w.r.t.
* each node producer-consumer model.
* each node producer-consumer model.
*/
*/
std::vector<StaticSchedulingElement> generateBaseScheduling() const;
std::vector<std::shared_ptr<StaticSchedulingElement>> generateBaseScheduling() const;
/**
/**
* Fill-in early and late scheduling step from initial base scheduling.
* Fill-in early and late scheduling step from initial base scheduling.
* For each node, specifies the earliest and latest possible execution
* For each node, specifies the earliest and latest possible execution
* logical step.
* logical step.
*/
*/
void generateEarlyLateScheduling(std::vector<StaticSchedulingElement>& schedule) const;
void generateEarlyLateScheduling(std::vector<std::shared_ptr<StaticSchedulingElement>>& schedule) const;
/**
/**
* @brief Set of layers receiving an input from currently processing layers
* @brief Set of layers receiving an input from currently processing layers
@@ -154,9 +155,24 @@ private:
@@ -154,9 +155,24 @@ private:
/** @brief List of SchedulingElement (i.e: Nodes with their computation time) */
/** @brief List of SchedulingElement (i.e: Nodes with their computation time) */
std::vector<SchedulingElement> mScheduling;
std::vector<SchedulingElement> mScheduling;
/** @brief List of nodes ordered by their */
/** @brief List of nodes ordered by their */
std::vector<std::vector<StaticSchedulingElement>> mStaticSchedule;
std::vector<std::vector<std::shared_ptr<StaticSchedulingElement>>> mStaticSchedule;
size_t mStaticScheduleStep = 0;
size_t mStaticScheduleStep = 0;
};
};
 
 
/**
 
* Multi-threaded parallel scheduler with dynamic scheduling.
 
*/
 
class ParallelScheduler : public SequentialScheduler {
 
public:
 
ParallelScheduler(std::shared_ptr<GraphView> graphView, std::shared_ptr<Node> upperNode = nullptr)
 
: SequentialScheduler(graphView, upperNode)
 
{
 
// ctor
 
};
 
~ParallelScheduler() = default;
 
 
virtual void forward(bool forwardDims = true, bool verbose = false, std::vector<std::shared_ptr<Aidge::Tensor>> data = {});
 
};
} // namespace Aidge
} // namespace Aidge
#endif /* AIDGE_SCHEDULER_H_ */
#endif /* AIDGE_SCHEDULER_H_ */
Loading