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
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class MultiProcessorPebbling : public Scheduler<Graph_t> {
VarArray comp_phase_ends;

unsigned max_time = 0;
unsigned time_limit_seconds;

// problem settings
bool slidingPebbles = false;
Expand Down Expand Up @@ -211,6 +212,7 @@ class MultiProcessorPebbling : public Scheduler<Graph_t> {
inline void setNeedsBlueAtEnd (const std::set<vertex_idx>& needs_blue_) {needs_blue_at_end = needs_blue_; }
inline void setHasRedInBeginning (const std::vector<std::set<vertex_idx> >& has_red_) {has_red_in_beginning = has_red_; }
inline void setVerbose (const bool verbose_) {verbose = verbose_; }
inline void setTimeLimitSeconds(unsigned time_limit_seconds_) { time_limit_seconds = time_limit_seconds_; }

bool hasEmptyStep(const BspInstance<Graph_t> &instance);
};
Expand All @@ -223,7 +225,7 @@ void MultiProcessorPebbling<Graph_t>::solveILP() {
if(!verbose)
model.SetIntParam(COPT_INTPARAM_LOGTOCONSOLE, 0);

model.SetDblParam(COPT_DBLPARAM_TIMELIMIT, Scheduler<Graph_t>::timeLimitSeconds);
model.SetDblParam(COPT_DBLPARAM_TIMELIMIT, time_limit_seconds);
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 @@ -25,7 +25,7 @@ limitations under the License.
namespace osp{

template<typename Graph_t>
class AcyclicPartitioningILP : public Scheduler<Graph_t> {
class AcyclicPartitioningILP {

static_assert(is_computational_dag_v<Graph_t>, "PebblingSchedule can only be used with computational DAGs.");

Expand Down Expand Up @@ -64,6 +64,8 @@ class AcyclicPartitioningILP : public Scheduler<Graph_t> {

std::vector<bool> is_original_source;

unsigned time_limit_seconds;

protected:
std::vector<VarArray> node_in_partition;
std::vector<VarArray> hyperedge_intersects_partition;
Expand All @@ -84,9 +86,6 @@ class AcyclicPartitioningILP : public Scheduler<Graph_t> {

RETURN_STATUS computePartitioning(const BspInstance<Graph_t> &instance, std::vector<unsigned>& partitioning);

// not used, only here for using scheduler class base functionality (status enums, timelimits, etc)
virtual RETURN_STATUS computeSchedule(BspSchedule<Graph_t> &schedule) override;

/**
* @brief Enables writing intermediate solutions.
*
Expand Down Expand Up @@ -139,7 +138,7 @@ class AcyclicPartitioningILP : public Scheduler<Graph_t> {
*
* @return The name of the schedule.
*/
virtual std::string getScheduleName() const override { return "AcyclicPartitioningILP"; }
virtual std::string getScheduleName() const { return "AcyclicPartitioningILP"; }

// getters and setters for problem parameters
inline std::pair<unsigned, unsigned> getMinAndMaxSize() const { return std::make_pair(minPartitionSize, maxPartitionSize); }
Expand All @@ -149,14 +148,15 @@ class AcyclicPartitioningILP : public Scheduler<Graph_t> {
inline void setNumberOfParts(const unsigned number_of_parts) {numberOfParts = number_of_parts; }
inline void setIgnoreSourceForConstraint(const bool ignore_) {ignore_sources_for_constraint = ignore_; }
inline void setIsOriginalSource(const std::vector<bool>& is_original_source_) {is_original_source = is_original_source_; }
void setTimeLimitSeconds(unsigned time_limit_seconds_) { time_limit_seconds = time_limit_seconds_; }
};

template<typename Graph_t>
void AcyclicPartitioningILP<Graph_t>::solveILP() {

model.SetIntParam(COPT_INTPARAM_LOGTOCONSOLE, 0);

model.SetDblParam(COPT_DBLPARAM_TIMELIMIT, Scheduler<Graph_t>::timeLimitSeconds);
model.SetDblParam(COPT_DBLPARAM_TIMELIMIT, time_limit_seconds);
model.SetIntParam(COPT_INTPARAM_THREADS, 128);

model.SetIntParam(COPT_INTPARAM_STRONGBRANCHING, 1);
Expand Down Expand Up @@ -347,9 +347,4 @@ std::vector<unsigned> AcyclicPartitioningILP<Graph_t>::returnAssignment(const Bs
return node_to_partition;
}

template<typename Graph_t>
RETURN_STATUS AcyclicPartitioningILP<Graph_t>::computeSchedule(BspSchedule<Graph_t> &) {
return RETURN_STATUS::ERROR;
}

}
9 changes: 5 additions & 4 deletions tests/ilp_hypergraph_partitioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ using namespace osp;
BOOST_AUTO_TEST_CASE(test_full) {

using graph = computational_dag_vector_impl_def_int_t;
using Hypergraph = Hypergraph_def_t;

// Getting root git directory
std::filesystem::path cwd = std::filesystem::current_path();
Expand All @@ -48,7 +49,7 @@ BOOST_AUTO_TEST_CASE(test_full) {

BOOST_CHECK(status);

Hypergraph Hgraph = convert_from_cdag_as_hyperdag<size_t, int, int, int, graph>(DAG);
Hypergraph Hgraph = convert_from_cdag_as_hyperdag<Hypergraph, graph>(DAG);
BOOST_CHECK_EQUAL(DAG.num_vertices(), Hgraph.num_vertices());

PartitioningProblem instance(Hgraph, 3, 35);
Expand All @@ -57,7 +58,7 @@ BOOST_AUTO_TEST_CASE(test_full) {

// ILP without replication

HypergraphPartitioningILP partitioner;
HypergraphPartitioningILP<Hypergraph> partitioner;
partitioner.setTimeLimitSeconds(60);
partitioner.computePartitioning(partition);

Expand All @@ -83,7 +84,7 @@ BOOST_AUTO_TEST_CASE(test_full) {

// ILP with replication

HypergraphPartitioningILPWithReplication partitioner_rep;
HypergraphPartitioningILPWithReplication<Hypergraph> partitioner_rep;
PartitioningWithReplication partition_rep(instance);

partitioner_rep.setTimeLimitSeconds(60);
Expand All @@ -110,7 +111,7 @@ BOOST_AUTO_TEST_CASE(test_full) {

// same tests with other replication formulation
instance.setMaxWorkWeightExplicitly(35);
partitioner_rep.setReplicationModel(HypergraphPartitioningILPWithReplication<>::REPLICATION_MODEL_IN_ILP::GENERAL);
partitioner_rep.setReplicationModel(HypergraphPartitioningILPWithReplication<Hypergraph>::REPLICATION_MODEL_IN_ILP::GENERAL);
partitioner_rep.setUseInitialSolution(false);
partitioner_rep.computePartitioning(partition_rep);

Expand Down