From 6a6def8252eda60df48d4a3bdcf7d314a07fb6e8 Mon Sep 17 00:00:00 2001 From: Gabriel Gouvine Date: Mon, 20 Apr 2015 14:49:12 +0200 Subject: [PATCH] Cleanup to enable routing-driven placement --- bootstrap/build.conf | 4 +- .../src/coloquinte/rough_legalizers.hxx | 21 +++++-- coloquinte/src/piecewise_linear.cxx | 1 + etesian/src/CMakeLists.txt | 3 +- etesian/src/EtesianEngine.cpp | 57 ++++++++++--------- etesian/src/etesian/EtesianEngine.h | 3 +- 6 files changed, 52 insertions(+), 37 deletions(-) diff --git a/bootstrap/build.conf b/bootstrap/build.conf index 2b97f90c..8447c0e8 100644 --- a/bootstrap/build.conf +++ b/bootstrap/build.conf @@ -14,11 +14,11 @@ projects = [ #, "nimbus" #, "metis" #, "mauka" + , "knik" , "katabatic" + , "kite" , "coloquinte" , "etesian" - , "knik" - , "kite" , "equinox" , "solstice" , "unicorn" diff --git a/coloquinte/src/coloquinte/rough_legalizers.hxx b/coloquinte/src/coloquinte/rough_legalizers.hxx index ce524932..6f86ac6f 100644 --- a/coloquinte/src/coloquinte/rough_legalizers.hxx +++ b/coloquinte/src/coloquinte/rough_legalizers.hxx @@ -130,13 +130,16 @@ class region_distribution{ std::vector prepare_regions(index_t x_cnt, index_t y_cnt) const; public: + + inline box placement_area() const; + inline point region_dimensions() const; + + inline index_t x_regions_cnt() const; + inline index_t y_regions_cnt() const; + inline index_t regions_cnt() const; - inline index_t x_regions_cnt() const; - inline index_t y_regions_cnt() const; - inline index_t regions_cnt() const; - - inline index_t cell_cnt() const; - inline index_t fractional_cell_cnt() const; + inline index_t cell_cnt() const; + inline index_t fractional_cell_cnt() const; /* * Two types of export @@ -206,6 +209,12 @@ class region_distribution{ inline region_distribution::movable_cell::movable_cell(){} inline region_distribution::movable_cell::movable_cell(capacity_t demand, point p, index_t ind) : demand_(demand), pos_(p), index_in_placement_(ind){} +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()); +} + inline index_t region_distribution::x_regions_cnt() const { return x_regions_cnt_; } inline index_t region_distribution::y_regions_cnt() const { return y_regions_cnt_; } inline index_t region_distribution::regions_cnt() const { index_t ret = x_regions_cnt() * y_regions_cnt(); assert(placement_regions_.size() == ret); return ret; } diff --git a/coloquinte/src/piecewise_linear.cxx b/coloquinte/src/piecewise_linear.cxx index 83b05034..c422354e 100644 --- a/coloquinte/src/piecewise_linear.cxx +++ b/coloquinte/src/piecewise_linear.cxx @@ -201,6 +201,7 @@ int_t piecewise_linear_function::last_before(int_t pos) const{ ++it; } assert(false); // We should have found it if the bound was correct + return -1; } int_t piecewise_linear_function::value_at(int_t pos) const{ diff --git a/etesian/src/CMakeLists.txt b/etesian/src/CMakeLists.txt index 67f6df94..77162099 100644 --- a/etesian/src/CMakeLists.txt +++ b/etesian/src/CMakeLists.txt @@ -30,7 +30,8 @@ PyGraphicEtesianEngine.cpp ) qtX_wrap_cpp( mocCpps ${mocIncludes} ) - set( depLibs ${CORIOLIS_PYTHON_LIBRARIES} + set( depLibs ${KATABATIC_LIBRARIES} + ${CORIOLIS_PYTHON_LIBRARIES} ${CORIOLIS_LIBRARIES} ${HURRICANE_PYTHON_LIBRARIES} ${HURRICANE_GRAPHICAL_LIBRARIES} diff --git a/etesian/src/EtesianEngine.cpp b/etesian/src/EtesianEngine.cpp index 5a80dedf..5b97136d 100644 --- a/etesian/src/EtesianEngine.cpp +++ b/etesian/src/EtesianEngine.cpp @@ -603,6 +603,31 @@ namespace Etesian { _progressReport2(" [--]" ); } + void EtesianEngine::roughLegalize( float minDisruption, unsigned options ){ + using namespace coloquinte::gp; + // Create a legalizer and bipartition it until we have sufficient precision + 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_) + legalizer.x_bipartition(); + 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 ) { + legalizer.x_bipartition(); + legalizer.y_bipartition(); + legalizer.redo_line_partitions(); + legalizer.redo_diagonal_bipartitions(); + legalizer.redo_line_partitions(); + legalizer.redo_diagonal_bipartitions(); + legalizer.selfcheck(); + } + // Keep the orientation between LB and UB + _placementUB = _placementLB; + // Update UB + get_rough_legalization( _circuit, _placementUB, legalizer ); + } + void EtesianEngine::feedRoutingBack(){ using namespace Katabatic; /* @@ -656,25 +681,7 @@ namespace Etesian { index_t i=0; do{ - // Create a legalizer and bipartition it until we have sufficient precision - auto legalizer = (options & ForceUniformDensity) != 0 ? - region_distribution::uniform_density_distribution (_surface, _circuit, _placementLB, _densityLimits) - : region_distribution::full_density_distribution (_surface, _circuit, _placementLB, _densityLimits); - // Until there is about 10 standard cells per region - for ( int quad_part=0 ; _circuit.cell_cnt() > (index_t)(10 * (1 << (quad_part*2))) ; ++quad_part ) { - legalizer.x_bipartition(); - legalizer.y_bipartition(); - legalizer.redo_line_partitions(); - legalizer.redo_diagonal_bipartitions(); - legalizer.redo_line_partitions(); - legalizer.redo_diagonal_bipartitions(); - legalizer.selfcheck(); - } - // Keep the orientation between LB and UB - _placementUB = _placementLB; - // Update UB - get_rough_legalization( _circuit, _placementUB, legalizer ); - + roughLegalize(minDisruption, options); if(options & UpdateUB) _updatePlacement( _placementUB ); @@ -699,11 +706,6 @@ namespace Etesian { if(options & UpdateLB) _updatePlacement( _placementLB ); - // First way to exit the loop: the legalization is close enough to the previous result - linearDisruption = get_mean_linear_disruption(_circuit, _placementLB, _placementUB); - if(linearDisruption <= minDisruption) - break; - // Optimize orientation sometimes if (i%5 == 0) { optimize_exact_orientations( _circuit, _placementLB ); @@ -728,9 +730,11 @@ namespace Etesian { pullingForce += penaltyIncrease; prevOptRatio = optRatio; + linearDisruption = get_mean_linear_disruption(_circuit, _placementLB, _placementUB); ++i; - // Second way to exit the loop: UB and LB difference is <10% - }while(prevOptRatio <= 0.9); + // First way to exit the loop: UB and LB difference is <10% + // Second way to exit the loop: the legalization is close enough to the previous result + }while(linearDisruption > minDisruption and prevOptRatio <= 0.9); _updatePlacement( _placementUB ); } @@ -739,6 +743,7 @@ namespace Etesian { using namespace coloquinte::dp; int_t sliceHeight = getSliceHeight() / getPitch(); + roughLegalize(sliceHeight, options); for ( int i=0; i