Skip to content

Commit 6e5a7a9

Browse files
committed
Improved information for small subtrees
1 parent 6774d40 commit 6e5a7a9

File tree

5 files changed

+30
-27
lines changed

5 files changed

+30
-27
lines changed

highs/ipm/hipo/factorhighs/Analyse.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,19 +1569,27 @@ void Analyse::generateParallelLayer(Int threads) {
15691569
// generate info about small subtrees
15701570
smallSubtreesInfo_.resize(smallSubtrees_.size());
15711571
Int index = 0;
1572+
double small_ops_current{};
1573+
smallSubtreesStart_.push_back(0);
15721574
for (auto it = smallSubtrees_.begin(); it != smallSubtrees_.end(); ++it) {
15731575
Int node = *it;
15741576

15751577
smallSubtreesInfo_[index].start = first_desc[node];
15761578
smallSubtreesInfo_[index].end = node + 1;
15771579

15781580
// no stack needed for small subtrees
1579-
smallSubtreesInfo_[index].stack = -1;
1581+
smallSubtreesInfo_[index].stack = stack_subtree_parallel_[node];
15801582

1581-
smallSubtreesInfo_[index].ops_fraction = subtree_ops[node] / total_ops;
1583+
// divide small subtrees in groups of up to 5% ops, to be spawned together
1584+
small_ops_current += subtree_ops[node] / total_ops;
1585+
if (small_ops_current > 0.05) {
1586+
smallSubtreesStart_.push_back(index + 1);
1587+
small_ops_current = 0.0;
1588+
}
15821589

15831590
++index;
15841591
}
1592+
if (small_ops_current > 0) smallSubtreesStart_.push_back(index);
15851593
}
15861594

15871595
Int Analyse::run(Symbolic& S) {
@@ -1721,6 +1729,7 @@ Int Analyse::run(Symbolic& S) {
17211729
S.smallSubtreesInfo_ = std::move(smallSubtreesInfo_);
17221730
S.aboveLayer_ = std::move(aboveLayer_);
17231731
S.smallSubtrees_ = std::move(smallSubtrees_);
1732+
S.smallSubtreesStart_ = std::move(smallSubtreesStart_);
17241733

17251734
#if HIPO_TIMING_LEVEL >= 1
17261735
data_.sumTime(kTimeAnalyse, clock_total.stop());

highs/ipm/hipo/factorhighs/Analyse.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ class Analyse {
8282
std::map<Int, Int> layerIndex_;
8383
std::vector<SubtreeInfo> layerSubtreesInfo_, smallSubtreesInfo_;
8484
std::set<Int> aboveLayer_, smallSubtrees_;
85+
std::vector<Int> smallSubtreesStart_;
86+
8587
std::vector<int64_t> stack_subtree_serial_;
8688
std::vector<int64_t> stack_subtree_parallel_;
8789
int64_t serial_stack_size_, parallel_stack_size_;

highs/ipm/hipo/factorhighs/Factorise.cpp

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -363,30 +363,13 @@ bool Factorise::run(Numeric& num) {
363363
}
364364

365365
// process small subtrees
366-
// They are grouped together and spawned when a group has more than 5% of
367-
// total operations
368-
Int small_start{};
369-
double small_ops_current{};
370366
Int small_spawned{};
371-
for (Int i = 0; i < S_.smallSubtrees().size(); ++i) {
372-
small_ops_current += S_.smallSubtreeInfo(i).ops_fraction;
373-
374-
if (small_ops_current > 0.05) {
375-
// spawn start to current
376-
highs::parallel::spawn(
377-
[=]() { processSmallSubtrees(small_start, i + 1); });
378-
379-
small_start = i + 1;
380-
small_ops_current = 0.0;
381-
++small_spawned;
382-
}
383-
}
384-
if (small_ops_current > 0) {
385-
// spawn start to end
386-
++small_spawned;
367+
for (Int i = 1; i < S_.smallSubtreesStart().size(); ++i) {
387368
highs::parallel::spawn([=]() {
388-
processSmallSubtrees(small_start, S_.smallSubtrees().size());
369+
processSmallSubtrees(S_.smallSubtreesStart()[i - 1],
370+
S_.smallSubtreesStart()[i]);
389371
});
372+
++small_spawned;
390373
}
391374

392375
// wait for subtrees to complete

highs/ipm/hipo/factorhighs/Symbolic.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ const SubtreeInfo& Symbolic::smallSubtreeInfo(Int i) const {
5353
const std::set<Int>& Symbolic::aboveLayer() const { return aboveLayer_; }
5454
const std::set<Int>& Symbolic::smallSubtrees() const { return smallSubtrees_; }
5555
const std::map<Int, Int>& Symbolic::layerIndex() const { return layerIndex_; }
56+
const std::vector<Int>& Symbolic::smallSubtreesStart() const {
57+
return smallSubtreesStart_;
58+
}
5659

5760
std::string memoryString(double mem) {
5861
std::stringstream ss;

highs/ipm/hipo/factorhighs/Symbolic.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ namespace hipo {
1212

1313
// info about subtrees in the parallel layer
1414
struct SubtreeInfo {
15-
Int start; // first node in subtree
16-
Int end; // first node not in subtree
17-
int64_t stack; // minimum stack size
18-
double ops_fraction; // fraction of operations in subtree
15+
Int start; // first node in subtree
16+
Int end; // first node not in subtree
17+
int64_t stack; // minimum stack size
1918
};
2019

2120
// Symbolic factorisation object
@@ -123,6 +122,12 @@ class Symbolic {
123122
// layer
124123
std::set<Int> smallSubtrees_;
125124

125+
// Information about how to divide small subtrees among threads.
126+
// A task is created that processes the subtrees numbered
127+
// smallSubtreesStart[i] to smallSubtreesStart[i+1]. These subtrees have a
128+
// total number of operations between 5% and 6% of the total operations.
129+
std::vector<Int> smallSubtreesStart_;
130+
126131
// Information about number of entries
127132
int64_t serial_stack_size_, parallel_stack_size_, factors_total_entries_;
128133
int64_t root_stack_entries_;
@@ -162,6 +167,7 @@ class Symbolic {
162167
const std::set<Int>& aboveLayer() const;
163168
const std::set<Int>& smallSubtrees() const;
164169
const std::map<Int, Int>& layerIndex() const;
170+
const std::vector<Int>& smallSubtreesStart() const;
165171

166172
void print(const Log& log, bool verbose = false) const;
167173
};

0 commit comments

Comments
 (0)