From d71ba37aa7c6f0fcc5b6f96b117d2b6dce6b84b1 Mon Sep 17 00:00:00 2001 From: Gabriel Gouvine Date: Mon, 27 Jul 2015 15:36:50 +0200 Subject: [PATCH] Changed Coloquinte's datastructures naming Used a big sed command Needs some testing --- coloquinte/src/MCF_opt.cxx | 16 +- coloquinte/src/cell_swapping.cxx | 30 ++-- coloquinte/src/checkers.cxx | 10 +- coloquinte/src/circuit.cxx | 94 +++++------ coloquinte/src/coloquinte/circuit_helper.hxx | 34 ++-- coloquinte/src/coloquinte/common.hxx | 62 ++++---- coloquinte/src/coloquinte/netlist.hxx | 2 +- .../src/coloquinte/rough_legalizers.hxx | 8 +- coloquinte/src/detailed.cxx | 8 +- coloquinte/src/legalizer.cxx | 46 +++--- coloquinte/src/orientation.cxx | 8 +- coloquinte/src/rough_legalizers.cxx | 146 +++++++++--------- coloquinte/src/row_opt.cxx | 28 ++-- coloquinte/src/topologies.cxx | 56 +++---- etesian/src/EtesianEngine.cpp | 18 +-- 15 files changed, 283 insertions(+), 283 deletions(-) diff --git a/coloquinte/src/MCF_opt.cxx b/coloquinte/src/MCF_opt.cxx index 40118721..67e46b5b 100644 --- a/coloquinte/src/MCF_opt.cxx +++ b/coloquinte/src/MCF_opt.cxx @@ -50,17 +50,17 @@ void optimize_on_topology_HPWL(netlist const & circuit, detailed_placement & pl) if((circuit.get_cell(i).attributes & XMovable) != 0 and (circuit.get_cell(oi).attributes & XMovable) != 0){ // Two movable cells: OK auto A = g.addArc(cell_nodes[oi], cell_nodes[i]); - constraint_arcs.push_back(arc_pair(A, -circuit.get_cell(i).size.x_)); + constraint_arcs.push_back(arc_pair(A, -circuit.get_cell(i).size.x)); } else if((circuit.get_cell( i).attributes & XMovable) != 0){ // The cell c is movable and constrained on the right auto A = g.addArc(fixed, cell_nodes[i]); - constraint_arcs.push_back(arc_pair(A, pl.plt_.positions_[oi].x_ - circuit.get_cell(i).size.x_)); + constraint_arcs.push_back(arc_pair(A, pl.plt_.positions_[oi].x - circuit.get_cell(i).size.x)); } else if((circuit.get_cell(oi).attributes & XMovable) != 0){ // The cell oc is movable and constrained on the left auto A = g.addArc(cell_nodes[oi], fixed); - constraint_arcs.push_back(arc_pair(A, -pl.plt_.positions_[i].x_ - circuit.get_cell(i).size.x_)); + constraint_arcs.push_back(arc_pair(A, -pl.plt_.positions_[i].x - circuit.get_cell(i).size.x)); } } } @@ -77,7 +77,7 @@ void optimize_on_topology_HPWL(netlist const & circuit, detailed_placement & pl) index_t rc = pl.row_last_cells_[r]; if(rc != null_ind and (circuit.get_cell(rc).attributes & XMovable) != 0){ auto Ar = g.addArc(fixed, cell_nodes[rc]); - constraint_arcs.push_back(arc_pair(Ar, pl.max_x_ - circuit.get_cell(rc).size.x_)); + constraint_arcs.push_back(arc_pair(Ar, pl.max_x_ - circuit.get_cell(rc).size.x)); } } @@ -86,7 +86,7 @@ void optimize_on_topology_HPWL(netlist const & circuit, detailed_placement & pl) for(index_t n=0; n= swp_min_c1 and swp_max_c2 >= swp_min_c2){ // Check both orientations of the cell @@ -49,20 +49,20 @@ std::function o2 = pl.plt_.orientations_[c2]; // Warning: won't work if the two cells don't have the same height - pl.plt_.positions_[c1].x_ = (swp_min_c1 + swp_max_c1) / 2; - pl.plt_.positions_[c2].x_ = (swp_min_c2 + swp_max_c2) / 2; - pl.plt_.positions_[c1].y_ = p2.y_; - pl.plt_.positions_[c2].y_ = p1.y_; + pl.plt_.positions_[c1].x = (swp_min_c1 + swp_max_c1) / 2; + pl.plt_.positions_[c2].x = (swp_min_c2 + swp_max_c2) / 2; + pl.plt_.positions_[c1].y = p2.y; + pl.plt_.positions_[c2].y = p1.y; // For standard cell placement, we want all the rows to be aligned in the same way if( (circuit.get_cell(c1).attributes & YFlippable) != 0 and (circuit.get_cell(c2).attributes & YFlippable) != 0) - std::swap(pl.plt_.orientations_[c1].y_, pl.plt_.orientations_[c2].y_); + std::swap(pl.plt_.orientations_[c1].y, pl.plt_.orientations_[c2].y); if(try_flip and (circuit.get_cell(c1).attributes & XFlippable) != 0 and (circuit.get_cell(c2).attributes & XFlippable) != 0){ index_t bst_ind = 4; for(index_t i=0; i<4; ++i){ - pl.plt_.orientations_[c1].x_ = i % 2; - pl.plt_.orientations_[c2].x_ = i / 2; + pl.plt_.orientations_[c1].x = i % 2; + pl.plt_.orientations_[c2].x = i / 2; std::int64_t new_cost = get_nets_cost(circuit, pl, involved_nets); if(new_cost < old_cost){ old_cost = new_cost; @@ -73,8 +73,8 @@ std::function= pos_hgh) ++nb_after; - if(pl.plt_.positions_[oc].x_ + circuit.get_cell(oc).size.x_ <= pos_low) ++ nb_before; + if(pl.plt_.positions_[oc].x >= pos_hgh) ++nb_after; + if(pl.plt_.positions_[oc].x + circuit.get_cell(oc).size.x <= pos_low) ++ nb_before; if(try_swap(circuit, pl, c, oc, try_flip, get_nets_cost)){ std::swap(c, oc); diff --git a/coloquinte/src/checkers.cxx b/coloquinte/src/checkers.cxx index effd340a..bd861947 100644 --- a/coloquinte/src/checkers.cxx +++ b/coloquinte/src/checkers.cxx @@ -22,7 +22,7 @@ void netlist::selfcheck() const{ assert(pin_cnt == net_indexes_.size()); for(auto const p : pin_offsets_){ - assert(std::isfinite(p.x_) and std::isfinite(p.y_)); + assert(std::isfinite(p.x) and std::isfinite(p.y)); } } @@ -57,10 +57,10 @@ void verify_placement_legality(netlist const & circuit, placement_t const & pl, for(index_t i=0; i b.x_min and e.y != b.y){ all_events.push_back(b); all_events.push_back(e); diff --git a/coloquinte/src/circuit.cxx b/coloquinte/src/circuit.cxx index 97a92975..4d9c0200 100644 --- a/coloquinte/src/circuit.cxx +++ b/coloquinte/src/circuit.cxx @@ -8,7 +8,7 @@ std::int64_t get_HPWL_length(netlist const & circuit, placement_t const & pl, in if(circuit.get_net(net_ind).pin_cnt <= 1) return 0; auto pins = get_pins_1D(circuit, pl, net_ind); - auto minmaxX = std::minmax_element(pins.x_.begin(), pins.x_.end()), minmaxY = std::minmax_element(pins.y_.begin(), pins.y_.end()); + auto minmaxX = std::minmax_element(pins.x.begin(), pins.x.end()), minmaxY = std::minmax_element(pins.y.begin(), pins.y.end()); return ((minmaxX.second->pos - minmaxX.first->pos) + (minmaxY.second->pos - minmaxY.first->pos)); } @@ -67,12 +67,12 @@ point empty_linear_systems(netlist const & circuit, placement_t c } if( (XMovable & circuit.get_cell(i).attributes) == 0 or not found_true_net){ - ret.x_.add_triplet(i, i, 1.0f); - ret.x_.add_doublet(i, pl.positions_[i].x_); + ret.x.add_triplet(i, i, 1.0f); + ret.x.add_doublet(i, pl.positions_[i].x); } if( (YMovable & circuit.get_cell(i).attributes) == 0 or not found_true_net){ - ret.y_.add_triplet(i, i, 1.0f); - ret.y_.add_doublet(i, pl.positions_[i].y_); + ret.y.add_triplet(i, i, 1.0f); + ret.y.add_doublet(i, pl.positions_[i].y); } } @@ -143,8 +143,8 @@ point get_HPWLF_linear_system (netlist const & circuit, placement if(pin_cnt < min_s or pin_cnt >= max_s) continue; auto pins = get_pins_1D(circuit, pl, i); - get_HPWLF(pins.x_, L.x_, tol); - get_HPWLF(pins.y_, L.y_, tol); + get_HPWLF(pins.x, L.x, tol); + get_HPWLF(pins.y, L.y, tol); } return L; } @@ -157,30 +157,30 @@ point get_HPWLR_linear_system (netlist const & circuit, placement if(pin_cnt < min_s or pin_cnt >= max_s) continue; auto pins = get_pins_1D(circuit, pl, i); - get_HPWLR(pins.x_, L.x_, tol); - get_HPWLR(pins.y_, L.y_, tol); + get_HPWLR(pins.x, L.x, tol); + get_HPWLR(pins.y, L.y, tol); } return L; } point get_star_linear_system (netlist const & circuit, placement_t const & pl, float_t tol, index_t min_s, index_t max_s){ point L = empty_linear_systems(circuit, pl); - L.x_.add_variables(circuit.net_cnt()); - L.y_.add_variables(circuit.net_cnt()); + L.x.add_variables(circuit.net_cnt()); + L.y.add_variables(circuit.net_cnt()); for(index_t i=0; i= max_s){ // Put a one in the intermediate variable in order to avoid non-invertible matrices - L.x_.add_triplet(i+circuit.cell_cnt(), i+circuit.cell_cnt(), 1.0f); - L.y_.add_triplet(i+circuit.cell_cnt(), i+circuit.cell_cnt(), 1.0f); + L.x.add_triplet(i+circuit.cell_cnt(), i+circuit.cell_cnt(), 1.0f); + L.y.add_triplet(i+circuit.cell_cnt(), i+circuit.cell_cnt(), 1.0f); continue; } auto pins = get_pins_1D(circuit, pl, i); // Provide the index of the star's central pin in the linear system - get_star(pins.x_, L.x_, tol, i+circuit.cell_cnt()); - get_star(pins.y_, L.y_, tol, i+circuit.cell_cnt()); + get_star(pins.x, L.x, tol, i+circuit.cell_cnt()); + get_star(pins.y, L.y, tol, i+circuit.cell_cnt()); } return L; } @@ -193,8 +193,8 @@ point get_clique_linear_system (netlist const & circuit, placemen if(pin_cnt < min_s or pin_cnt >= max_s) continue; auto pins = get_pins_1D(circuit, pl, i); - get_clique(pins.x_, L.x_, tol); - get_clique(pins.y_, L.y_, tol); + get_clique(pins.x, L.x, tol); + get_clique(pins.y, L.y, tol); } return L; } @@ -213,8 +213,8 @@ point get_MST_linear_system(netlist const & circuit, placement_t } auto const edges = get_MST_topology(points); for(auto E : edges){ - add_force(pins[E.first].x(), pins[E.second].x(), L.x_, tol, 1.0f); - add_force(pins[E.first].y(), pins[E.second].y(), L.y_, tol, 1.0f); + add_force(pins[E.first].x(), pins[E.second].x(), L.x, tol, 1.0f); + add_force(pins[E.first].y(), pins[E.second].y(), L.y, tol, 1.0f); } } return L; @@ -233,11 +233,11 @@ point get_RSMT_linear_system(netlist const & circuit, placement_t points.push_back(p.pos); } auto const edges = get_RSMT_topology(points, 8); - for(auto E : edges.x_){ - add_force(pins[E.first].x(), pins[E.second].x(), L.x_, tol, 1.0f); + for(auto E : edges.x){ + add_force(pins[E.first].x(), pins[E.second].x(), L.x, tol, 1.0f); } - for(auto E : edges.y_){ - add_force(pins[E.first].y(), pins[E.second].y(), L.y_, tol, 1.0f); + for(auto E : edges.y){ + add_force(pins[E.first].y(), pins[E.second].y(), L.y, tol, 1.0f); } } return L; @@ -278,28 +278,28 @@ void solve_linear_system(netlist const & circuit, placement_t & pl, point x_sol, y_sol; std::vector x_guess(pl.cell_cnt()), y_guess(pl.cell_cnt()); - assert(L.x_.internal_size() == x_guess.size()); - assert(L.y_.internal_size() == y_guess.size()); + assert(L.x.internal_size() == x_guess.size()); + assert(L.y.internal_size() == y_guess.size()); for(index_t i=0; i(pl.positions_[i].x_); - y_guess[i] = static_cast(pl.positions_[i].y_); + x_guess[i] = static_cast(pl.positions_[i].x); + y_guess[i] = static_cast(pl.positions_[i].y); } #pragma omp parallel sections num_threads(2) { #pragma omp section - x_sol = L.x_.solve_CG(x_guess, nbr_iter); + x_sol = L.x.solve_CG(x_guess, nbr_iter); #pragma omp section - y_sol = L.y_.solve_CG(y_guess, nbr_iter); + y_sol = L.y.solve_CG(y_guess, nbr_iter); } for(index_t i=0; i(x_sol[i]); + pl.positions_[i].x = static_cast(x_sol[i]); } if( (circuit.get_cell(i).attributes & YMovable) != 0){ assert(std::isfinite(y_sol[i])); - pl.positions_[i].y_ = static_cast(y_sol[i]); + pl.positions_[i].y = static_cast(y_sol[i]); } } } @@ -325,13 +325,13 @@ point get_pulling_forces (netlist const & circuit, placement_t co float_t typical_force = 1.0f / typical_distance; std::vector scaling = get_area_scales(circuit); for(index_t i=0; i get_linear_pulling_forces (netlist const & circuit, placeme assert(LB_pl.cell_cnt() == UB_pl.cell_cnt()); std::vector scaling = get_area_scales(circuit); for(index_t i=0; i(std::abs(UB_pl.positions_[i].x_ - LB_pl.positions_[i].x_)), min_distance)), - i, UB_pl.positions_[i].x_ + L.x.add_anchor( + force * scaling[i] / (std::max(static_cast(std::abs(UB_pl.positions_[i].x - LB_pl.positions_[i].x)), min_distance)), + i, UB_pl.positions_[i].x ); - L.y_.add_anchor( - force * scaling[i] / (std::max(static_cast(std::abs(UB_pl.positions_[i].y_ - LB_pl.positions_[i].y_)), min_distance)), - i, UB_pl.positions_[i].y_ + L.y.add_anchor( + force * scaling[i] / (std::max(static_cast(std::abs(UB_pl.positions_[i].y - LB_pl.positions_[i].y)), min_distance)), + i, UB_pl.positions_[i].y ); } @@ -375,10 +375,10 @@ float_t get_mean_linear_disruption(netlist const & circuit, placement_t const & float_t area = static_cast(circuit.get_cell(i).area); point diff = LB_pl.positions_[i] - UB_pl.positions_[i]; - if( (circuit.get_cell(i).attributes & XMovable) == 0) assert(diff.x_ == 0); - if( (circuit.get_cell(i).attributes & YMovable) == 0) assert(diff.y_ == 0); + if( (circuit.get_cell(i).attributes & XMovable) == 0) assert(diff.x == 0); + if( (circuit.get_cell(i).attributes & YMovable) == 0) assert(diff.y == 0); - tot_cost += area * (std::abs(diff.x_) + std::abs(diff.y_)); + tot_cost += area * (std::abs(diff.x) + std::abs(diff.y)); tot_area += area; } return tot_cost / tot_area; @@ -391,10 +391,10 @@ float_t get_mean_quadratic_disruption(netlist const & circuit, placement_t const float_t area = static_cast(circuit.get_cell(i).area); point diff = LB_pl.positions_[i] - UB_pl.positions_[i]; - if( (circuit.get_cell(i).attributes & XMovable) == 0) assert(diff.x_ == 0); - if( (circuit.get_cell(i).attributes & YMovable) == 0) assert(diff.y_ == 0); + if( (circuit.get_cell(i).attributes & XMovable) == 0) assert(diff.x == 0); + if( (circuit.get_cell(i).attributes & YMovable) == 0) assert(diff.y == 0); - float_t manhattan = (std::abs(diff.x_) + std::abs(diff.y_)); + float_t manhattan = (std::abs(diff.x) + std::abs(diff.y)); tot_cost += area * manhattan * manhattan; tot_area += area; } diff --git a/coloquinte/src/coloquinte/circuit_helper.hxx b/coloquinte/src/coloquinte/circuit_helper.hxx index 53187393..ae002480 100644 --- a/coloquinte/src/coloquinte/circuit_helper.hxx +++ b/coloquinte/src/coloquinte/circuit_helper.hxx @@ -24,28 +24,28 @@ struct pin_2D{ bool movable; pin_2D(index_t c, point p, point o, bool m) : cell_ind(c), pos(p), offs(o), movable(m){} - pin_1D x() const{ return pin_1D(cell_ind, pos.x_, offs.x_, movable); } - pin_1D y() const{ return pin_1D(cell_ind, pos.y_, offs.y_, movable); } + pin_1D x() const{ return pin_1D(cell_ind, pos.x, offs.x, movable); } + pin_1D y() const{ return pin_1D(cell_ind, pos.y, offs.y, movable); } }; inline int_t dist(pin_2D const a, pin_2D const b){ point diff = a.pos - b.pos; - return std::abs(diff.x_) + std::abs(diff.y_); + return std::abs(diff.x) + std::abs(diff.y); } inline std::vector get_pins_2D(netlist const & circuit, placement_t const & pl, index_t net_ind){ std::vector ret; for(auto p : circuit.get_net(net_ind)){ - assert(std::isfinite(pl.positions_[p.cell_ind].x_) and std::isfinite(pl.positions_[p.cell_ind].y_)); - assert(std::isfinite(pl.orientations_[p.cell_ind].x_) and std::isfinite(pl.orientations_[p.cell_ind].y_)); + assert(std::isfinite(pl.positions_[p.cell_ind].x) and std::isfinite(pl.positions_[p.cell_ind].y)); + assert(std::isfinite(pl.orientations_[p.cell_ind].x) and std::isfinite(pl.orientations_[p.cell_ind].y)); point offs; - offs.x_ = pl.orientations_[p.cell_ind].x_ ? p.offset.x_ : circuit.get_cell(p.cell_ind).size.x_ - p.offset.x_; - offs.y_ = pl.orientations_[p.cell_ind].y_ ? p.offset.y_ : circuit.get_cell(p.cell_ind).size.y_ - p.offset.y_; + offs.x = pl.orientations_[p.cell_ind].x ? p.offset.x : circuit.get_cell(p.cell_ind).size.x - p.offset.x; + offs.y = pl.orientations_[p.cell_ind].y ? p.offset.y : circuit.get_cell(p.cell_ind).size.y - p.offset.y; point pos = offs + pl.positions_[p.cell_ind]; - assert(std::isfinite(offs.x_) and std::isfinite(offs.y_)); - assert(std::isfinite(pos.x_) and std::isfinite(pos.y_)); + assert(std::isfinite(offs.x) and std::isfinite(offs.y)); + assert(std::isfinite(pos.x) and std::isfinite(pos.y)); bool movable = (circuit.get_cell(p.cell_ind).attributes & XMovable) != 0 and (circuit.get_cell(p.cell_ind).attributes & YMovable) != 0; ret.push_back(pin_2D(p.cell_ind, pos, offs, movable)); @@ -56,22 +56,22 @@ inline std::vector get_pins_2D(netlist const & circuit, placemen inline point > get_pins_1D(netlist const & circuit, placement_t const & pl, index_t net_ind){ point > ret; for(auto p : circuit.get_net(net_ind)){ - assert(std::isfinite(pl.positions_[p.cell_ind].x_) and std::isfinite(pl.positions_[p.cell_ind].y_)); - assert(std::isfinite(pl.orientations_[p.cell_ind].x_) and std::isfinite(pl.orientations_[p.cell_ind].y_)); + assert(std::isfinite(pl.positions_[p.cell_ind].x) and std::isfinite(pl.positions_[p.cell_ind].y)); + assert(std::isfinite(pl.orientations_[p.cell_ind].x) and std::isfinite(pl.orientations_[p.cell_ind].y)); point offs; - offs.x_ = pl.orientations_[p.cell_ind].x_ ? p.offset.x_ : circuit.get_cell(p.cell_ind).size.x_ - p.offset.x_; - offs.y_ = pl.orientations_[p.cell_ind].y_ ? p.offset.y_ : circuit.get_cell(p.cell_ind).size.y_ - p.offset.y_; + offs.x = pl.orientations_[p.cell_ind].x ? p.offset.x : circuit.get_cell(p.cell_ind).size.x - p.offset.x; + offs.y = pl.orientations_[p.cell_ind].y ? p.offset.y : circuit.get_cell(p.cell_ind).size.y - p.offset.y; point pos = offs + pl.positions_[p.cell_ind]; - assert(std::isfinite(offs.x_) and std::isfinite(offs.y_)); - assert(std::isfinite(pos.x_) and std::isfinite(pos.y_)); + assert(std::isfinite(offs.x) and std::isfinite(offs.y)); + assert(std::isfinite(pos.x) and std::isfinite(pos.y)); bool x_movable = (circuit.get_cell(p.cell_ind).attributes & XMovable) != 0; bool y_movable = (circuit.get_cell(p.cell_ind).attributes & YMovable) != 0; - ret.x_.push_back(pin_1D(p.cell_ind, pos.x_, offs.x_, x_movable)); - ret.y_.push_back(pin_1D(p.cell_ind, pos.y_, offs.y_, y_movable)); + ret.x.push_back(pin_1D(p.cell_ind, pos.x, offs.x, x_movable)); + ret.y.push_back(pin_1D(p.cell_ind, pos.y, offs.y, y_movable)); } return ret; } diff --git a/coloquinte/src/coloquinte/common.hxx b/coloquinte/src/coloquinte/common.hxx index 97025967..b31be557 100644 --- a/coloquinte/src/coloquinte/common.hxx +++ b/coloquinte/src/coloquinte/common.hxx @@ -30,83 +30,83 @@ enum Movability{ template struct point{ - T x_, y_; + T x, y; point(){} - point(T x, T y): x_(x), y_(y){} + point(T x, T y): x(x), y(y){} template operator point() const{ - return point(static_cast(x_), static_cast(y_)); + return point(static_cast(x), static_cast(y)); } void operator+=(point const o){ - x_ += o.x_; - y_ += o.y_; + x += o.x; + y += o.y; } }; template point operator+(point const a, point const b){ - return point(a.x_+b.x_, a.y_+b.y_); + return point(a.x+b.x, a.y+b.y); } template point operator-(point const a, point const b){ - return point(a.x_-b.x_, a.y_-b.y_); + return point(a.x-b.x, a.y-b.y); } template point operator*(T lambda, point const p){ - return point(lambda * p.x_, lambda * p.y_); + return point(lambda * p.x, lambda * p.y); } template point operator*(point const a, point const b){ - return point(a.x_*b.x_, a.y_*b.y_); + return point(a.x*b.x, a.y*b.y); } template struct box{ - T x_min_, x_max_, y_min_, y_max_; + T x_min, x_max, y_min, y_max; box(){} - box(T x_mn, T x_mx, T y_mn, T y_mx) : x_min_(x_mn), x_max_(x_mx), y_min_(y_mn), y_max_(y_mx){} - box(point mn, point mx) : x_min_(mn.x_), x_max_(mx.x_), y_min_(mn.y_), y_max_(mx.y_){} + box(T x_mn, T x_mx, T y_mn, T y_mx) : x_min(x_mn), x_max(x_mx), y_min(y_mn), y_max(y_mx){} + box(point mn, point mx) : x_min(mn.x), x_max(mx.x), y_min(mn.y), y_max(mx.y){} bool in(box const o) const{ - return x_max_ <= o.x_max_ - && y_max_ <= o.y_max_ - && x_min_ >= o.x_min_ - && y_min_ >= o.y_min_; + return x_max <= o.x_max + && y_max <= o.y_max + && x_min >= o.x_min + && y_min >= o.y_min; } bool intersects(box const o) const{ - return x_min_ < o.x_max_ - && y_min_ < o.y_max_ - && o.x_min_ < x_max_ - && o.y_min_ < y_max_; + return x_min < o.x_max + && y_min < o.y_max + && o.x_min < x_max + && o.y_min < y_max; } box intersection(box const o) const{ return box( - std::max(x_min_, o.x_min_), - std::min(x_max_, o.x_max_), - std::max(y_min_, o.y_min_), - std::min(y_max_, o.y_max_) + std::max(x_min, o.x_min), + std::min(x_max, o.x_max), + std::max(y_min, o.y_min), + std::min(y_max, o.y_max) ); } box bounding_box(box const o) const{ return box( - std::min(x_min_, o.x_min_), - std::max(x_max_, o.x_max_), - std::min(y_min_, o.y_min_), - std::max(y_max_, o.y_max_) + std::min(x_min, o.x_min), + std::max(x_max, o.x_max), + std::min(y_min, o.y_min), + std::max(y_max, o.y_max) ); } point dimensions() const{ - return point(x_max_-x_min_, y_max_-y_min_); + return point(x_max-x_min, y_max-y_min); } bool empty() const{ - return dimensions().x_ <= 0 or dimensions().y_ <= 0; + return dimensions().x <= 0 or dimensions().y <= 0; } template operator box() const{ - return box(static_cast(x_min_), static_cast(x_max_), static_cast(y_min_), static_cast(y_max_)); + return box(static_cast(x_min), static_cast(x_max), static_cast(y_min), static_cast(y_max)); } }; diff --git a/coloquinte/src/coloquinte/netlist.hxx b/coloquinte/src/coloquinte/netlist.hxx index ac45e761..cdf45448 100644 --- a/coloquinte/src/coloquinte/netlist.hxx +++ b/coloquinte/src/coloquinte/netlist.hxx @@ -24,7 +24,7 @@ struct temporary_cell{ index_t list_index; temporary_cell(){} - temporary_cell(point s, mask_t attr, index_t ind) : size(s), attributes(attr), list_index(ind){ area = static_cast(s.x_) * static_cast(s.y_);} + temporary_cell(point s, mask_t attr, index_t ind) : size(s), attributes(attr), list_index(ind){ area = static_cast(s.x) * static_cast(s.y);} }; struct temporary_net{ diff --git a/coloquinte/src/coloquinte/rough_legalizers.hxx b/coloquinte/src/coloquinte/rough_legalizers.hxx index 6f86ac6f..6e43387a 100644 --- a/coloquinte/src/coloquinte/rough_legalizers.hxx +++ b/coloquinte/src/coloquinte/rough_legalizers.hxx @@ -212,7 +212,7 @@ inline region_distribution::movable_cell::movable_cell(capacity_t demand, point< inline box region_distribution::placement_area() const { return placement_area_; } inline point region_distribution::region_dimensions() const { point s = static_cast >(placement_area().dimensions()); - return point(s.x_/x_regions_cnt(), s.y_/y_regions_cnt()); + return point(s.x/x_regions_cnt(), s.y/y_regions_cnt()); } inline index_t region_distribution::x_regions_cnt() const { return x_regions_cnt_; } @@ -247,10 +247,10 @@ inline capacity_t region_distribution::region::allocated_capacity() const{ inline index_t region_distribution::region::cell_cnt() const{ return cell_references_.size(); } inline float_t region_distribution::region::distance(region_distribution::cell_ref const & C) const{ - return std::abs(pos_.x_ - C.pos_.x_) + std::abs(pos_.y_ - C.pos_.y_); + return std::abs(pos_.x - C.pos_.x) + std::abs(pos_.y - C.pos_.y); /* - float_t manhattan = std::max(static_cast(0.0), std::max(C.pos_.x_ - surface_.x_max_, surface_.x_min_ - C.pos_.x_)) - + std::max(static_cast(0.0), std::max(C.pos_.y_ - surface_.y_max_, surface_.y_min_ - C.pos_.y_)); + float_t manhattan = std::max(static_cast(0.0), std::max(C.pos_.x - surface_.x_max, surface_.x_min - C.pos_.x)) + + std::max(static_cast(0.0), std::max(C.pos_.y - surface_.y_max, surface_.y_min - C.pos_.y)); return manhattan * (1.0 + manhattan * 0.0001); */ } diff --git a/coloquinte/src/detailed.cxx b/coloquinte/src/detailed.cxx index dafc22cf..5009318e 100644 --- a/coloquinte/src/detailed.cxx +++ b/coloquinte/src/detailed.cxx @@ -78,7 +78,7 @@ void detailed_placement::selfcheck() const{ for(index_t i=0; i= min_x_ and c.position.x_ + c.width <= max_x_); + // : assert(c.position.x >= min_x_ and c.position.x + c.width <= max_x_); index_t n_ind = l + neighbours_limits_[i]; assert(cell_rows_[i] + cell_height(i) <= row_cnt()); @@ -143,10 +143,10 @@ std::pair detailed_placement::get_limit_positions(netlist const & a_i = neighbours_[l].second; if(b_i != null_ind){ - ret.first = std::max(ret.first, plt_.positions_[b_i].x_ + circuit.get_cell(b_i).size.x_); + ret.first = std::max(ret.first, plt_.positions_[b_i].x + circuit.get_cell(b_i).size.x); } if(a_i != null_ind){ - ret.second = std::min(ret.second, plt_.positions_[a_i].x_); + ret.second = std::min(ret.second, plt_.positions_[a_i].x); } } return ret; @@ -250,7 +250,7 @@ void detailed_placement::reorder_standard_cells(std::vector const old_o void row_compatible_orientation(netlist const & circuit, detailed_placement & pl, bool first_row_orient){ for(index_t c=0; c good_legalize( detailed_placement legalize(netlist const & circuit, placement_t const & pl, box surface, int_t row_height){ if(row_height <= 0) throw std::runtime_error("The rows' height should be positive\n"); - index_t nbr_rows = (surface.y_max_ - surface.y_min_) / row_height; - // The position of the ith row is surface.y_min_ + i * row_height + index_t nbr_rows = (surface.y_max - surface.y_min) / row_height; + // The position of the ith row is surface.y_min + i * row_height std::vector > row_occupation(nbr_rows); std::vector cells; @@ -372,32 +372,32 @@ detailed_placement legalize(netlist const & circuit, placement_t const & pl, box if( (cur.attributes & XMovable) != 0 && (cur.attributes & YMovable) != 0){ // Just truncate the position we target point target_pos = pl.positions_[i]; - index_t cur_cell_rows = (cur.size.y_ + row_height -1) / row_height; - cells.push_back(cell_to_leg(target_pos.x_, target_pos.y_, i, cur.size.x_, cur_cell_rows)); + index_t cur_cell_rows = (cur.size.y + row_height -1) / row_height; + cells.push_back(cell_to_leg(target_pos.x, target_pos.y, i, cur.size.x, cur_cell_rows)); cell_heights[i] = cur_cell_rows; } else{ // In each row, we put the index of the fixed cell and the range that is already occupied - int_t low_x_pos = pl.positions_[i].x_, - hgh_x_pos = pl.positions_[i].x_ + cur.size.x_, - low_y_pos = pl.positions_[i].y_, - hgh_y_pos = pl.positions_[i].y_ + cur.size.y_; + int_t low_x_pos = pl.positions_[i].x, + hgh_x_pos = pl.positions_[i].x + cur.size.x, + low_y_pos = pl.positions_[i].y, + hgh_y_pos = pl.positions_[i].y + cur.size.y; new_placement.positions_[i] = point(low_x_pos, low_y_pos); - if(hgh_y_pos <= surface.y_min_ or low_y_pos >= surface.y_max_ or hgh_x_pos <= surface.x_min_ or low_x_pos >= surface.x_max_){ + if(hgh_y_pos <= surface.y_min or low_y_pos >= surface.y_max or hgh_x_pos <= surface.x_min or low_x_pos >= surface.x_max){ placement_rows[i] = null_ind; cell_heights[i] = 0; } else{ assert(low_x_pos < hgh_x_pos and low_y_pos < hgh_y_pos); - int_t rnd_hgh_x_pos = std::min(surface.x_max_, hgh_x_pos); - int_t rnd_hgh_y_pos = std::min(surface.y_max_, hgh_y_pos); - int_t rnd_low_x_pos = std::max(surface.x_min_, low_x_pos); - int_t rnd_low_y_pos = std::max(surface.y_min_, low_y_pos); + int_t rnd_hgh_x_pos = std::min(surface.x_max, hgh_x_pos); + int_t rnd_hgh_y_pos = std::min(surface.y_max, hgh_y_pos); + int_t rnd_low_x_pos = std::max(surface.x_min, low_x_pos); + int_t rnd_low_y_pos = std::max(surface.y_min, low_y_pos); - index_t first_row = (rnd_low_y_pos - surface.y_min_) / row_height; - index_t last_row = (index_t) (rnd_hgh_y_pos - surface.y_min_ + row_height - 1) / row_height; // Exclusive: if the cell spans the next row, i.e. pos % row_height >= 0, include it too + index_t first_row = (rnd_low_y_pos - surface.y_min) / row_height; + index_t last_row = (index_t) (rnd_hgh_y_pos - surface.y_min + row_height - 1) / row_height; // Exclusive: if the cell spans the next row, i.e. pos % row_height >= 0, include it too assert(last_row <= nbr_rows); placement_rows[i] = first_row; @@ -421,12 +421,12 @@ detailed_placement legalize(netlist const & circuit, placement_t const & pl, box std::vector > cells_by_rows; auto final_cells = good_legalize(row_occupation, cells, cells_by_rows, - surface.x_min_, surface.x_max_, surface.y_min_, + surface.x_min, surface.x_max, surface.y_min, row_height, nbr_rows ); for(cell_leg_properties C : final_cells){ - new_placement.positions_[C.ind] = point(C.x_pos, static_cast(C.row_pos) * row_height + surface.y_min_); + new_placement.positions_[C.ind] = point(C.x_pos, static_cast(C.row_pos) * row_height + surface.y_min); placement_rows[C.ind] = C.row_pos; } @@ -435,8 +435,8 @@ detailed_placement legalize(netlist const & circuit, placement_t const & pl, box placement_rows, cell_heights, cells_by_rows, - surface.x_min_, surface.x_max_, - surface.y_min_, + surface.x_min, surface.x_max, + surface.y_min, nbr_rows, row_height ); } diff --git a/coloquinte/src/orientation.cxx b/coloquinte/src/orientation.cxx index 1cd8ec21..fed113c6 100644 --- a/coloquinte/src/orientation.cxx +++ b/coloquinte/src/orientation.cxx @@ -141,10 +141,10 @@ inline void spread_orient(netlist const & circuit, placement_t & pl, std::functi } // End anonymous namespace void optimize_x_orientations(netlist const & circuit, placement_t & pl){ - opt_orient(circuit, pl, [](point p) -> int_t { return p.x_; }, [](point & p) -> bool & { return p.x_; }, XFlippable); + opt_orient(circuit, pl, [](point p) -> int_t { return p.x; }, [](point & p) -> bool & { return p.x; }, XFlippable); } void optimize_y_orientations(netlist const & circuit, placement_t & pl){ - opt_orient(circuit, pl, [](point p) -> int_t { return p.y_; }, [](point & p) -> bool & { return p.y_; }, YFlippable); + opt_orient(circuit, pl, [](point p) -> int_t { return p.y; }, [](point & p) -> bool & { return p.y; }, YFlippable); } // Iteratively optimize feasible orientations; performs only one pass @@ -155,8 +155,8 @@ void optimize_exact_orientations(netlist const & circuit, placement_t & pl){ /* void spread_orientations(netlist const & circuit, placement_t & pl){ - spread_orient(circuit, pl, [](point & p) -> float_t & { return p.x_; }, XFlippable); - spread_orient(circuit, pl, [](point & p) -> float_t & { return p.y_; }, YFlippable); + spread_orient(circuit, pl, [](point & p) -> float_t & { return p.x; }, XFlippable); + spread_orient(circuit, pl, [](point & p) -> float_t & { return p.y; }, YFlippable); } */ diff --git a/coloquinte/src/rough_legalizers.cxx b/coloquinte/src/rough_legalizers.cxx index ff6e33da..a2cde3e9 100644 --- a/coloquinte/src/rough_legalizers.cxx +++ b/coloquinte/src/rough_legalizers.cxx @@ -79,28 +79,28 @@ region_distribution::region::region(capacity_t cap, point pos, std::vec box region_distribution::get_box(index_t x, index_t y, index_t x_cnt, index_t y_cnt) const{ auto ret = box( - placement_area_.x_min_ + ( ((std::int64_t) (placement_area_.x_max_ - placement_area_.x_min_)) * x ) / x_cnt, - placement_area_.x_min_ + ( ((std::int64_t) (placement_area_.x_max_ - placement_area_.x_min_)) * (x+1) ) / x_cnt, - placement_area_.y_min_ + ( ((std::int64_t) (placement_area_.y_max_ - placement_area_.y_min_)) * y ) / y_cnt, - placement_area_.y_min_ + ( ((std::int64_t) (placement_area_.y_max_ - placement_area_.y_min_)) * (y+1) ) / y_cnt + placement_area_.x_min + ( ((std::int64_t) (placement_area_.x_max - placement_area_.x_min)) * x ) / x_cnt, + placement_area_.x_min + ( ((std::int64_t) (placement_area_.x_max - placement_area_.x_min)) * (x+1) ) / x_cnt, + placement_area_.y_min + ( ((std::int64_t) (placement_area_.y_max - placement_area_.y_min)) * y ) / y_cnt, + placement_area_.y_min + ( ((std::int64_t) (placement_area_.y_max - placement_area_.y_min)) * (y+1) ) / y_cnt ); assert(not ret.empty()); return ret; } std::vector region_distribution::prepare_regions(index_t x_cnt, index_t y_cnt) const{ - assert(placement_area_.x_max_ > placement_area_.x_min_); - assert(placement_area_.y_max_ > placement_area_.y_min_); + assert(placement_area_.x_max > placement_area_.x_min); + assert(placement_area_.y_max > placement_area_.y_min); // Uses a sweepline algorithm to initialize all regions' capacities at a time, taking macros and density maps into account - // The events in the priority queue: basically a density_limit object, but the y_min_ may be different from the original one + // The events in the priority queue: basically a density_limit object, but the y_min may be different from the original one struct event{ box box_; capacity_t multiplicator_; bool operator<(event const o) const{ - return box_.y_min_ > o.box_.y_min_ // Priority queue = highest first - or (box_.y_min_ == o.box_.y_min_ and multiplicator_ > o.multiplicator_); // Smallest density first, just because + return box_.y_min > o.box_.y_min // Priority queue = highest first + or (box_.y_min == o.box_.y_min and multiplicator_ > o.multiplicator_); // Smallest density first, just because } event(box surface, capacity_t den) : box_(surface), multiplicator_(den) {} event(density_limit D, capacity_t density_mul) : box_(D.box_) { @@ -109,9 +109,9 @@ std::vector region_distribution::prepare_regions(in }; struct line_y{ - int_t y_min_, y_max_; + int_t y_min, y_max; capacity_t multiplicator_; - line_y(int_t mn, int_t mx, capacity_t cap) : y_min_(mn), y_max_(mx), multiplicator_(cap) {} + line_y(int_t mn, int_t mx, capacity_t cap) : y_min(mn), y_max(mx), multiplicator_(cap) {} }; // The regions' capacities @@ -120,10 +120,10 @@ std::vector region_distribution::prepare_regions(in // Find the limits of the regions std::vector x_reg_lims(x_cnt+1), y_reg_lims(y_cnt+1); for(index_t i=0; i<=x_cnt; ++i){ - x_reg_lims[i] = placement_area_.x_min_ + ( ((std::int64_t) (placement_area_.x_max_ - placement_area_.x_min_)) * i ) / x_cnt; + x_reg_lims[i] = placement_area_.x_min + ( ((std::int64_t) (placement_area_.x_max - placement_area_.x_min)) * i ) / x_cnt; } for(index_t i=0; i<=y_cnt; ++i){ - y_reg_lims[i] = placement_area_.y_min_ + ( ((std::int64_t) (placement_area_.y_max_ - placement_area_.y_min_)) * i ) / y_cnt; + y_reg_lims[i] = placement_area_.y_min + ( ((std::int64_t) (placement_area_.y_max - placement_area_.y_min)) * i ) / y_cnt; } //std::vector > added; @@ -132,12 +132,12 @@ std::vector region_distribution::prepare_regions(in /* // Failed attempt at calculating the coordinates directly point dims = placement_area_.dimensions(); - auto mins = point(placement_area_.x_min_, placement_area_.y_min_); + auto mins = point(placement_area_.x_min, placement_area_.y_min); - index_t x_mn = (static_cast(bx.x_min_ - mins.x_ + 1) * x_cnt) / dims.x_, - x_mx = (static_cast(bx.x_max_ - mins.x_ - 1) * x_cnt) / dims.x_ + 1, - y_mn = (static_cast(bx.y_min_ - mins.y_ + 1) * y_cnt) / dims.y_, - y_mx = (static_cast(bx.y_max_ - mins.y_ - 1) * y_cnt) / dims.y_ + 1; + index_t x_mn = (static_cast(bx.x_min - mins.x + 1) * x_cnt) / dims.x, + x_mx = (static_cast(bx.x_max - mins.x - 1) * x_cnt) / dims.x + 1, + y_mn = (static_cast(bx.y_min - mins.y + 1) * y_cnt) / dims.y, + y_mx = (static_cast(bx.y_max - mins.y - 1) * y_cnt) / dims.y + 1; */ /* @@ -148,15 +148,15 @@ std::vector region_distribution::prepare_regions(in added.push_back(bx); */ - assert(bx.x_min_ >= placement_area_.x_min_); - assert(bx.y_min_ >= placement_area_.y_min_); - assert(bx.x_max_ <= placement_area_.x_max_); - assert(bx.y_max_ <= placement_area_.y_max_); + assert(bx.x_min >= placement_area_.x_min); + assert(bx.y_min >= placement_area_.y_min); + assert(bx.x_max <= placement_area_.x_max); + assert(bx.y_max <= placement_area_.y_max); - index_t x_mn = std::upper_bound(x_reg_lims.begin(), x_reg_lims.end(), bx.x_min_) - x_reg_lims.begin() -1, - y_mn = std::upper_bound(y_reg_lims.begin(), y_reg_lims.end(), bx.y_min_) - y_reg_lims.begin() -1, - x_mx = std::lower_bound(x_reg_lims.begin(), x_reg_lims.end(), bx.x_max_) - x_reg_lims.begin(), - y_mx = std::lower_bound(y_reg_lims.begin(), y_reg_lims.end(), bx.y_max_) - y_reg_lims.begin(); + index_t x_mn = std::upper_bound(x_reg_lims.begin(), x_reg_lims.end(), bx.x_min) - x_reg_lims.begin() -1, + y_mn = std::upper_bound(y_reg_lims.begin(), y_reg_lims.end(), bx.y_min) - y_reg_lims.begin() -1, + x_mx = std::lower_bound(x_reg_lims.begin(), x_reg_lims.end(), bx.x_max) - x_reg_lims.begin(), + y_mx = std::lower_bound(y_reg_lims.begin(), y_reg_lims.end(), bx.y_max) - y_reg_lims.begin(); for(index_t x=x_mn; x region_distribution::prepare_regions(in assert(bx.intersects(cur_box)); box inter = bx.intersection(cur_box); point dims = inter.dimensions(); - region_caps[y*x_cnt + x] += d * static_cast(dims.x_) * static_cast(dims.y_); + region_caps[y*x_cnt + x] += d * static_cast(dims.x) * static_cast(dims.y); } } }; @@ -186,24 +186,24 @@ std::vector region_distribution::prepare_regions(in // The initial sweepline, with begin and end of the line std::map active_obstacles; - line_y placement_begin (placement_area_.y_min_, placement_area_.y_max_, full_density_mul), - placement_end (placement_area_.y_min_, placement_area_.y_max_, 0); + line_y placement_begin (placement_area_.y_min, placement_area_.y_max, full_density_mul), + placement_end (placement_area_.y_min, placement_area_.y_max, 0); - active_obstacles.insert(std::pair(placement_area_.x_min_, placement_begin)); // Full density placement area as initial object - active_obstacles.insert(std::pair(placement_area_.x_max_, placement_end)); + active_obstacles.insert(std::pair(placement_area_.x_min, placement_begin)); // Full density placement area as initial object + active_obstacles.insert(std::pair(placement_area_.x_max, placement_end)); // Main loop: sweep the line on y (the line is horizontal, and moves toward bigger y) while(not events.empty()){ event D = events.top(); - int_t x_b=D.box_.x_min_, x_e=D.box_.x_max_; - int_t y_b=D.box_.y_min_, y_e=D.box_.y_max_; + int_t x_b=D.box_.x_min, x_e=D.box_.x_max; + int_t y_b=D.box_.y_min, y_e=D.box_.y_max; events.pop(); - assert(x_b >= placement_area_.x_min_); - assert(y_b >= placement_area_.y_min_); - assert(x_e <= placement_area_.x_max_); - assert(y_e <= placement_area_.y_max_); + assert(x_b >= placement_area_.x_min); + assert(y_b >= placement_area_.y_min); + assert(x_e <= placement_area_.x_max); + assert(y_e <= placement_area_.y_max); // For each delimitation between the bounds of the new rectangle // If the new delimitation has higher density or this delimitation ends on y there @@ -215,7 +215,7 @@ std::vector region_distribution::prepare_regions(in line_y const new_elt(y_b, y_e, D.multiplicator_); std::vector new_delimitations; - // First element on the line whose x_ is after our x_min (i.e. may have an intersection), and while there is an intersection + // First element on the line whose x is after our x_min (i.e. may have an intersection), and while there is an intersection auto first_it = active_obstacles.upper_bound(x_b); assert(first_it != active_obstacles.begin()); assert(std::prev(first_it)->first <= x_b); @@ -224,8 +224,8 @@ std::vector region_distribution::prepare_regions(in for(auto it = std::prev(first_it); it != active_obstacles.end() and it->first < x_e;){ auto next_it = std::next(it); assert(next_it != active_obstacles.end()); - assert(it->second.y_min_ <= y_b); - assert(it->second.y_max_ >= y_b); + assert(it->second.y_min <= y_b); + assert(it->second.y_max >= y_b); assert(it->first < x_e); assert(next_it->first > x_b); assert(next_it-> first > it->first); @@ -233,18 +233,18 @@ std::vector region_distribution::prepare_regions(in int_t x_c_min = std::max(x_b, it->first), x_c_max = std::min(x_e, next_it->first); assert(x_c_min < x_c_max); - // Add the area from it->second.y_min_ to D.box_.y_min_ - if(y_b > it->second.y_min_) - add_region(box(it->first, next_it->first, it->second.y_min_, y_b), it->second.multiplicator_); - it->second.y_min_ = y_b; // Now the part before has been used + // Add the area from it->second.y_min to D.box_.y_min + if(y_b > it->second.y_min) + add_region(box(it->first, next_it->first, it->second.y_min, y_b), it->second.multiplicator_); + it->second.y_min = y_b; // Now the part before has been used auto part_b = *it, part_e = *next_it; - if(part_b.second.multiplicator_ > D.multiplicator_ or part_b.second.y_max_ == y_b){ // The new event is visible now + if(part_b.second.multiplicator_ > D.multiplicator_ or part_b.second.y_max == y_b){ // The new event is visible now // In case parts of the line become visible again later - if(part_b.second.y_max_ > y_e){ // Push back a new event to account for the comeback - events.push(event(box(x_c_min, x_c_max, y_e, part_b.second.y_max_), part_b.second.multiplicator_)); + if(part_b.second.y_max > y_e){ // Push back a new event to account for the comeback + events.push(event(box(x_c_min, x_c_max, y_e, part_b.second.y_max), part_b.second.multiplicator_)); } // Depending whether this part of the line is or is not fully covered @@ -265,8 +265,8 @@ std::vector region_distribution::prepare_regions(in } else{ // The new event is not visible yet currently_in = false; - if(part_b.second.y_max_ < y_e){ // Push back a new event - events.push(event(box(x_c_min, x_c_max, part_b.second.y_max_, y_e), D.multiplicator_)); + if(part_b.second.y_max < y_e){ // Push back a new event + events.push(event(box(x_c_min, x_c_max, part_b.second.y_max, y_e), D.multiplicator_)); } } @@ -274,8 +274,8 @@ std::vector region_distribution::prepare_regions(in } } for(auto it=active_obstacles.begin(); std::next(it) != active_obstacles.end(); ++it){ - assert(it->second.y_max_ == placement_area_.y_max_); - add_region(box(it->first, std::next(it)->first, it->second.y_min_, it->second.y_max_), it->second.multiplicator_); + assert(it->second.y_max == placement_area_.y_max); + add_region(box(it->first, std::next(it)->first, it->second.y_min, it->second.y_max), it->second.multiplicator_); } std::vector ret(x_cnt*y_cnt); @@ -284,7 +284,7 @@ std::vector region_distribution::prepare_regions(in box bx = get_box(x, y, x_cnt, y_cnt); ret[y*x_cnt + x] = region( region_caps[y*x_cnt + x], - point(0.5f * bx.x_min_ + 0.5f * bx.x_max_, 0.5f * bx.y_min_ + 0.5f * bx.y_max_), + point(0.5f * bx.x_min + 0.5f * bx.x_max, 0.5f * bx.y_min + 0.5f * bx.y_max), std::vector() ); } @@ -437,7 +437,7 @@ void region_distribution::region::distribute_new_cells(std::vector b.allocated_capacity_ or (a.allocated_capacity_ == b.allocated_capacity_ and a.pos_.x_+a.pos_.y_ < b.pos_.x_+b.pos_.y_); }); + std::sort(all_cells.begin(), all_cells.end(), [](cell_ref const a, cell_ref const b){ return a.allocated_capacity_ > b.allocated_capacity_ or (a.allocated_capacity_ == b.allocated_capacity_ and a.pos_.x+a.pos_.y < b.pos_.x+b.pos_.y); }); std::vector > costs(regions.size()); std::vector demands; @@ -704,7 +704,7 @@ void region_distribution::redo_line_partitions(){ for(index_t x=0; x(get_region(x, y))); } - region::redistribute_cells(regs, [](point p){ return p.x_; }); + region::redistribute_cells(regs, [](point p){ return p.x; }); } #pragma omp parallel for for(index_t x=0; x(get_region(x, y))); } - region::redistribute_cells(regs, [](point p){ return p.y_; }); + region::redistribute_cells(regs, [](point p){ return p.y; }); } } @@ -737,7 +737,7 @@ void region_distribution::x_resize(index_t sz){ for(index_t x=0; x(get_region(x, y))); } - region::distribute_new_cells(regs, cells, [](point p){ return p.x_; }); + region::distribute_new_cells(regs, cells, [](point p){ return p.x; }); } } @@ -762,7 +762,7 @@ void region_distribution::y_resize(index_t sz){ for(index_t y=0; y(get_region(x, y))); } - region::distribute_new_cells(regs, cells, [](point p){ return p.y_; }); + region::distribute_new_cells(regs, cells, [](point p){ return p.y; }); } } @@ -823,7 +823,7 @@ region_distribution::region_distribution( auto pos = pl.positions_[i]; auto end = pos + c.size; density_limit macro; - macro.box_ = box(pos.x_, end.x_, pos.y_, end.y_); + macro.box_ = box(pos.x, end.x, pos.y, end.y); macro.density_ = 0.0f; density_map_.push_back(macro); } @@ -969,11 +969,11 @@ std::vector region_distribution::export_sprea for(index_t i=0; i pt = R.cell_references_[i].pos_; float_t cap = static_cast(R.cell_references_[i].allocated_capacity_); - x_cells[i] = OSRP_task(pt.x_, cap/total_capacity * (surface.x_max_ - surface.x_min_), 1.0, i); - y_cells[i] = OSRP_task(pt.y_, cap/total_capacity * (surface.y_max_ - surface.y_min_), 1.0, i); + x_cells[i] = OSRP_task(pt.x, cap/total_capacity * (surface.x_max - surface.x_min), 1.0, i); + y_cells[i] = OSRP_task(pt.y, cap/total_capacity * (surface.y_max - surface.y_min), 1.0, i); } - std::vector x_ret = get_optimal_quadratic_pos(x_cells, surface.x_min_, surface.x_max_); - std::vector y_ret = get_optimal_quadratic_pos(y_cells, surface.y_min_, surface.y_max_); + std::vector x_ret = get_optimal_quadratic_pos(x_cells, surface.x_min, surface.x_max); + std::vector y_ret = get_optimal_quadratic_pos(y_cells, surface.y_min, surface.y_max); for(index_t i=0; i region_distribution::export_sprea movable_cell C = cell_list_[i]; assert(C.demand_ > 0); C.pos_ = ( static_cast(1.0) / static_cast(C.demand_) ) * weighted_pos[i]; - assert(std::isfinite(C.pos_.x_) and std::isfinite(C.pos_.y_)); + assert(std::isfinite(C.pos_.x) and std::isfinite(C.pos_.y)); ret.push_back(C); } return ret; @@ -1003,19 +1003,19 @@ std::vector region_distribution::export_sprea index_t n = R.cell_references_.size(); float_t total_capacity = static_cast(R.capacity()); box surface = static_cast >(get_box(x, y, x_regions_cnt(), y_regions_cnt())); - assert(surface.x_max_ > surface.x_min_ and surface.y_max_ > surface.y_min_); + assert(surface.x_max > surface.x_min and surface.y_max > surface.y_min); std::vector > x_cells, y_cells; for(auto const C : R.cell_references_){ float_t cap = static_cast(C.allocated_capacity_); - float_t x_cap_prop = cap/total_capacity * (surface.x_max_ - surface.x_min_), - y_cap_prop = cap/total_capacity * (surface.y_max_ - surface.y_min_); - x_cells.push_back(legalizable_task(x_cap_prop, C.pos_.x_, C.index_in_list_)); - y_cells.push_back(legalizable_task(y_cap_prop, C.pos_.y_, C.index_in_list_)); + float_t x_cap_prop = cap/total_capacity * (surface.x_max - surface.x_min), + y_cap_prop = cap/total_capacity * (surface.y_max - surface.y_min); + x_cells.push_back(legalizable_task(x_cap_prop, C.pos_.x, C.index_in_list_)); + y_cells.push_back(legalizable_task(y_cap_prop, C.pos_.y, C.index_in_list_)); } - OSRP_leg x_leg(surface.x_min_, surface.x_max_), y_leg(surface.y_min_, surface.y_max_); + OSRP_leg x_leg(surface.x_min, surface.x_max), y_leg(surface.y_min, surface.y_max); std::sort(x_cells.begin(), x_cells.end()); for(legalizable_task & C : x_cells) @@ -1025,7 +1025,7 @@ std::vector region_distribution::export_sprea auto x_pl = x_leg.get_placement(); for(index_t i=0; i(x_cells[i].width * total_capacity / (surface.x_max_ - surface.x_min_)); + weighted_pos[x_pl[i].first].x += (x_pl[i].second + 0.5f * x_cells[i].width) * static_cast(x_cells[i].width * total_capacity / (surface.x_max - surface.x_min)); } std::sort(y_cells.begin(), y_cells.end()); @@ -1036,7 +1036,7 @@ std::vector region_distribution::export_sprea auto y_pl = y_leg.get_placement(); for(index_t i=0; i(y_cells[i].width * total_capacity / (surface.y_max_ - surface.y_min_)); + weighted_pos[y_pl[i].first].y += (y_pl[i].second + 0.5f * y_cells[i].width) * static_cast(y_cells[i].width * total_capacity / (surface.y_max - surface.y_min)); } } } @@ -1046,7 +1046,7 @@ std::vector region_distribution::export_sprea movable_cell C = cell_list_[i]; assert(C.demand_ > 0); C.pos_ = ( 1.0f / static_cast(C.demand_ * cell_density_mul) ) * weighted_pos[i]; - assert(std::isfinite(C.pos_.x_) and std::isfinite(C.pos_.y_)); + assert(std::isfinite(C.pos_.x) and std::isfinite(C.pos_.y)); ret.push_back(C); } return ret; @@ -1055,7 +1055,7 @@ std::vector region_distribution::export_sprea float_t region_distribution::region::cost() const{ float_t res = 0.0; for(cell_ref const C : cell_references_){ - res += (std::abs(C.pos_.x_-pos_.x_) + std::abs(C.pos_.y_-pos_.y_)) * static_cast(C.allocated_capacity_); + res += (std::abs(C.pos_.x-pos_.x) + std::abs(C.pos_.y-pos_.y)) * static_cast(C.allocated_capacity_); } return res; } diff --git a/coloquinte/src/row_opt.cxx b/coloquinte/src/row_opt.cxx index 5b67410b..5e91c34b 100644 --- a/coloquinte/src/row_opt.cxx +++ b/coloquinte/src/row_opt.cxx @@ -180,10 +180,10 @@ Hnet_group get_B2B_netgroup(netlist const & circuit, detailed_placement const & Hnet_group ret; for(index_t c : cells) - ret.cell_widths.push_back(circuit.get_cell(c).size.x_); + ret.cell_widths.push_back(circuit.get_cell(c).size.x); for(index_t n : involved_nets){ - std::vector cur_pins = get_pins_1D(circuit, pl.plt_, n).x_; + std::vector cur_pins = get_pins_1D(circuit, pl.plt_, n).x; for(pin_1D & p : cur_pins){ auto it = std::lower_bound(cells_in_row.begin(), cells_in_row.end(), p.cell_ind); if(it != cells_in_row.end() and it->cell_ind == p.cell_ind){ @@ -206,7 +206,7 @@ Hnet_group get_RSMT_netgroup(netlist const & circuit, detailed_placement const & Hnet_group ret; for(index_t c : cells) - ret.cell_widths.push_back(circuit.get_cell(c).size.x_); + ret.cell_widths.push_back(circuit.get_cell(c).size.x); for(index_t n : involved_nets){ auto vpins = get_pins_2D(circuit, pl.plt_, n); @@ -223,7 +223,7 @@ Hnet_group get_RSMT_netgroup(netlist const & circuit, detailed_placement const & std::vector > pin_locations; for(auto p : vpins) pin_locations.push_back(p.pos); - auto const Htopo = get_RSMT_topology(pin_locations, 8).x_; + auto const Htopo = get_RSMT_topology(pin_locations, 8).x; // In the horizontal topology, we transform the parts of the tree that are on the row into HPWL subnets // Two pins sharing an edge are in the same subnet if one of them is on the row: use union-find @@ -432,7 +432,7 @@ std::vector > get_cell_ranges(netlist const & circuit, d std::vector > lims; for(index_t i=0; i+1 > get_cell_ranges(netlist const & circuit, d for(index_t OSRP_cell : cells){ auto attr = circuit.get_cell(OSRP_cell).attributes; auto cur_lim = std::pair(lower_lim, upper_lim); - int_t pos = pl.plt_.positions_[OSRP_cell].x_; + int_t pos = pl.plt_.positions_[OSRP_cell].x; if( (attr & XMovable) == 0 or pl.cell_height(OSRP_cell) != 1){ - cur_lim = std::pair(pos, pos + circuit.get_cell(OSRP_cell).size.x_); + cur_lim = std::pair(pos, pos + circuit.get_cell(OSRP_cell).size.x); } else{ assert(pos >= lower_lim); - assert(pos + circuit.get_cell(OSRP_cell).size.x_ <= upper_lim); + assert(pos + circuit.get_cell(OSRP_cell).size.x <= upper_lim); } lims.push_back(cur_lim); } @@ -486,8 +486,8 @@ void OSRP_generic(netlist const & circuit, detailed_placement & pl){ std::vector flipped; optimize_noncvx_sequence(nets, no_permutation, final_positions, flipped, flippability, lims); for(index_t i=0; i int_t Hconnectivity::get_wirelength(std::array, pin_cnt> const sorted_points) const{ std::array minmaxs; for(index_t i=0; i> 4; - minmaxs[b_con].merge(sorted_points.front() .y_); - minmaxs[e_con].merge(sorted_points.back() .y_); + minmaxs[b_con].merge(sorted_points.front() .y); + minmaxs[e_con].merge(sorted_points.back() .y); for(std::uint8_t const E : connexions){ minmaxs[(E >> 4)].merge(minmaxs[(E & 15u)]); } - int_t cost = sorted_points.back().x_ - sorted_points.front().x_ + sorted_points[b_con+1].x_ - sorted_points[e_con+1].x_; + int_t cost = sorted_points.back().x - sorted_points.front().x + sorted_points[b_con+1].x - sorted_points[e_con+1].x; for(std::uint8_t const E : connexions){ - cost += std::abs(sorted_points[(E >> 4) +1].x_ - sorted_points[(E & 15u) +1].x_); + cost += std::abs(sorted_points[(E >> 4) +1].x - sorted_points[(E & 15u) +1].x); } for(index_t i=0; i > const & pins, std::a std::int64_t get_wirelength_from_topo(std::vector > const & points, std::vector > Htopo){ std::vector minmaxs(points.size()); for(index_t i=0; i get_vertical_topology(std::vector > pins, std:: ipoints[i] = indexed_pt(pins[i], i); } - std::sort(ipoints.begin(), ipoints.end(), [](indexed_pt a , indexed_pt b){return a.y_ < b.y_; }); + std::sort(ipoints.begin(), ipoints.end(), [](indexed_pt a , indexed_pt b){return a.y < b.y; }); // First pin with y ordering std::vector min_y_pin(pins.size()); @@ -222,19 +222,19 @@ inline void northeast_octant_neighbours(std::vector > pins, std::ve } std::sort(point_list.begin(), point_list.end(), - [](indexed_pt const a, indexed_pt const b){ return a.x_ + a.y_ < b.x_ + b.y_; } + [](indexed_pt const a, indexed_pt const b){ return a.x + a.y < b.x + b.y; } ); // Decreasing order of x and y; multiset not necessary because no two elements have same coordinate std::set > - active_upper_octant([](indexed_pt const a, indexed_pt const b)->bool{return a.x_ > b.x_;}), - active_lower_octant([](indexed_pt const a, indexed_pt const b)->bool{return a.y_ > b.y_;}); + active_upper_octant([](indexed_pt const a, indexed_pt const b)->bool{return a.x > b.x;}), + active_lower_octant([](indexed_pt const a, indexed_pt const b)->bool{return a.y > b.y;}); for(indexed_pt const current : point_list){ { // North to north-east region auto first_it = active_upper_octant.lower_bound(current); // Largest x with x <= current.x auto it = first_it; - for(; it != active_upper_octant.end() && it->x_ - it->y_ >= current.x_ - current.y_; ++it){ + for(; it != active_upper_octant.end() && it->x - it->y >= current.x - current.y; ++it){ edges.push_back(std::pair(current.index, it->index)); } if(first_it != active_upper_octant.end()){ active_upper_octant.erase(first_it, it); } @@ -243,7 +243,7 @@ inline void northeast_octant_neighbours(std::vector > pins, std::ve { // North-east to east region auto first_it = active_lower_octant.lower_bound(current); // Largest y with y <= current.y auto it = first_it; - for(; it != active_lower_octant.end() && it->y_ - it->x_ >= current.y_ - current.x_; ++it){ + for(; it != active_lower_octant.end() && it->y - it->x >= current.y - current.x; ++it){ edges.push_back(std::pair(current.index, it->index)); } if(first_it != active_lower_octant.end()){ active_lower_octant.erase(first_it, it); } @@ -255,7 +255,7 @@ inline void northeast_octant_neighbours(std::vector > pins, std::ve // Gets the nearest octant neighbour for each point in the south-east quadrant inline void southeast_octant_neighbours(std::vector > pins, std::vector > & edges){ for(auto & pin : pins){ - pin.y_ = - pin.y_; + pin.y = - pin.y; } northeast_octant_neighbours(pins, edges); } @@ -336,7 +336,7 @@ std::vector get_big_horizontal_topology_from_sorted(std::vector > inverted_coords = pins; for(point & pt : inverted_coords){ - std::swap(pt.x_, pt.y_); + std::swap(pt.x, pt.y); } auto Htopo = get_vertical_topology(inverted_coords, Vtopo); @@ -356,7 +356,7 @@ std::vector get_RSMT_horizontal_topology(std::vector > cons ipoints[i] = indexed_pt(pins[i], i); } auto xpoints=ipoints; - std::sort(xpoints.begin(), xpoints.end(), [](indexed_pt a , indexed_pt b){return a.x_ < b.x_; }); + std::sort(xpoints.begin(), xpoints.end(), [](indexed_pt a , indexed_pt b){return a.x < b.x; }); return std::vector{{xpoints[0].index, xpoints[1].index}, {xpoints[1].index, xpoints[2].index}}; } @@ -368,7 +368,7 @@ std::vector get_RSMT_horizontal_topology(std::vector > cons for(index_t i=0; i > sorted_pins(pins.size()); for(index_t i=0; i > get_MST_topology(std::vector a, point b){ return std::abs(a.x_ - b.x_) + std::abs(a.y_ - b.y_); }; + auto D = [](point a, point b){ return std::abs(a.x - b.x) + std::abs(a.y - b.y); }; auto dists = std::array({D(pins[1], pins[2]), D(pins[1], pins[2]), D(pins[0], pins[1])}); index_t mx = std::max_element(dists.begin(), dists.end()) - dists.begin(); for(index_t i=0; i<3; ++i){ @@ -420,7 +420,7 @@ std::vector > get_MST_topology(std::vector p1 = pins[E.first], p2 = pins[E.second]; - return std::abs(p1.x_ - p2.x_) + std::abs(p1.y_ - p2.y_); + return std::abs(p1.x - p2.x) + std::abs(p1.y - p2.y); }; // Perform Kruskal to get the tree std::sort(edges.begin(), edges.end(), [&](edge_t a, edge_t b){ return edge_length(a) < edge_length(b); }); @@ -444,8 +444,8 @@ std::int64_t MST_length(std::vector > const & pins){ auto edges = get_MST_topology(pins); std::int64_t sum = 0; for(auto E : edges){ - sum += std::abs(pins[E.first].x_ - pins[E.second].x_); - sum += std::abs(pins[E.first].y_ - pins[E.second].y_); + sum += std::abs(pins[E.first].x - pins[E.second].x); + sum += std::abs(pins[E.first].y - pins[E.second].y); } return sum; } @@ -454,12 +454,12 @@ std::int64_t RSMT_length(std::vector > const & pins, index_t exacti assert(exactitude_limit <= 10 and exactitude_limit >= 3); if(pins.size() <= 3){ if(pins.size() == 2){ - return std::abs(pins[0].x_ - pins[1].x_) + std::abs(pins[0].y_ - pins[1].y_); + return std::abs(pins[0].x - pins[1].x) + std::abs(pins[0].y - pins[1].y); } else if(pins.size() == 3){ - auto minmaxX = std::minmax_element(pins.begin(), pins.end(), [](point a, point b){ return a.x_ < b.x_; }), - minmaxY = std::minmax_element(pins.begin(), pins.end(), [](point a, point b){ return a.y_ < b.y_; }); - return (minmaxX.second->x_ - minmaxX.first->x_) + (minmaxY.second->y_ - minmaxY.first->y_); + auto minmaxX = std::minmax_element(pins.begin(), pins.end(), [](point a, point b){ return a.x < b.x; }), + minmaxY = std::minmax_element(pins.begin(), pins.end(), [](point a, point b){ return a.y < b.y; }); + return (minmaxX.second->x - minmaxX.first->x) + (minmaxY.second->y - minmaxY.first->y); } else{ return 0; @@ -467,7 +467,7 @@ std::int64_t RSMT_length(std::vector > const & pins, index_t exacti } else{ std::vector > points = pins; - std::sort(points.begin(), points.end(), [](point a , point b){return a.x_ < b.x_; }); + std::sort(points.begin(), points.end(), [](point a , point b){return a.x < b.x; }); if(points.size() <= exactitude_limit){ switch(points.size()){ @@ -517,9 +517,9 @@ point > > get_RSMT_topology(std::vector< ipoints[i] = indexed_pt(pins[i], i); } auto xpoints=ipoints; - std::sort(xpoints.begin(), xpoints.end(), [](indexed_pt a , indexed_pt b){return a.x_ < b.x_; }); + std::sort(xpoints.begin(), xpoints.end(), [](indexed_pt a , indexed_pt b){return a.x < b.x; }); auto ypoints=ipoints; - std::sort(ypoints.begin(), ypoints.end(), [](indexed_pt a , indexed_pt b){return a.y_ < b.y_; }); + std::sort(ypoints.begin(), ypoints.end(), [](indexed_pt a , indexed_pt b){return a.y < b.y; }); return point >{{{xpoints[0].index, xpoints[1].index}, {xpoints[1].index, xpoints[2].index}}, {{ypoints[0].index, ypoints[1].index}, {ypoints[1].index, ypoints[2].index}}}; } diff --git a/etesian/src/EtesianEngine.cpp b/etesian/src/EtesianEngine.cpp index 39610890..909ac6ad 100644 --- a/etesian/src/EtesianEngine.cpp +++ b/etesian/src/EtesianEngine.cpp @@ -148,19 +148,19 @@ namespace { , DbU::Unit pitch ) { - DbU::Unit tx = position.x_ * pitch; - DbU::Unit ty = position.y_ * pitch; + DbU::Unit tx = position.x * pitch; + DbU::Unit ty = position.y * pitch; Box cellBox = model->getAbutmentBox(); Transformation::Orientation orient = Transformation::Orientation::ID; - if ( not orientation.x_ and orientation.y_) { + if ( not orientation.x and orientation.y) { tx += cellBox.getWidth(); orient = Transformation::Orientation::MX; - } else if ( orientation.x_ and not orientation.y_) { + } else if ( orientation.x and not orientation.y) { ty += cellBox.getHeight(); orient = Transformation::Orientation::MY; - } else if ( not orientation.x_ and not orientation.y_) { + } else if ( not orientation.x and not orientation.y) { tx += cellBox.getWidth(); ty += cellBox.getHeight(); orient = Transformation::Orientation::R2; @@ -586,7 +586,7 @@ namespace Etesian { _placementLB.positions_ = positions; _placementLB.orientations_ = orientations; _placementUB = _placementLB; - //cerr << "Coloquinte cell height: " << _circuit.get_cell(0).size.y_ << endl; + //cerr << "Coloquinte cell height: " << _circuit.get_cell(0).size.y << endl; } @@ -616,11 +616,11 @@ namespace Etesian { auto legalizer = (options & ForceUniformDensity) != 0 ? region_distribution::uniform_density_distribution (_surface, _circuit, _placementLB, _densityLimits) : region_distribution::full_density_distribution (_surface, _circuit, _placementLB, _densityLimits); - while(legalizer.region_dimensions().x_ > 2*legalizer.region_dimensions().y_) + while(legalizer.region_dimensions().x > 2*legalizer.region_dimensions().y) legalizer.x_bipartition(); - while(2*legalizer.region_dimensions().x_ < legalizer.region_dimensions().y_) + while(2*legalizer.region_dimensions().x < legalizer.region_dimensions().y) legalizer.y_bipartition(); - while( std::max(legalizer.region_dimensions().x_, legalizer.region_dimensions().y_)*4 > minDisruption ) { + while( std::max(legalizer.region_dimensions().x, legalizer.region_dimensions().y)*4 > minDisruption ) { legalizer.x_bipartition(); legalizer.y_bipartition(); legalizer.redo_line_partitions();