Skip to content

Commit 66d825f

Browse files
committed
Changes to FormatHandler::terminate
1 parent 68406f8 commit 66d825f

File tree

5 files changed

+33
-33
lines changed

5 files changed

+33
-33
lines changed

highs/ipm/hipo/factorhighs/Factorise.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,9 @@ void Factorise::processSupernode(Int sn) {
200200

201201
// initialise the format handler
202202
// this also allocates space for the frontal matrix and schur complement
203-
std::unique_ptr<FormatHandler> FH(
204-
new HybridHybridFormatHandler(S_, sn, regul_, data_, sn_columns_[sn]));
203+
std::unique_ptr<FormatHandler> FH(new HybridHybridFormatHandler(
204+
S_, sn, regul_, sn_columns_[sn], schur_contribution_[sn], swaps_[sn],
205+
pivot_2x2_[sn], data_));
205206

206207
#if HIPO_TIMING_LEVEL >= 2
207208
data_.sumTime(kTimeFactorisePrepare, clock.stop());
@@ -344,8 +345,7 @@ void Factorise::processSupernode(Int sn) {
344345
FH->extremeEntries();
345346

346347
// terminate the format handler
347-
FH->terminate(schur_contribution_[sn], total_reg_, swaps_[sn],
348-
pivot_2x2_[sn]);
348+
FH->terminate(total_reg_);
349349
#if HIPO_TIMING_LEVEL >= 2
350350
data_.sumTime(kTimeFactoriseTerminate, clock.stop());
351351
#endif

highs/ipm/hipo/factorhighs/FormatHandler.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,27 @@
77
namespace hipo {
88

99
FormatHandler::FormatHandler(const Symbolic& S, Int sn, const Regul& regul,
10-
std::vector<double>& frontal)
10+
std::vector<double>& frontal,
11+
std::vector<double>& clique,
12+
std::vector<Int>& swaps,
13+
std::vector<double>& pivot_2x2)
1114
: S_{&S},
1215
regul_{regul},
1316
sn_{sn},
1417
nb_{S_->blockSize()},
1518
sn_size_{S_->snStart(sn_ + 1) - S_->snStart(sn_)},
1619
ldf_{S_->ptr(sn_ + 1) - S_->ptr(sn_)},
1720
ldc_{ldf_ - sn_size_},
18-
frontal_{frontal} {
19-
local_reg_.resize(sn_size_);
20-
swaps_.resize(sn_size_);
21-
pivot_2x2_.resize(sn_size_);
21+
frontal_{frontal},
22+
clique_{clique},
23+
swaps_{swaps},
24+
pivot_2x2_{pivot_2x2} {
25+
local_reg_.assign(sn_size_, 0.0);
26+
swaps_.assign(sn_size_, 0);
27+
pivot_2x2_.assign(sn_size_, 0.0);
2228
}
2329

24-
void FormatHandler::terminate(std::vector<double>& clique,
25-
std::vector<double>& total_reg,
26-
std::vector<Int>& swaps,
27-
std::vector<double>& pivot_2x2) {
28-
// Move local copies of data into their final position.
29-
// In this way, the shared objects sn_columns_ and schur_contribution_ are
30-
// accessed only here, while a local copy is used for the assembly and dense
31-
// factorisation. This should avoid the problem of false sharing.
32-
33-
clique = std::move(clique_);
34-
swaps = std::move(swaps_);
35-
pivot_2x2 = std::move(pivot_2x2_);
36-
30+
void FormatHandler::terminate(std::vector<double>& total_reg) {
3731
// Move local regularisation into total regularisation.
3832
for (Int i = 0; i < sn_size_; ++i)
3933
total_reg[S_->snStart(sn_) + i] = local_reg_[i];

highs/ipm/hipo/factorhighs/FormatHandler.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ class FormatHandler {
4949

5050
// local copies to be moved at the end
5151
std::vector<double>& frontal_;
52-
std::vector<double> clique_{};
52+
std::vector<double>& clique_;
5353
std::vector<double> local_reg_{};
54-
std::vector<Int> swaps_{};
55-
std::vector<double> pivot_2x2_{};
54+
std::vector<Int>& swaps_;
55+
std::vector<double>& pivot_2x2_;
5656

5757
public:
5858
FormatHandler(const Symbolic& S, Int sn, const Regul& regul,
59-
std::vector<double>& frontal);
60-
void terminate(std::vector<double>& clique, std::vector<double>& total_reg,
61-
std::vector<Int>& swaps, std::vector<double>& pivot_2x2);
59+
std::vector<double>& frontal, std::vector<double>& clique,
60+
std::vector<Int>& swaps, std::vector<double>& pivot_2x2);
61+
void terminate(std::vector<double>& total_reg);
6262

6363
// avoid copies
6464
FormatHandler(const FormatHandler&) = delete;

highs/ipm/hipo/factorhighs/HybridHybridFormatHandler.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
namespace hipo {
99

1010
HybridHybridFormatHandler::HybridHybridFormatHandler(
11-
const Symbolic& S, Int sn, const Regul& regul, DataCollector& data,
12-
std::vector<double>& frontal)
13-
: FormatHandler(S, sn, regul, frontal), data_{data} {
11+
const Symbolic& S, Int sn, const Regul& regul, std::vector<double>& frontal,
12+
std::vector<double>& clique, std::vector<Int>& swaps,
13+
std::vector<double>& pivot_2x2, DataCollector& data)
14+
: FormatHandler(S, sn, regul, frontal, clique, swaps, pivot_2x2),
15+
data_{data} {
1416
// initialise frontal and clique
1517
initFrontal();
1618
initClique();
@@ -28,7 +30,7 @@ void HybridHybridFormatHandler::initFrontal() {
2830
}
2931

3032
void HybridHybridFormatHandler::initClique() {
31-
clique_.resize(S_->cliqueSize(sn_));
33+
clique_.assign(S_->cliqueSize(sn_), 0.0);
3234
}
3335

3436
void HybridHybridFormatHandler::assembleFrontal(Int i, Int j, double val) {

highs/ipm/hipo/factorhighs/HybridHybridFormatHandler.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ class HybridHybridFormatHandler : public FormatHandler {
2323

2424
public:
2525
HybridHybridFormatHandler(const Symbolic& S, Int sn, const Regul& regul,
26-
DataCollector& data, std::vector<double>& frontal);
26+
std::vector<double>& frontal,
27+
std::vector<double>& clique,
28+
std::vector<Int>& swaps,
29+
std::vector<double>& pivot_2x2,
30+
DataCollector& data);
2731
};
2832

2933
} // namespace hipo

0 commit comments

Comments
 (0)