Skip to content

Commit

Permalink
Fix no-sign-compare warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Coloquinte committed Oct 16, 2023
1 parent 1010cc8 commit b72e6f1
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/coloquinte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ float Circuit::maxDisruption(const PlacementSolution &a,
std::vector<float> 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<float> ret;
Expand Down
20 changes: 10 additions & 10 deletions src/place_detailed/detailed_placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 9 additions & 9 deletions src/place_detailed/incr_net_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ namespace {
std::unordered_map<int, int> buildCellMapping(const Circuit &circuit,
const std::vector<int> &cells) {
std::unordered_map<int, int> 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;
Expand Down Expand Up @@ -173,7 +173,7 @@ IncrNetModel IncrNetModelBuilder::build() const {
}

IncrNetModel IncrNetModelBuilder::build(const std::vector<int> &pos) const {
assert(pos.size() == nbCells());
assert((int) pos.size() == nbCells());
IncrNetModel ret;
ret.netLimits_ = netLimits_;
ret.netCells_ = netCells_;
Expand Down Expand Up @@ -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()) {
Expand All @@ -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");
Expand Down
20 changes: 10 additions & 10 deletions src/place_detailed/legalizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Expand All @@ -108,8 +108,8 @@ void LegalizerBase::importLegalization(const LegalizerBase &leg,
std::vector<int> x = leg.cellLegalX();
std::vector<int> y = leg.cellLegalY();
std::vector<CellOrientation> 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];
Expand Down
28 changes: 14 additions & 14 deletions src/place_detailed/place_detailed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void DetailedPlacer::runInserts(int nbRows, int nbNeighbours) {

void DetailedPlacer::runSwapsOneRow(int row, int nbNeighbours) {
std::vector<int> 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<int> candidates(cells.begin() + b, cells.begin() + e);
Expand All @@ -184,7 +184,7 @@ void DetailedPlacer::runInsertsOneRow(int row, int nbNeighbours) {
std::vector<int> 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<int> candidates(cells.begin() + b, cells.begin() + e);
Expand All @@ -196,7 +196,7 @@ void DetailedPlacer::runSwapsTwoRows(int r1, int r2, int nbNeighbours) {
std::vector<int> cells1 = placement_.rowCells(r1);
std::vector<int> cells2 = placement_.rowCells(r2);
std::vector<int> 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);
Expand All @@ -221,7 +221,7 @@ void DetailedPlacer::runInsertsTwoRows(int r1, int r2, int nbNeighbours) {
std::vector<int> cells2 = placement_.rowCells(r2);
cells2.insert(cells2.begin(), -1);
std::vector<int> 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);
Expand Down Expand Up @@ -372,7 +372,7 @@ std::vector<int> 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) {
Expand Down Expand Up @@ -413,7 +413,7 @@ void DetailedPlacer::runShiftsOnRows(const std::vector<int> &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<int> subproblem(cells.begin() + start, cells.begin() + end);
runShiftsOnCells(subproblem);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand All @@ -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");
}
Expand Down
4 changes: 2 additions & 2 deletions src/place_global/density_legalizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ void DensityLegalizer::improveXTransport() {
pb.balanceDemand();
std::vector<int> assignment = pb.assign();
std::vector<std::vector<int> > 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) {
Expand Down Expand Up @@ -462,7 +462,7 @@ void DensityLegalizer::improveYTransport() {
pb.balanceDemand();
std::vector<int> assignment = pb.assign();
std::vector<std::vector<int> > 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) {
Expand Down

0 comments on commit b72e6f1

Please sign in to comment.