@@ -38,7 +38,8 @@ using ComputationalDag = ComputationalDagEdgeIdxVectorImplDefIntT;
3838
3939int main (int argc, char *argv[]) {
4040 if (argc < 4 ) {
41- std::cerr << " Usage: " << argv[0 ] << " <input_file> <machine_file> <max_number_step> <optional:recomp>" << std::endl;
41+ std::cerr << " Usage: " << argv[0 ] << " <input_file> <machine_file> <max_number_step> [time_limit_seconds] [recomp]"
42+ << std::endl;
4243 return 1 ;
4344 }
4445
@@ -57,17 +58,33 @@ int main(int argc, char *argv[]) {
5758 return 1 ;
5859 }
5960
61+ unsigned steps = static_cast <unsigned >(stepInt);
62+
63+ // Default time limit: 3600 seconds (1 hour)
64+ unsigned timeLimitSeconds = 3600 ;
6065 bool recomp = false ;
6166
62- if (argc > 4 && std::string (argv[4 ]) == " recomp" ) {
63- recomp = true ;
64- } else if (argc > 4 ) {
65- std::cerr << " Unknown argument: " << argv[4 ] << " . Expected 'recomp' for recomputation." << std::endl;
66- return 1 ;
67+ // Parse optional arguments
68+ for (int i = 4 ; i < argc; ++i) {
69+ std::string arg = argv[i];
70+ if (arg == " recomp" ) {
71+ recomp = true ;
72+ } else {
73+ // Try to parse as time limit
74+ try {
75+ int timeLimitInt = std::stoi (arg);
76+ if (timeLimitInt < 1 ) {
77+ std::cerr << " Argument time_limit_seconds must be a positive integer: " << timeLimitInt << std::endl;
78+ return 1 ;
79+ }
80+ timeLimitSeconds = static_cast <unsigned >(timeLimitInt);
81+ } catch (const std::exception &) {
82+ std::cerr << " Unknown argument: " << arg << " . Expected a time limit (integer) or 'recomp'." << std::endl;
83+ return 1 ;
84+ }
85+ }
6786 }
6887
69- unsigned steps = static_cast <unsigned >(stepInt);
70-
7188 BspInstance<ComputationalDag> instance;
7289 ComputationalDag &graph = instance.GetComputationalDag ();
7390
@@ -88,6 +105,9 @@ int main(int argc, char *argv[]) {
88105
89106 CoptFullScheduler<ComputationalDag> scheduler;
90107 scheduler.SetMaxNumberOfSupersteps (steps);
108+ scheduler.SetTimeLimitSeconds (timeLimitSeconds);
109+
110+ std::cout << " Time limit set to " << timeLimitSeconds << " seconds." << std::endl;
91111
92112 if (recomp) {
93113 BspScheduleRecomp<ComputationalDag> schedule (instance);
0 commit comments