Skip to content
Snippets Groups Projects

Improved scheduling

Merged Olivier BICHLER requested to merge scheduling into dev
4 files
+ 213
81
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -30,6 +30,18 @@ class GraphView;
class SequentialScheduler {
private:
struct StaticSchedulingElement {
StaticSchedulingElement(
std::shared_ptr<Node> node_,
size_t early_ = static_cast<size_t>(-1),
size_t late_ = static_cast<size_t>(-1))
: node(node_), early(early_), late(late_) {}
std::shared_ptr<Node> node;
size_t early;
size_t late;
};
struct SchedulingElement {
SchedulingElement(
std::shared_ptr<Node> node_,
@@ -57,7 +69,17 @@ public:
};
~SequentialScheduler() = default;
void generateScheduling(bool verbose = false);
/**
* Generate full static scheduling of the GraphView.
* For each node, an earliest and latest possible execution logical step
* is specified. Nodes that may be scheduled at the same logical step have
* no data dependency and can be run in parallel.
*/
void generateScheduling();
/**
* Reset all scheduling and associated nodes producer consumer.
*/
void resetScheduling();
/**
@@ -79,6 +101,12 @@ public:
*/
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.
* @param fileName Name of the generated file.
*/
void saveStaticSchedulingDiagram(const std::string& fileName) const;
/**
* @brief Save in a Markdown file the order of layers execution.
* @param fileName Name of the generated file.
@@ -89,14 +117,26 @@ public:
* @brief Return a vector of Node ordered by the order they are called by the scheduler
* @return std::vector<std::shared_ptr<Node>>
*/
inline std::vector<std::shared_ptr<Node>> getStaticScheduling(size_t step = 0) const noexcept {
return mStaticSchedule.at(step);
}
std::vector<std::shared_ptr<Node>> getStaticScheduling(size_t step = 0) const;
inline std::shared_ptr<GraphView> getGraphView() const noexcept {
return mGraphView;
}
private:
/**
* Generate an initial base scheduling for the GraphView.
* The scheduling is entirely sequential and garanteed to be valid w.r.t.
* each node producer-consumer model.
*/
std::vector<StaticSchedulingElement> generateBaseScheduling() const;
/**
* Fill-in early and late scheduling step from initial base scheduling.
* For each node, specifies the earliest and latest possible execution
* logical step.
*/
void generateEarlyLateScheduling(std::vector<StaticSchedulingElement>& schedule) const;
/**
* @brief Set of layers receiving an input from currently processing layers
*
@@ -114,7 +154,7 @@ private:
/** @brief List of SchedulingElement (i.e: Nodes with their computation time) */
std::vector<SchedulingElement> mScheduling;
/** @brief List of nodes ordered by their */
std::vector<std::vector<std::shared_ptr<Node>>> mStaticSchedule;
std::vector<std::vector<StaticSchedulingElement>> mStaticSchedule;
size_t mStaticScheduleStep = 0;
};
} // namespace Aidge
Loading