Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions apps/ilp_bsp_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ using ComputationalDag = ComputationalDagEdgeIdxVectorImplDefIntT;

int main(int argc, char *argv[]) {
if (argc < 4) {
std::cerr << "Usage: " << argv[0] << " <input_file> <machine_file> <max_number_step> <optional:recomp>" << std::endl;
std::cerr << "Usage: " << argv[0] << " <input_file> <machine_file> <max_number_step> [time_limit_seconds] [recomp]"
<< std::endl;
return 1;
}

Expand All @@ -57,17 +58,33 @@ int main(int argc, char *argv[]) {
return 1;
}

unsigned steps = static_cast<unsigned>(stepInt);

// Default time limit: 3600 seconds (1 hour)
unsigned timeLimitSeconds = 3600;
bool recomp = false;

if (argc > 4 && std::string(argv[4]) == "recomp") {
recomp = true;
} else if (argc > 4) {
std::cerr << "Unknown argument: " << argv[4] << ". Expected 'recomp' for recomputation." << std::endl;
return 1;
// Parse optional arguments
for (int i = 4; i < argc; ++i) {
std::string arg = argv[i];
if (arg == "recomp") {
recomp = true;
} else {
// Try to parse as time limit
try {
int timeLimitInt = std::stoi(arg);
if (timeLimitInt < 1) {
std::cerr << "Argument time_limit_seconds must be a positive integer: " << timeLimitInt << std::endl;
return 1;
}
timeLimitSeconds = static_cast<unsigned>(timeLimitInt);
} catch (const std::exception &) {
std::cerr << "Unknown argument: " << arg << ". Expected a time limit (integer) or 'recomp'." << std::endl;
return 1;
}
}
}

unsigned steps = static_cast<unsigned>(stepInt);

BspInstance<ComputationalDag> instance;
ComputationalDag &graph = instance.GetComputationalDag();

Expand All @@ -88,6 +105,9 @@ int main(int argc, char *argv[]) {

CoptFullScheduler<ComputationalDag> scheduler;
scheduler.SetMaxNumberOfSupersteps(steps);
scheduler.SetTimeLimitSeconds(timeLimitSeconds);

std::cout << "Time limit set to " << timeLimitSeconds << " seconds." << std::endl;

if (recomp) {
BspScheduleRecomp<ComputationalDag> schedule(instance);
Expand Down
6 changes: 3 additions & 3 deletions include/osp/bsp/scheduler/IlpSchedulers/CoptFullScheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CoptFullScheduler : public Scheduler<GraphT> {
bool writeSolutionsFound_;
bool isMaxBsp_ = false;

unsigned timeLimitSeconds_ = 0;
unsigned timeLimitSeconds_ = 3600;

const BspScheduleCS<GraphT> *initialSchedule_;
const BspScheduleRecomp<GraphT> *initialScheduleRecomp_;
Expand Down Expand Up @@ -277,7 +277,7 @@ class CoptFullScheduler : public Scheduler<GraphT> {

for (unsigned node = 0; node < schedule.GetInstance().NumberOfVertices(); node++) {
for (unsigned processor = 0; processor < schedule.GetInstance().NumberOfProcessors(); processor++) {
for (unsigned step = 0; step < numberOfSupersteps - 1; step++) {
for (unsigned step = 0; step < numberOfSupersteps; step++) {
if (nodeToProcessorSuperstepVar_[node][processor][static_cast<int>(step)].Get(COPT_DBLINFO_VALUE) >= .99) {
schedule.Assignments(node).emplace_back(processor, step);
}
Expand All @@ -290,7 +290,7 @@ class CoptFullScheduler : public Scheduler<GraphT> {
for (unsigned int pFrom = 0; pFrom < schedule.GetInstance().NumberOfProcessors(); pFrom++) {
for (unsigned int pTo = 0; pTo < schedule.GetInstance().NumberOfProcessors(); pTo++) {
if (pFrom != pTo) {
for (unsigned int step = 0; step < maxNumberSupersteps_; step++) {
for (unsigned int step = 0; step < numberOfSupersteps - 1; step++) {
if (commProcessorToProcessorSuperstepNodeVar_[pFrom][pTo][step][static_cast<int>(node)].Get(
COPT_DBLINFO_VALUE)
>= .99) {
Expand Down