Skip to content

Commit 9bdad4a

Browse files
fixes in partitioning and pebbling
1 parent 82c972f commit 9bdad4a

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

include/osp/pebbling/pebblers/pebblingILP/MultiProcessorPebbling.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class MultiProcessorPebbling : public Scheduler<Graph_t> {
8686
VarArray comp_phase_ends;
8787

8888
unsigned max_time = 0;
89+
unsigned time_limit_seconds;
8990

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

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

226-
model.SetDblParam(COPT_DBLPARAM_TIMELIMIT, Scheduler<Graph_t>::timeLimitSeconds);
228+
model.SetDblParam(COPT_DBLPARAM_TIMELIMIT, time_limit_seconds);
227229
model.SetIntParam(COPT_INTPARAM_THREADS, 128);
228230

229231
model.SetIntParam(COPT_INTPARAM_STRONGBRANCHING, 1);

include/osp/pebbling/pebblers/pebblingILP/partialILP/AcyclicPartitioningILP.hpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ limitations under the License.
2525
namespace osp{
2626

2727
template<typename Graph_t>
28-
class AcyclicPartitioningILP : public Scheduler<Graph_t> {
28+
class AcyclicPartitioningILP {
2929

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

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

6565
std::vector<bool> is_original_source;
6666

67+
unsigned time_limit_seconds;
68+
6769
protected:
6870
std::vector<VarArray> node_in_partition;
6971
std::vector<VarArray> hyperedge_intersects_partition;
@@ -84,9 +86,6 @@ class AcyclicPartitioningILP : public Scheduler<Graph_t> {
8486

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

87-
// not used, only here for using scheduler class base functionality (status enums, timelimits, etc)
88-
virtual RETURN_STATUS computeSchedule(BspSchedule<Graph_t> &schedule) override;
89-
9089
/**
9190
* @brief Enables writing intermediate solutions.
9291
*
@@ -139,7 +138,7 @@ class AcyclicPartitioningILP : public Scheduler<Graph_t> {
139138
*
140139
* @return The name of the schedule.
141140
*/
142-
virtual std::string getScheduleName() const override { return "AcyclicPartitioningILP"; }
141+
virtual std::string getScheduleName() const { return "AcyclicPartitioningILP"; }
143142

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

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

157157
model.SetIntParam(COPT_INTPARAM_LOGTOCONSOLE, 0);
158158

159-
model.SetDblParam(COPT_DBLPARAM_TIMELIMIT, Scheduler<Graph_t>::timeLimitSeconds);
159+
model.SetDblParam(COPT_DBLPARAM_TIMELIMIT, time_limit_seconds);
160160
model.SetIntParam(COPT_INTPARAM_THREADS, 128);
161161

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

350-
template<typename Graph_t>
351-
RETURN_STATUS AcyclicPartitioningILP<Graph_t>::computeSchedule(BspSchedule<Graph_t> &) {
352-
return RETURN_STATUS::ERROR;
353-
}
354-
355350
}

tests/ilp_hypergraph_partitioning.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ using namespace osp;
3232
BOOST_AUTO_TEST_CASE(test_full) {
3333

3434
using graph = computational_dag_vector_impl_def_int_t;
35+
using Hypergraph = Hypergraph_def_t;
3536

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

4950
BOOST_CHECK(status);
5051

51-
Hypergraph Hgraph = convert_from_cdag_as_hyperdag<size_t, int, int, int, graph>(DAG);
52+
Hypergraph Hgraph = convert_from_cdag_as_hyperdag<Hypergraph, graph>(DAG);
5253
BOOST_CHECK_EQUAL(DAG.num_vertices(), Hgraph.num_vertices());
5354

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

5859
// ILP without replication
5960

60-
HypergraphPartitioningILP partitioner;
61+
HypergraphPartitioningILP<Hypergraph> partitioner;
6162
partitioner.setTimeLimitSeconds(60);
6263
partitioner.computePartitioning(partition);
6364

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

8485
// ILP with replication
8586

86-
HypergraphPartitioningILPWithReplication partitioner_rep;
87+
HypergraphPartitioningILPWithReplication<Hypergraph> partitioner_rep;
8788
PartitioningWithReplication partition_rep(instance);
8889

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

111112
// same tests with other replication formulation
112113
instance.setMaxWorkWeightExplicitly(35);
113-
partitioner_rep.setReplicationModel(HypergraphPartitioningILPWithReplication<>::REPLICATION_MODEL_IN_ILP::GENERAL);
114+
partitioner_rep.setReplicationModel(HypergraphPartitioningILPWithReplication<Hypergraph>::REPLICATION_MODEL_IN_ILP::GENERAL);
114115
partitioner_rep.setUseInitialSolution(false);
115116
partitioner_rep.computePartitioning(partition_rep);
116117

0 commit comments

Comments
 (0)