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
3 changes: 1 addition & 2 deletions apps/ilp_bsp_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ int main(int argc, char *argv[]) {

CoptFullScheduler<ComputationalDag> scheduler;
scheduler.setMaxNumberOfSupersteps(steps);
scheduler.setTimeLimitHours(48);


if (recomp) {

BspScheduleRecomp<ComputationalDag> schedule(instance);
Expand Down
137 changes: 86 additions & 51 deletions apps/test_suite_runner/StringToScheduler/run_bsp_scheduler.hpp

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions include/osp/bsp/scheduler/GreedySchedulers/GreedyChildren.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ class GreedyChildren : public Scheduler<Graph_t> {
bool ensure_enough_sources;

public:
GreedyChildren(bool ensure_enough_sources_ = true) : ensure_enough_sources(ensure_enough_sources_) {};
GreedyChildren(unsigned time_limit, bool ensure_enough_sources_ = true)
: Scheduler<Graph_t>(time_limit), ensure_enough_sources(ensure_enough_sources_) {};

GreedyChildren(bool ensure_enough_sources_ = true) : Scheduler<Graph_t>(), ensure_enough_sources(ensure_enough_sources_) {};

RETURN_STATUS computeSchedule(BspSchedule<Graph_t> &sched) override {

Expand Down Expand Up @@ -75,7 +74,7 @@ class GreedyChildren : public Scheduler<Graph_t> {
if (nodes_assigned_this_superstep.count(par)) {
if (!processor_set) {
const unsigned par_proc = sched.assignedProcessor(par);
if(!instance.isCompatible(node, par_proc)) {
if (!instance.isCompatible(node, par_proc)) {
failed_to_allocate = true;
break;
}
Expand Down Expand Up @@ -106,7 +105,7 @@ class GreedyChildren : public Scheduler<Graph_t> {
}
}
sched.setAssignedProcessor(node, best_proc);
}
}

nodes_assigned_this_superstep.emplace(node);
processor_weights[sched.assignedProcessor(node)] += graph.vertex_work_weight(node);
Expand Down
5 changes: 2 additions & 3 deletions include/osp/bsp/scheduler/GreedySchedulers/RandomGreedy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ class RandomGreedy : public Scheduler<Graph_t> {
bool ensure_enough_sources;

public:
RandomGreedy(bool ensure_enough_sources_ = true) : ensure_enough_sources(ensure_enough_sources_) {};
RandomGreedy(unsigned time_limit, bool ensure_enough_sources_)
: Scheduler<Graph_t>(time_limit), ensure_enough_sources(ensure_enough_sources_) {};

RandomGreedy(bool ensure_enough_sources_ = true) : Scheduler<Graph_t>(), ensure_enough_sources(ensure_enough_sources_) {};

RETURN_STATUS computeSchedule(BspSchedule<Graph_t> &sched) override {

Expand Down
29 changes: 20 additions & 9 deletions include/osp/bsp/scheduler/IlpSchedulers/CoptFullScheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ class CoptFullScheduler : public Scheduler<Graph_t> {
bool is_max_bsp = false;
bool use_memory_constraint;
bool use_initial_schedule = false;
const BspScheduleCS<Graph_t> *initial_schedule;

bool write_solutions_found;
bool use_initial_schedule_recomp = false;
const BspScheduleRecomp<Graph_t> *initial_schedule_recomp;

bool write_solutions_found;
unsigned timeLimitSeconds = 0;

const BspScheduleCS<Graph_t> *initial_schedule;
const BspScheduleRecomp<Graph_t> *initial_schedule_recomp;

std::string write_solutions_path;
std::string solution_file_prefix;

Expand Down Expand Up @@ -822,8 +824,8 @@ class CoptFullScheduler : public Scheduler<Graph_t> {

public:
CoptFullScheduler(unsigned steps = 5)
: allow_recomputation(false), use_memory_constraint(false), use_initial_schedule(false), initial_schedule(0),
write_solutions_found(false), max_number_supersteps(steps) {
: allow_recomputation(false), use_memory_constraint(false), use_initial_schedule(false),
write_solutions_found(false), initial_schedule(0), max_number_supersteps(steps) {

// solution_callback.comm_processor_to_processor_superstep_node_var_ptr =
// &comm_processor_to_processor_superstep_node_var;
Expand All @@ -832,7 +834,7 @@ class CoptFullScheduler : public Scheduler<Graph_t> {

CoptFullScheduler(const BspScheduleCS<Graph_t> &schedule)
: allow_recomputation(false), use_memory_constraint(false), use_initial_schedule(true),
initial_schedule(&schedule), write_solutions_found(false),
write_solutions_found(false), initial_schedule(&schedule),
max_number_supersteps(schedule.numberOfSupersteps()) {

// solution_callback.comm_processor_to_processor_superstep_node_var_ptr =
Expand All @@ -842,7 +844,7 @@ class CoptFullScheduler : public Scheduler<Graph_t> {

CoptFullScheduler(const BspScheduleRecomp<Graph_t> &schedule)
: allow_recomputation(true), use_memory_constraint(false), use_initial_schedule_recomp(true),
initial_schedule_recomp(&schedule), write_solutions_found(false),
write_solutions_found(false), initial_schedule_recomp(&schedule),
max_number_supersteps(schedule.numberOfSupersteps()) {
}

Expand All @@ -869,6 +871,13 @@ class CoptFullScheduler : public Scheduler<Graph_t> {
return status;
}
}

virtual RETURN_STATUS computeScheduleWithTimeLimit(BspSchedule<Graph_t> &schedule, unsigned timeLimit) {

timeLimitSeconds = timeLimit;
return computeSchedule(schedule);
}

virtual RETURN_STATUS computeMaxBspSchedule(MaxBspSchedule<Graph_t> &schedule) {

MaxBspScheduleCS<Graph_t> schedule_cs(schedule.getInstance());
Expand Down Expand Up @@ -934,7 +943,9 @@ class CoptFullScheduler : public Scheduler<Graph_t> {

virtual void computeScheduleBase(const BspScheduleRecomp<Graph_t> &schedule, Model &model) {

model.SetDblParam(COPT_DBLPARAM_TIMELIMIT, Scheduler<Graph_t>::timeLimitSeconds);
if (timeLimitSeconds > 0) {
model.SetDblParam(COPT_DBLPARAM_TIMELIMIT, timeLimitSeconds);
}
model.SetIntParam(COPT_INTPARAM_THREADS, 128);

model.SetIntParam(COPT_INTPARAM_STRONGBRANCHING, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ limitations under the License.
#include <callbackbase.h>
#include <coptcpp_pch.h>

#include "osp/auxiliary/io/DotFileWriter.hpp"
#include "osp/bsp/scheduler/LocalSearch/KernighanLin/kl_total_comm.hpp"
#include "osp/bsp/scheduler/Scheduler.hpp"
#include "osp/graph_algorithms/directed_graph_edge_view.hpp"
#include "osp/auxiliary/io/DotFileWriter.hpp"

namespace osp {

Expand Down Expand Up @@ -76,9 +76,9 @@ class TotalCommunicationScheduler : public Scheduler<Graph_t> {

auto sched = constructBspScheduleFromCallback();
DotFileWriter sched_writer;
sched_writer.write_schedule(write_solutions_path_cb + "intmed_sol_" + solution_file_prefix_cb + "_" +
std::to_string(counter) + "_schedule.dot",
sched);
sched_writer.write_schedule(write_solutions_path_cb + "intmed_sol_" + solution_file_prefix_cb +
"_" + std::to_string(counter) + "_schedule.dot",
sched);
counter++;
}

Expand All @@ -95,8 +95,8 @@ class TotalCommunicationScheduler : public Scheduler<Graph_t> {

for (unsigned processor = 0; processor < instance_ptr->numberOfProcessors(); processor++) {

for (unsigned step = 0; step < static_cast<unsigned>((*node_to_processor_superstep_var_ptr)[0][0].Size());
step++) {
for (unsigned step = 0;
step < static_cast<unsigned>((*node_to_processor_superstep_var_ptr)[0][0].Size()); step++) {

assert(size < std::numeric_limits<int>::max());
if (GetSolution(
Expand Down Expand Up @@ -170,8 +170,8 @@ class TotalCommunicationScheduler : public Scheduler<Graph_t> {

for (unsigned processor = 0; processor < instance_ptr->numberOfProcessors(); processor++) {

for (unsigned step = 0; step < static_cast<unsigned>((*node_to_processor_superstep_var_ptr)[0][0].Size());
step++) {
for (unsigned step = 0;
step < static_cast<unsigned>((*node_to_processor_superstep_var_ptr)[0][0].Size()); step++) {
assert(step <= std::numeric_limits<int>::max());
if (GetSolution(
(*node_to_processor_superstep_var_ptr)[node][processor][static_cast<int>(step)]) >=
Expand Down Expand Up @@ -203,8 +203,8 @@ class TotalCommunicationScheduler : public Scheduler<Graph_t> {

for (unsigned processor = 0; processor < instance_ptr->numberOfProcessors(); processor++) {

for (unsigned step = 0; step < static_cast<unsigned>((*node_to_processor_superstep_var_ptr)[0][0].Size());
step++) {
for (unsigned step = 0;
step < static_cast<unsigned>((*node_to_processor_superstep_var_ptr)[0][0].Size()); step++) {

if (schedule.assignedProcessor(node) == processor && schedule.assignedSuperstep(node) == step) {
assert(step <= std::numeric_limits<int>::max());
Expand Down Expand Up @@ -425,7 +425,8 @@ class TotalCommunicationScheduler : public Scheduler<Graph_t> {
model.AddConstr(superstep_used_var[0] == 1);

for (unsigned int step = 0; step < max_number_supersteps - 1; step++) {
model.AddConstr(superstep_used_var[static_cast<int>(step)] >= superstep_used_var[static_cast<int>(step + 1)]);
model.AddConstr(superstep_used_var[static_cast<int>(step)] >=
superstep_used_var[static_cast<int>(step + 1)]);
}

// superstep is used at all
Expand Down Expand Up @@ -579,7 +580,7 @@ class TotalCommunicationScheduler : public Scheduler<Graph_t> {
Expr expr_work;
for (const auto &node : instance.vertices()) {
expr_work += instance.getComputationalDag().vertex_work_weight(node) *
node_to_processor_superstep_var[node][processor][static_cast<int>(step)];
node_to_processor_superstep_var[node][processor][static_cast<int>(step)];
}

model.AddConstr(max_work_superstep_var[static_cast<int>(step)] >= expr_work);
Expand Down Expand Up @@ -632,6 +633,11 @@ class TotalCommunicationScheduler : public Scheduler<Graph_t> {

virtual ~TotalCommunicationScheduler() = default;

virtual RETURN_STATUS computeScheduleWithTimeLimit(BspSchedule<Graph_t> &schedule, unsigned timeout) override {
model.SetDblParam(COPT_DBLPARAM_TIMELIMIT, timeout);
return computeSchedule(schedule);
}

/**
* @brief Compute the schedule for the given BspInstance using the COPT solver.
*
Expand Down Expand Up @@ -662,13 +668,11 @@ class TotalCommunicationScheduler : public Scheduler<Graph_t> {
loadInitialSchedule();
}

model.SetDblParam(COPT_DBLPARAM_TIMELIMIT, Scheduler<Graph_t>::timeLimitSeconds);

model.SetIntParam(COPT_INTPARAM_THREADS, 128);

model.SetIntParam(COPT_INTPARAM_STRONGBRANCHING, 1);
model.SetIntParam(COPT_INTPARAM_LPMETHOD, 1);
model.SetIntParam(COPT_INTPARAM_ROUNDINGHEURLEVEL, 1);

model.SetIntParam(COPT_INTPARAM_SUBMIPHEURLEVEL, 1);
// model.SetIntParam(COPT_INTPARAM_PRESOLVE, 1);
// model.SetIntParam(COPT_INTPARAM_CUTLEVEL, 0);
Expand Down
14 changes: 0 additions & 14 deletions include/osp/bsp/scheduler/ImprovementScheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,6 @@ class ComboScheduler : public Scheduler<Graph_t> {
ComboScheduler(Scheduler<Graph_t> &base, ImprovementScheduler<Graph_t> &improvement)
: Scheduler<Graph_t>(), base_scheduler(base), improvement_scheduler(improvement) {}

virtual void setTimeLimitSeconds(unsigned int limit) override {

Scheduler<Graph_t>::timeLimitSeconds = limit;
base_scheduler.setTimeLimitSeconds(limit);
improvement_scheduler.setTimeLimitSeconds(limit);
}

virtual void setTimeLimitHours(unsigned int limit) override {

Scheduler<Graph_t>::timeLimitSeconds = limit * 3600;
base_scheduler.setTimeLimitHours(limit);
improvement_scheduler.setTimeLimitHours(limit);
}

virtual ~ComboScheduler() = default;

virtual std::string getScheduleName() const override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ limitations under the License.
#include "osp/bsp/scheduler/ImprovementScheduler.hpp"
#include "osp/graph_algorithms/directed_graph_top_sort.hpp"

#include <chrono>

namespace osp{

template<typename Graph_t>
Expand Down
Loading