Skip to content

Commit

Permalink
Correctly update run_scheduler_at when scheduler didn't run.
Browse files Browse the repository at this point in the history
In some cases the scheduler does not have to run. In such
cases the SchedulerStats.algorithm_runtime_ is set max_uint64.
Previously, the code was directly using algorithm_runtime_ and
coulse cause integer overflow. This change addresses this issue.

Affected modules: sim

Change-Id: I065ac766f646c7d2d1b2d6549c80405cd300bd53
  • Loading branch information
ICGog committed May 31, 2017
1 parent b97a12e commit 50fd149
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/sim/simulator.cc
Expand Up @@ -208,8 +208,15 @@ uint64_t Simulator::ScheduleJobsHelper(uint64_t run_scheduler_at) {
return event_manager_->GetTimeOfNextSchedulerRun(
run_scheduler_at, scheduler_stats.scheduler_runtime_);
} else {
return event_manager_->GetTimeOfNextSchedulerRun(
run_scheduler_at, scheduler_stats.algorithm_runtime_);
if (scheduler_stats.algorithm_runtime_ ==
numeric_limits<uint64_t>::max()) {
// Scheduler hasn't executed.
return event_manager_->GetTimeOfNextSchedulerRun(
run_scheduler_at, 0);
} else {
return event_manager_->GetTimeOfNextSchedulerRun(
run_scheduler_at, scheduler_stats.algorithm_runtime_);
}
}
} else if (FLAGS_solver_runtime_accounting_mode == "solver") {
return event_manager_->GetTimeOfNextSchedulerRun(
Expand Down

0 comments on commit 50fd149

Please sign in to comment.