Skip to content

Commit

Permalink
Critical Path Optimization v1
Browse files Browse the repository at this point in the history
  • Loading branch information
sukritkalra committed Nov 3, 2023
1 parent 3fef5ae commit 0e13d8f
Show file tree
Hide file tree
Showing 7 changed files with 385 additions and 90 deletions.
19 changes: 13 additions & 6 deletions schedulers/tetrisched/include/tetrisched/Expression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@ enum ExpressionType {
};
using ExpressionType = enum ExpressionType;

/// A representation of the ranges on start and finish time.
struct ExpressionTimeBounds {
TimeRange startTimeRange;
TimeRange endTimeRange;
std::string toString() const;
};

/// A Base Class for all expressions in the STRL language.
class Expression : public std::enable_shared_from_this<Expression> {
protected:
Expand All @@ -253,9 +260,6 @@ class Expression : public std::enable_shared_from_this<Expression> {
/// Adds a parent to this expression.
void addParent(ExpressionPtr parent);

/// Returns the parents of this Expression.
std::vector<ExpressionPtr> getParents() const;

public:
/// Construct the Expression class of the given type.
Expression(std::string name, ExpressionType type);
Expand Down Expand Up @@ -283,12 +287,15 @@ class Expression : public std::enable_shared_from_this<Expression> {
/// Returns the ID of this Expression.
std::string getId() const;

/// Returns the number of children of this Expression.
size_t getNumChildren() const;

/// Returns the number of parents of this Expression.
size_t getNumParents() const;

/// Returns the parents of this Expression.
std::vector<ExpressionPtr> getParents() const;

/// Returns the number of children of this Expression.
size_t getNumChildren() const;

/// Returns the children of this Expression.
std::vector<ExpressionPtr> getChildren() const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ class CriticalPathOptimizationPass : public OptimizationPass {
/// A map from an Expression's ID to the valid time bounds for it.
std::unordered_map<std::string, ExpressionTimeBounds> expressionTimeBoundMap;

/// A helper method to recursively compute the time bounds for an Expression.
void computeTimeBounds(ExpressionPtr expression);

/// A helper method to push down the time bounds into the Expression tree.
void pushDownTimeBounds(ExpressionPtr expression);

/// A helper method to purge the nodes that do not fit their time bounds.
void purgeNodes(ExpressionPtr expression);

public:
/// Instantiate the Critical Path optimization pass.
CriticalPathOptimizationPass();
Expand Down
6 changes: 0 additions & 6 deletions schedulers/tetrisched/include/tetrisched/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ using Time = uint32_t;
/// start or the finish times from each Expression.
using TimeRange = std::pair<Time, Time>;

/// A representation of the ranges on start and finish time.
struct ExpressionTimeBounds {
TimeRange startTimeRange;
TimeRange endTimeRange;
};

/// General forward declarations.
class Expression;
using ExpressionPtr = std::shared_ptr<Expression>;
Expand Down
9 changes: 8 additions & 1 deletion schedulers/tetrisched/src/Expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ size_t CapacityConstraintMap::size() const {

/* Method definitions for Expression */

std::string ExpressionTimeBounds::toString() const {
return "Start: [" + std::to_string(startTimeRange.first) + ", " +
std::to_string(startTimeRange.second) + "], End: [" +
std::to_string(endTimeRange.first) + ", " +
std::to_string(endTimeRange.second) + "]";
}

Expression::Expression(std::string name, ExpressionType type)
: name(name), id(tetrisched::uuid::generate_uuid()), type(type) {}

Expand Down Expand Up @@ -420,7 +427,7 @@ void Expression::exportToDot(std::string fileName) const {
}

std::string Expression::getDescriptiveName() const {
return this->getTypeString();
return this->getTypeString() + "(" + name + ")";
}

/* Method definitions for ChooseExpression */
Expand Down
Loading

0 comments on commit 0e13d8f

Please sign in to comment.