Skip to content

Commit 52222a8

Browse files
committed
Switch off loop splitting if parallel is off
1 parent fde1686 commit 52222a8

File tree

1 file changed

+29
-23
lines changed

1 file changed

+29
-23
lines changed

highs/ipm/hipo/factorhighs/HybridPackedFormatHandler.cpp

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -139,31 +139,37 @@ void HybridPackedFormatHandler::assembleChild(Int child_sn,
139139
const Int child_clique_size =
140140
S_->ptr(child_sn + 1) - S_->ptr(child_sn) - child_sn_size;
141141

142-
// The loop over the columns of the child clique has completely independent
143-
// iterations. The loop is split evenly among the available threads.
144-
145-
TaskGroupSpecial tg;
146-
147-
const Int threads = highs::parallel::num_threads();
148-
const double ops_per_thread =
149-
(double)child_clique_size * (child_clique_size + 1) / 2 / threads;
150-
double ops_current = 0;
151-
Int next_col = 0;
152-
for (Int last_col = 0; last_col < child_clique_size; ++last_col) {
153-
ops_current += child_clique_size - last_col;
154-
155-
if (ops_current > ops_per_thread || last_col == child_clique_size - 1) {
156-
tg.spawn([=]() {
157-
for (Int col = next_col; col <= last_col; ++col) {
158-
assembleChildSingleCol(child_sn, child, child_clique_size, col);
159-
}
160-
});
161-
next_col = last_col + 1;
162-
ops_current = 0;
142+
bool parallel = S_->parTree() || S_->parNode();
143+
144+
if (parallel) {
145+
// The loop over the columns of the child clique has completely independent
146+
// iterations. The loop is split evenly among the available threads.
147+
148+
TaskGroupSpecial tg;
149+
const Int threads = highs::parallel::num_threads();
150+
const double ops_per_thread =
151+
(double)child_clique_size * (child_clique_size + 1) / 2 / threads;
152+
double ops_current = 0;
153+
Int next_col = 0;
154+
for (Int last_col = 0; last_col < child_clique_size; ++last_col) {
155+
ops_current += child_clique_size - last_col;
156+
157+
if (ops_current > ops_per_thread || last_col == child_clique_size - 1) {
158+
tg.spawn([=]() {
159+
for (Int col = next_col; col <= last_col; ++col) {
160+
assembleChildSingleCol(child_sn, child, child_clique_size, col);
161+
}
162+
});
163+
next_col = last_col + 1;
164+
ops_current = 0;
165+
}
163166
}
164-
}
167+
tg.taskWait();
165168

166-
tg.taskWait();
169+
} else {
170+
for (Int col = 0; col < child_clique_size; ++col)
171+
assembleChildSingleCol(child_sn, child, child_clique_size, col);
172+
}
167173
}
168174

169175
void HybridPackedFormatHandler::extremeEntries() {

0 commit comments

Comments
 (0)