diff --git a/sparta/src/CommandLineSimulator.cpp b/sparta/src/CommandLineSimulator.cpp index bb6dff13d9..ba3785ef15 100644 --- a/sparta/src/CommandLineSimulator.cpp +++ b/sparta/src/CommandLineSimulator.cpp @@ -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>>("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(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);