Skip to content

Commit a8caafb

Browse files
authored
Merge pull request #7663 from gudeh/gpl-fix-code-scan-defects
gpl: fix code scan defects
2 parents c930c92 + b20f73d commit a8caafb

File tree

7 files changed

+50
-39
lines changed

7 files changed

+50
-39
lines changed

src/gpl/src/initialPlace.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,6 @@ void InitialPlace::doBicgstabPlace(int threads)
7171
instLocVecY_,
7272
log_,
7373
threads);
74-
float error_max = std::max(error.x, error.y);
75-
log_->report(
76-
"[InitialPlace] Iter: {} conjugate gradient residual: {:0.8f} HPWL: "
77-
"{}",
78-
iter,
79-
error_max,
80-
pbc_->hpwl());
81-
updateCoordi();
8274

8375
if (graphics) {
8476
graphics->cellPlot(true);
@@ -91,6 +83,24 @@ void InitialPlace::doBicgstabPlace(int threads)
9183
gui->gifAddFrame(region, 500, dbu_per_pixel, 20);
9284
}
9385

86+
if (std::isnan(error.x) || std::isnan(error.y)) {
87+
log_->warn(GPL,
88+
154,
89+
"Conjugate gradient initial placement solver failed at "
90+
"iteration {}. ",
91+
iter);
92+
break;
93+
}
94+
95+
float error_max = std::max(error.x, error.y);
96+
log_->report(
97+
"[InitialPlace] Iter: {} conjugate gradient residual: {:0.8f} HPWL: "
98+
"{}",
99+
iter,
100+
error_max,
101+
pbc_->hpwl());
102+
updateCoordi();
103+
94104
if (error_max <= 1e-5 && iter >= 5) {
95105
break;
96106
}

src/gpl/src/mbff.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,9 @@ MBFF::Mask MBFF::GetArrayMask(dbInst* inst, const bool isTray)
637637

638638
const sta::Cell* cell = network_->dbToSta(inst->getMaster());
639639
const sta::LibertyCell* lib_cell = getLibertyCell(cell);
640-
for (const sta::Sequential* seq : lib_cell->sequentials()) {
641-
ret.func_idx = GetMatchingFunc(seq->data(), inst, isTray);
642-
break;
640+
const auto& seqs = lib_cell->sequentials();
641+
if (!seqs.empty()) {
642+
ret.func_idx = GetMatchingFunc(seqs.front()->data(), inst, isTray);
643643
}
644644

645645
ret.is_scan_cell = IsScanCell(inst);
@@ -828,9 +828,13 @@ void MBFF::ModifyPinConnections(const std::vector<Flop>& flops,
828828
}
829829
if (IsSupplyPin(iterm)) {
830830
if (iterm->getSigType() == odb::dbSigType::GROUND) {
831-
ground->connect(net);
831+
if (ground) {
832+
ground->connect(net);
833+
}
832834
} else {
833-
power->connect(net);
835+
if (power) {
836+
power->connect(net);
837+
}
834838
}
835839
}
836840
if (IsClockPin(iterm)) {
@@ -1773,6 +1777,10 @@ float MBFF::GetKSilh(const std::vector<std::vector<Flop>>& clusters,
17731777
tot += ((b_j - a_j) / std::max(a_j, b_j));
17741778
}
17751779
}
1780+
1781+
if (num_flops == 0) {
1782+
return 0.0f;
1783+
}
17761784
return tot / num_flops;
17771785
}
17781786

src/gpl/src/nesterovBase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,15 +1266,15 @@ class NesterovBase
12661266

12671267
bool isDiverged_ = false;
12681268

1269-
NesterovPlaceVars* npVars_;
1269+
NesterovPlaceVars* npVars_ = nullptr;
12701270

12711271
bool isMaxPhiCoefChanged_ = false;
12721272

12731273
float minSumOverflow_ = 1e30;
12741274
float hpwlWithMinSumOverflow_ = 1e30;
12751275
int iter_ = 0;
12761276
bool isConverged_ = false;
1277-
bool reprint_iter_header_;
1277+
bool reprint_iter_header_ = false;
12781278

12791279
void initFillerGCells();
12801280
};

src/gpl/src/nesterovPlace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class NesterovPlace
110110
float wireLengthCoefY_ = 0;
111111

112112
// observability metrics
113-
utl::Gauge<double>* hpwl_gauge_;
113+
utl::Gauge<double>* hpwl_gauge_ = nullptr;
114114

115115
// half-parameter-wire-length
116116
int64_t prevHpwl_ = 0;

src/gpl/src/routeBase.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -253,24 +253,6 @@ RouteBase::RouteBase(RouteBaseVars rbVars,
253253

254254
RouteBase::~RouteBase() = default;
255255

256-
void RouteBase::reset()
257-
{
258-
rbVars_.reset();
259-
db_ = nullptr;
260-
nbc_ = nullptr;
261-
log_ = nullptr;
262-
263-
numCall_ = 0;
264-
265-
minRc_ = 1e30;
266-
minRcTargetDensity_ = 0;
267-
minRcViolatedCnt_ = 0;
268-
269-
nbc_->resetMinRcCellSize();
270-
271-
resetRoutabilityResources();
272-
}
273-
274256
void RouteBase::resetRoutabilityResources()
275257
{
276258
inflatedAreaDelta_ = 0;

src/gpl/src/routeBase.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ class RouteBase
196196
int minRcViolatedCnt_ = 0;
197197

198198
void init();
199-
void reset();
200199
void resetRoutabilityResources();
201200

202201
// update numCall_

src/gpl/src/solver.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,28 @@ ResidualError cpuSparseSolve(int maxSolverIter,
2020
{
2121
omp_set_num_threads(threads);
2222

23-
ResidualError error;
23+
ResidualError residual_error;
2424
BiCGSTAB<SMatrix, IdentityPreconditioner> solver;
2525
solver.setMaxIterations(maxSolverIter);
26+
2627
solver.compute(placeInstForceMatrixX);
2728
instLocVecX = solver.solveWithGuess(fixedInstForceVecX, instLocVecX);
28-
error.x = solver.error();
29+
if (solver.info() == Eigen::NoConvergence
30+
|| solver.info() == Eigen::Success) {
31+
residual_error.x = solver.error();
32+
} else {
33+
residual_error.x = std::numeric_limits<float>::quiet_NaN();
34+
}
2935

3036
solver.compute(placeInstForceMatrixY);
3137
instLocVecY = solver.solveWithGuess(fixedInstForceVecY, instLocVecY);
32-
error.y = solver.error();
33-
return error;
38+
if (solver.info() == Eigen::NoConvergence
39+
|| solver.info() == Eigen::Success) {
40+
residual_error.y = solver.error();
41+
} else {
42+
residual_error.y = std::numeric_limits<float>::quiet_NaN();
43+
}
44+
45+
return residual_error;
3446
}
3547
} // namespace gpl

0 commit comments

Comments
 (0)