From b72e6f171b3a98c7d68ec684ddf64a3f9cb1d97a Mon Sep 17 00:00:00 2001 From: Gabriel Gouvine Date: Mon, 16 Oct 2023 12:07:57 +0200 Subject: [PATCH] Fix no-sign-compare warnings --- src/coloquinte.cpp | 2 +- src/place_detailed/detailed_placement.cpp | 20 ++++++++-------- src/place_detailed/incr_net_model.cpp | 18 +++++++-------- src/place_detailed/legalizer.cpp | 20 ++++++++-------- src/place_detailed/place_detailed.cpp | 28 +++++++++++------------ src/place_global/density_legalizer.cpp | 4 ++-- 6 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/coloquinte.cpp b/src/coloquinte.cpp index 6ae302f0..c79a2c94 100644 --- a/src/coloquinte.cpp +++ b/src/coloquinte.cpp @@ -771,7 +771,7 @@ float Circuit::maxDisruption(const PlacementSolution &a, std::vector Circuit::allDistances(const PlacementSolution &a, const PlacementSolution &b, LegalizationModel costModel) { - if (a.size() != nbCells() || b.size() != nbCells()) { + if ((int) a.size() != nbCells() || (int) b.size() != nbCells()) { throw std::runtime_error("Solution size doesn't match number of cells"); } std::vector ret; diff --git a/src/place_detailed/detailed_placement.cpp b/src/place_detailed/detailed_placement.cpp index 9cf53ead..c23729de 100644 --- a/src/place_detailed/detailed_placement.cpp +++ b/src/place_detailed/detailed_placement.cpp @@ -453,34 +453,34 @@ Point DetailedPlacement::positionOnInsert(int c, int row, int pred) const { } void DetailedPlacement::check() const { - if (rows_.size() != nbRows()) { + if ((int) rows_.size() != nbRows()) { throw std::runtime_error("Row size mismatch"); } - if (rowFirstCell_.size() != nbRows()) { + if ((int) rowFirstCell_.size() != nbRows()) { throw std::runtime_error("Row size mismatch"); } - if (rowLastCell_.size() != nbRows()) { + if ((int) rowLastCell_.size() != nbRows()) { throw std::runtime_error("Row size mismatch"); } - if (cellWidth_.size() != nbCells()) { + if ((int) cellWidth_.size() != nbCells()) { throw std::runtime_error("Cell size mismatch"); } - if (cellPred_.size() != nbCells()) { + if ((int) cellPred_.size() != nbCells()) { throw std::runtime_error("Cell size mismatch"); } - if (cellNext_.size() != nbCells()) { + if ((int) cellNext_.size() != nbCells()) { throw std::runtime_error("Cell size mismatch"); } - if (cellRow_.size() != nbCells()) { + if ((int) cellRow_.size() != nbCells()) { throw std::runtime_error("Cell size mismatch"); } - if (cellX_.size() != nbCells()) { + if ((int) cellX_.size() != nbCells()) { throw std::runtime_error("Cell size mismatch"); } - if (cellY_.size() != nbCells()) { + if ((int) cellY_.size() != nbCells()) { throw std::runtime_error("Cell size mismatch"); } - if (cellIndex_.size() != nbCells()) { + if ((int) cellIndex_.size() != nbCells()) { throw std::runtime_error("Cell size mismatch"); } for (int i = 0; i < nbRows(); ++i) { diff --git a/src/place_detailed/incr_net_model.cpp b/src/place_detailed/incr_net_model.cpp index 2d0b9e1f..caa63d99 100644 --- a/src/place_detailed/incr_net_model.cpp +++ b/src/place_detailed/incr_net_model.cpp @@ -47,10 +47,10 @@ namespace { std::unordered_map buildCellMapping(const Circuit &circuit, const std::vector &cells) { std::unordered_map cellMap; - for (int i = 0; i < cells.size(); ++i) { + for (size_t i = 0; i < cells.size(); ++i) { int c = cells[i]; assert(c >= 0 && c < circuit.nbCells()); - cellMap[c] = i; + cellMap[c] = (int) i; } assert(cellMap.size() == cells.size()); return cellMap; @@ -173,7 +173,7 @@ IncrNetModel IncrNetModelBuilder::build() const { } IncrNetModel IncrNetModelBuilder::build(const std::vector &pos) const { - assert(pos.size() == nbCells()); + assert((int) pos.size() == nbCells()); IncrNetModel ret; ret.netLimits_ = netLimits_; ret.netCells_ = netCells_; @@ -258,10 +258,10 @@ void IncrNetModel::recomputeNet(int net) { } void IncrNetModel::check() const { - if (netLimits_.size() != nbNets() + 1) { + if ((int) netLimits_.size() != nbNets() + 1) { throw std::runtime_error("Net number mismatch"); } - if (netLimits_.front() != 0 || netLimits_.back() != netCells_.size()) { + if (netLimits_.front() != 0 || netLimits_.back() != (int) netCells_.size()) { throw std::runtime_error("Pin number mismatch"); } if (netCells_.size() != netPinOffsets_.size()) { @@ -278,19 +278,19 @@ void IncrNetModel::check() const { throw std::runtime_error("Invalid number of pins in nets"); } } - if (cellLimits_.size() != nbCells() + 1) { + if ((int) cellLimits_.size() != nbCells() + 1) { throw std::runtime_error("Cell number mismatch"); } - if (cellLimits_.front() != 0 || cellLimits_.back() != cellNets_.size()) { + if (cellLimits_.front() != 0 || cellLimits_.back() != (int) cellNets_.size()) { throw std::runtime_error("Pin number mismatch"); } if (cellLimits_.back() != nbPins()) { throw std::runtime_error("Pin number mismatch"); } - if (cellNets_.size() != nbPins()) { + if ((int) cellNets_.size() != nbPins()) { throw std::runtime_error("Pin number mismatch"); } - assert(cellPinOffsets_.size() == nbPins()); + assert((int) cellPinOffsets_.size() == nbPins()); for (int i = 0; i < nbCells(); ++i) { if (cellLimits_[i] > cellLimits_[i + 1]) { throw std::runtime_error("Invalid number of pins in cell"); diff --git a/src/place_detailed/legalizer.cpp b/src/place_detailed/legalizer.cpp index 331aeb54..fe46aa14 100644 --- a/src/place_detailed/legalizer.cpp +++ b/src/place_detailed/legalizer.cpp @@ -63,29 +63,29 @@ LegalizerBase::LegalizerBase( } void LegalizerBase::check() const { - if (cellWidth_.size() != nbCells()) { + if ((int) cellWidth_.size() != nbCells()) { throw std::runtime_error("Number of cell widths does not match"); } - if (cellHeight_.size() != nbCells()) { + if ((int) cellHeight_.size() != nbCells()) { throw std::runtime_error("Number of cell heights does not match"); } - if (cellTargetX_.size() != nbCells()) { + if ((int) cellTargetX_.size() != nbCells()) { throw std::runtime_error("Number of cell x targets does not match"); } - if (cellTargetY_.size() != nbCells()) { + if ((int) cellTargetY_.size() != nbCells()) { throw std::runtime_error("Number of cell y targets does not match"); } - if (cellTargetOrientation_.size() != nbCells()) { + if ((int) cellTargetOrientation_.size() != nbCells()) { throw std::runtime_error( "Number of cell orientation targets does not match"); } - if (cellToX_.size() != nbCells()) { + if ((int) cellToX_.size() != nbCells()) { throw std::runtime_error("Number of cell x positions does not match"); } - if (cellToY_.size() != nbCells()) { + if ((int) cellToY_.size() != nbCells()) { throw std::runtime_error("Number of cell y positions does not match"); } - if (cellToOrientation_.size() != nbCells()) { + if ((int) cellToOrientation_.size() != nbCells()) { throw std::runtime_error("Number of cell orientations does not match"); } for (Row r : rows_) { @@ -108,8 +108,8 @@ void LegalizerBase::importLegalization(const LegalizerBase &leg, std::vector x = leg.cellLegalX(); std::vector y = leg.cellLegalY(); std::vector o = leg.cellLegalOrientation(); - assert(cells.size() == leg.nbCells()); - for (int i = 0; i < cells.size(); ++i) { + assert((int) cells.size() == leg.nbCells()); + for (size_t i = 0; i < cells.size(); ++i) { int c = cells[i]; if (leg.cellIsPlaced_[i]) { cellToX_[c] = x[i]; diff --git a/src/place_detailed/place_detailed.cpp b/src/place_detailed/place_detailed.cpp index 3e6137cb..dcc00c4f 100644 --- a/src/place_detailed/place_detailed.cpp +++ b/src/place_detailed/place_detailed.cpp @@ -172,7 +172,7 @@ void DetailedPlacer::runInserts(int nbRows, int nbNeighbours) { void DetailedPlacer::runSwapsOneRow(int row, int nbNeighbours) { std::vector cells = placement_.rowCells(row); - for (int i = 0; i < cells.size(); ++i) { + for (int i = 0; i < (int) cells.size(); ++i) { int b = std::max(0, i - nbNeighbours); int e = std::min((int)cells.size(), i + nbNeighbours + 1); std::vector candidates(cells.begin() + b, cells.begin() + e); @@ -184,7 +184,7 @@ void DetailedPlacer::runInsertsOneRow(int row, int nbNeighbours) { std::vector cells = placement_.rowCells(row); // Consider insertion before the first cell cells.insert(cells.begin(), -1); - for (int i = 1; i < cells.size(); ++i) { + for (int i = 1; i < (int) cells.size(); ++i) { int b = std::max(0, i - nbNeighbours); int e = std::min((int)cells.size(), i + nbNeighbours + 1); std::vector candidates(cells.begin() + b, cells.begin() + e); @@ -196,7 +196,7 @@ void DetailedPlacer::runSwapsTwoRows(int r1, int r2, int nbNeighbours) { std::vector cells1 = placement_.rowCells(r1); std::vector cells2 = placement_.rowCells(r2); std::vector closestIndex = computeClosestIndexInRow(cells1, cells2); - for (int i = 0; i < cells1.size(); ++i) { + for (int i = 0; i < (int) cells1.size(); ++i) { int closest = closestIndex[i]; int b = std::max(0, closest - nbNeighbours); int e = std::min((int)cells2.size(), closest + nbNeighbours + 1); @@ -221,7 +221,7 @@ void DetailedPlacer::runInsertsTwoRows(int r1, int r2, int nbNeighbours) { std::vector cells2 = placement_.rowCells(r2); cells2.insert(cells2.begin(), -1); std::vector closestIndex = computeClosestIndexInRow(cells1, cells2); - for (int i = 0; i < cells1.size(); ++i) { + for (int i = 0; i < (int) cells1.size(); ++i) { int closest = closestIndex[i]; int b = std::max(0, closest - nbNeighbours); int e = std::min((int)cells2.size(), closest + nbNeighbours + 1); @@ -372,7 +372,7 @@ std::vector DetailedPlacer::computeClosestIndexInRow( int x = placement_.cellX(row1Cell); while (true) { int c = row2Cells[closest]; - if (closest == row2Cells.size() - 1) { + if (closest == (int) row2Cells.size() - 1) { break; } if (c != -1 && placement_.cellX(c) < x) { @@ -413,7 +413,7 @@ void DetailedPlacer::runShiftsOnRows(const std::vector &rows, // Only select part of the cells so we never solve an optimization problem // bigger than maxNbCells int overlap = std::min(maxNbCells / 2, 10); - for (int start = 0; start < cells.size(); start += maxNbCells - overlap) { + for (int start = 0; start < (int) cells.size(); start += maxNbCells - overlap) { int end = std::min(start + maxNbCells, (int)cells.size()); std::vector subproblem(cells.begin() + start, cells.begin() + end); runShiftsOnCells(subproblem); @@ -564,12 +564,12 @@ class RowReordering { /** * @brief Number of registered regions */ - size_t nbRegions() const { return regions_.size(); } + int nbRegions() const { return regions_.size(); } /** * @brief Number of registered cells */ - size_t nbCells() const { return cells_.size(); } + int nbCells() const { return cells_.size(); } /** * @brief Add a region and its cells to be optimized @@ -737,7 +737,7 @@ void RowReordering::writeback() { for (int c : cells_) { placement_.unplace(c); } - for (size_t i = 0; i < nbRegions(); ++i) { + for (int i = 0; i < nbRegions(); ++i) { int pred = regions_[i].cellPred; for (size_t j = 0; j < bestOrder_[i].size(); ++j) { int c = bestOrder_[i][j]; @@ -758,15 +758,15 @@ void RowReordering::writeback() { } void RowReordering::check() const { - if (nbRegions() != order_.size()) + if (nbRegions() != (int) order_.size()) throw std::runtime_error("Inconsistent number of regions"); - if (nbRegions() != positions_.size()) + if (nbRegions() != (int) positions_.size()) throw std::runtime_error("Inconsistent number of regions"); - if (nbRegions() != bestOrder_.size()) + if (nbRegions() != (int) bestOrder_.size()) throw std::runtime_error("Inconsistent number of regions"); - if (nbRegions() != bestPositions_.size()) + if (nbRegions() != (int) bestPositions_.size()) throw std::runtime_error("Inconsistent number of regions"); - for (size_t i = 0; i < nbRegions(); ++i) { + for (int i = 0; i < nbRegions(); ++i) { if (bestOrder_[i].size() != bestPositions_[i].size()) throw std::runtime_error("Inconsistent number of cells in regions"); } diff --git a/src/place_global/density_legalizer.cpp b/src/place_global/density_legalizer.cpp index 37b5ab78..5299e905 100644 --- a/src/place_global/density_legalizer.cpp +++ b/src/place_global/density_legalizer.cpp @@ -428,7 +428,7 @@ void DensityLegalizer::improveXTransport() { pb.balanceDemand(); std::vector assignment = pb.assign(); std::vector > binCells(nbBinsX()); - for (int i = 0; i < cells.size(); ++i) { + for (size_t i = 0; i < cells.size(); ++i) { binCells[assignment[i]].push_back(cells[i]); } for (int i = 0; i < nbBinsX(); ++i) { @@ -462,7 +462,7 @@ void DensityLegalizer::improveYTransport() { pb.balanceDemand(); std::vector assignment = pb.assign(); std::vector > binCells(nbBinsY()); - for (int i = 0; i < cells.size(); ++i) { + for (size_t i = 0; i < cells.size(); ++i) { binCells[assignment[i]].push_back(cells[i]); } for (int j = 0; j < nbBinsY(); ++j) {