Skip to content

Commit

Permalink
Enable necessary profiling in TetriSched.
Browse files Browse the repository at this point in the history
  • Loading branch information
sukritkalra committed Apr 5, 2024
1 parent 5aebad9 commit 56190a7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
9 changes: 5 additions & 4 deletions schedulers/tetrisched/include/tetrisched/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@

// Macros for timing.
#define TETRISCHED_TIMING_FILE_NAME "libtetrisched_performance.csv"
#ifdef _TETRISCHED_PERF_ENABLED_

#define CONCAT_INTERNAL(x, y) x##y
#define CONCAT(x, y) CONCAT_INTERNAL(x, y)
#define TETRISCHED_SCOPE_TIMER(TIMER_NAME) \
#define TETRISCHED_SCOPE_NECESSARY_TIMER(TIMER_NAME) \
tetrisched::timing::ScopeTimer CONCAT(timer, __LINE__)(TIMER_NAME);

#ifdef _TETRISCHED_PERF_ENABLED_
#define TETRISCHED_SCOPE_TIMER(TIMER_NAME) \
tetrisched::timing::ScopeTimer CONCAT(timer, __LINE__)(TIMER_NAME);
#else
#define TETRISCHED_SCOPE_TIMER(TIMER_NAME)
#endif
Expand All @@ -62,7 +63,7 @@
#define TETRISCHED_ILP_TYPE double


// Macro for hinting the variables.
// Macro for hinting the variables.
// We have two strategies for hinting the variables.
// 1. We can hint the variables from a solution value cache saved from the previous
// iteration. This is the default behavior.
Expand Down
4 changes: 4 additions & 0 deletions schedulers/tetrisched/src/OptimizationPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ void CriticalPathOptimizationPass::runPass(
ExpressionPtr strlExpression,
CapacityConstraintMapPtr /* capacityConstraints */,
std::optional<std::string> /* debugFile */) {
TETRISCHED_SCOPE_NECESSARY_TIMER("CriticalPathOptimizationPass::runPass");
/* Preprocessing: We first compute the post-order traversal of the
Expression graph since all subsequent steps use it. */
auto postOrderTraversal = computePostOrderTraversal(strlExpression);
Expand Down Expand Up @@ -475,6 +476,7 @@ DiscretizationSelectorOptimizationPass::DiscretizationSelectorOptimizationPass(
void DiscretizationSelectorOptimizationPass::runPass(
ExpressionPtr strlExpression, CapacityConstraintMapPtr capacityConstraints,
std::optional<std::string> /* debugFile */) {
TETRISCHED_SCOPE_NECESSARY_TIMER("DiscretizationSelectorOptimizationPass::runPass");
/* Do a Post-Order Traversal of the DAG. */
std::stack<ExpressionPtr> firstStack;
firstStack.push(strlExpression);
Expand Down Expand Up @@ -1085,6 +1087,8 @@ void CapacityConstraintMapPurgingOptimizationPass::
void CapacityConstraintMapPurgingOptimizationPass::runPass(
ExpressionPtr strlExpression, CapacityConstraintMapPtr capacityConstraints,
std::optional<std::string> debugFile) {
TETRISCHED_SCOPE_NECESSARY_TIMER(
"CapacityConstraintMapPurgingOptimizationPass::runPass")
/* Preprocessing: Compute the post-order to compute the cliques. */
auto postOrderTraversal = computePostOrderTraversal(strlExpression);
childLeafExpressions.reserve(postOrderTraversal.size());
Expand Down
8 changes: 4 additions & 4 deletions schedulers/tetrisched/src/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void Scheduler::registerSTRL(
}

{
TETRISCHED_SCOPE_TIMER("Scheduler::registerSTRL::parse," +
TETRISCHED_SCOPE_NECESSARY_TIMER("Scheduler::registerSTRL::parse," +
std::to_string(currentTime));
// Parse the ExpressionTree to populate the solver model.
TETRISCHED_DEBUG("Beginning the parsing of the ExpressionTree rooted at "
Expand Down Expand Up @@ -144,21 +144,21 @@ void Scheduler::schedule(Time currentTime) {

// Translate the model to the solver backend.
{
TETRISCHED_SCOPE_TIMER("Scheduler::schedule::translateModel," +
TETRISCHED_SCOPE_NECESSARY_TIMER("Scheduler::schedule::translateModel," +
std::to_string(currentTime));
this->solver->translateModel(solverConfig);
}

// Solve the model.
{
TETRISCHED_SCOPE_TIMER("Scheduler::schedule::solveModel," +
TETRISCHED_SCOPE_NECESSARY_TIMER("Scheduler::schedule::solveModel," +
std::to_string(currentTime));
solverSolution = this->solver->solveModel();
}

// Populate the results from the solver into the expression tree.
{
TETRISCHED_SCOPE_TIMER("Scheduler::schedule::populateResults," +
TETRISCHED_SCOPE_NECESSARY_TIMER("Scheduler::schedule::populateResults," +
std::to_string(currentTime));
if (solverSolution.has_value() && solverSolution.value()->isValid()) {
this->expression.value()->populateResults(solverModel);
Expand Down
2 changes: 1 addition & 1 deletion schedulers/tetrisched/src/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ ScopeTimer::~ScopeTimer() {
std::lock_guard<std::mutex> lock(sharedLock); // Acquire the shared lock
getOutputFileStream() << "END," << scopeTimerName << ","
<< startTimeMicroseconds << "," << endtimeMicroseconds
<< "," << duration << "\n";
<< "," << duration << std::endl;
}

} // namespace timing
Expand Down
2 changes: 1 addition & 1 deletion scripts/run_alibaba_final_experiments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ execute_experiment () {

echo "[x] Constructed configuration for ${EXPERIMENT_DIR}. Beginning experiment"

if ! python3 main.py --flagfile=${EXPERIMENT_DIR}/alibaba_trace_replay.conf > ${EXPERIMENT_DIR}/alibaba_trace_replay.output; then
if ! TETRISCHED_LOGGING_DIR=${EXPERIMENT_DIR} python3 main.py --flagfile=${EXPERIMENT_DIR}/alibaba_trace_replay.conf > ${EXPERIMENT_DIR}/alibaba_trace_replay.output; then
echo "[x] Failed in the execution of ${LOG_BASE}. Exiting."
exit 3
fi
Expand Down

0 comments on commit 56190a7

Please sign in to comment.