Skip to content

Commit e91220a

Browse files
committed
Use for each
1 parent 952227c commit e91220a

File tree

2 files changed

+8
-25
lines changed

2 files changed

+8
-25
lines changed

highs/ipm/hipo/factorhighs/FactorHiGHSSettings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const double kDynamicDiagCoeff = 1e-24;
5151
const Int kMetisSeed = 42;
5252

5353
// parallel assembly
54-
const Int kParallelAssemblyThresh = 100;
54+
const Int kParallelAssemblyThresh = 50;
5555

5656
struct Regul {
5757
double primal{};

highs/ipm/hipo/factorhighs/HybridPackedFormatHandler.cpp

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -141,31 +141,14 @@ void HybridPackedFormatHandler::assembleChild(Int child_sn,
141141

142142
bool parallel = S_->parTree() || S_->parNode();
143143

144-
if (parallel && child_clique_size > kParallelAssemblyThresh) {
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) {
144+
if (parallel) {
145+
highs::parallel::for_each(
146+
0, child_clique_size,
147+
[=](Int start, Int end) {
148+
for (Int col = start; col < end; ++col)
160149
assembleChildSingleCol(child_sn, child, child_clique_size, col);
161-
}
162-
});
163-
next_col = last_col + 1;
164-
ops_current = 0;
165-
}
166-
}
167-
tg.taskWait();
168-
150+
},
151+
kParallelAssemblyThresh);
169152
} else {
170153
for (Int col = 0; col < child_clique_size; ++col)
171154
assembleChildSingleCol(child_sn, child, child_clique_size, col);

0 commit comments

Comments
 (0)