Skip to content

Commit

Permalink
Implement basic infrastructure for optimization passes.
Browse files Browse the repository at this point in the history
  • Loading branch information
sukritkalra committed Nov 2, 2023
1 parent 13ae25b commit 3ced497
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
6 changes: 4 additions & 2 deletions schedulers/tetrisched/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ set(TETRISCHED_SOURCE
"src/Expression.cpp"
"src/Partition.cpp"
"src/SolverModel.cpp"
"src/Scheduler.cpp")
"src/Scheduler.cpp"
"src/OptimizationPasses.cpp")

if (EXISTS "${CPLEX_DIR}")
LIST(APPEND TETRISCHED_SOURCE "src/CPLEXSolver.cpp")
Expand All @@ -125,7 +126,8 @@ target_link_libraries(tetrisched PRIVATE ${SOLVER_BACKEND_LINK_LIBRARIES})
set(TETRISCHED_TESTS
"test/test_expression.cpp"
"test/test_partitions.cpp"
"test/test_solver.cpp")
"test/test_solver.cpp"
"test/test_optimization.cpp")

add_executable(test_tetrisched ${TETRISCHED_TESTS})
target_include_directories(test_tetrisched PRIVATE include)
Expand Down
30 changes: 30 additions & 0 deletions schedulers/tetrisched/include/tetrisched/OptimizationPasses.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef _TETRISCHED_OPTIMIZATION_PASSES_HPP_
#define _TETRISCHED_OPTIMIZATION_PASSES_HPP_

#include <string>

#include "tetrisched/Expression.hpp"

namespace tetrisched {
class OptimizationPass {
/// A representative name of the optimization pass.
std::string name;

public:
/// Construct the base OptimizationPass class.
OptimizationPass(std::string name);

/// Run the pass on the given STRL expression.
virtual void runPass(ExpressionPtr strlExpression) = 0;
};

class CriticalPathOptimizationPass : public OptimizationPass {
public:
/// Instantiate the Critical Path optimization pass.
CriticalPathOptimizationPass();

/// Run the Critical Path optimization pass on the given STRL expression.
void runPass(ExpressionPtr strlExpression) override;
};
} // namespace tetrisched
#endif // _TETRISCHED_OPTIMIZATION_PASSES_HPP_
15 changes: 15 additions & 0 deletions schedulers/tetrisched/src/OptimizationPasses.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "tetrisched/OptimizationPasses.hpp"

namespace tetrisched {

/* Methods for OptimizationPass */
OptimizationPass::OptimizationPass(std::string name) : name(name) {}

/* Methods for CriticalPathOptimizationPass */
CriticalPathOptimizationPass::CriticalPathOptimizationPass()
: OptimizationPass("CriticalPathOptimizationPass") {}

void CriticalPathOptimizationPass::runPass(ExpressionPtr strlExpression) {
// TODO (Sukrit): Implement this.
}
}
8 changes: 8 additions & 0 deletions schedulers/tetrisched/test/test_optimization.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <gtest/gtest.h>

#include "tetrisched/OptimizationPasses.hpp"

TEST(OptimizationTest, TestBasicCriticalPathOptimizationPass) {
// Create an OptimizationPass object.
tetrisched::CriticalPathOptimizationPass optimizationPass();
}

0 comments on commit 3ced497

Please sign in to comment.