Skip to content

Commit

Permalink
Add CLS option to control infinite loop timeout (#538)
Browse files Browse the repository at this point in the history
furuame authored Nov 4, 2024
1 parent d03a7fc commit a944066
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions sparta/src/CommandLineSimulator.cpp
Original file line number Diff line number Diff line change
@@ -320,7 +320,9 @@ CommandLineSimulator::CommandLineSimulator(const std::string& usage,
"Examples:\n'--cpu-timeout 5 clean'\n"
"'--cpu-timeout 5 error'\n"
"The only exit types are \"clean\" and \"error\". error throws an exception, clean will stop simulation nicely.") // Brief

("inf-loop-timeout",
named_value<std::vector<std::vector<std::string>>>("SECONDS"),
"The time length that the simulator uses to check whether the scheduler makes the forward progress.") // Brief
;

debug_opts_.add_options()
@@ -1402,14 +1404,32 @@ bool CommandLineSimulator::parse(int argc,

bool use_wall_clock;
if(o.string_key == "cpu-timeout")
{
use_wall_clock = false;
}
else if (o.string_key == "wall-timeout")
{
use_wall_clock = true;
else
}
else{
sparta_assert(false); // one can only hope that we can't get here logically.
}
std::cout << " set timeout to " << hours << " hours" << std::endl;
SleeperThread::getInstance()->setTimeout(duration, clean_exit, use_wall_clock);
++i;
} else if(o.string_key == "inf-loop-timeout") {
size_t end_pos;
size_t seconds;
try {
seconds = utils::smartLexicalCast<size_t>(o.value.at(0), end_pos);
}
catch(...){
throw SpartaException("inf-loop-timeout must take an integer value, not \"")
<< o.value.at(0) << "\"";
}
std::cout << " set infinite loop protection timeout to " << seconds << " seconds" << std::endl;
SleeperThread::getInstance()->setInfLoopSleepInterval(std::chrono::seconds(seconds));
++i;
} else if(o.string_key == "simdb-dir") {
const std::string & db_dir = o.value[0];
auto p = sfs::path(db_dir);

0 comments on commit a944066

Please sign in to comment.