Skip to content

Commit

Permalink
Merge branch 'master' into cts_enhance_clkgater_handling
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurjolo committed Nov 19, 2024
2 parents d34440b + 75f2922 commit 928902c
Show file tree
Hide file tree
Showing 28 changed files with 733 additions and 217 deletions.
6 changes: 5 additions & 1 deletion include/ord/InitOpenRoad.hh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@

#include <tcl.h>

#include <string>

namespace ord {

// Call this inside of Tcl_Main.
void initOpenRoad(Tcl_Interp* interp);
void initOpenRoad(Tcl_Interp* interp,
const char* log_filename,
const char* metrics_filename);
} // namespace ord
4 changes: 3 additions & 1 deletion include/ord/OpenRoad.hh
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ class OpenRoad
// OpenRoad object and/or any other tools they need to reference.
static OpenRoad* openRoad();
static void setOpenRoad(OpenRoad* app, bool reinit_ok = false);
void init(Tcl_Interp* tcl_interp);
void init(Tcl_Interp* tcl_interp,
const char* log_filename,
const char* metrics_filename);

Tcl_Interp* tclInterp() { return tcl_interp_; }
utl::Logger* getLogger() { return logger_; }
Expand Down
4 changes: 3 additions & 1 deletion include/ord/Tech.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ class Tech
public:
// interp is only passed by standalone OR as it gets its
// interpreter from Tcl_Main.
Tech(Tcl_Interp* interp = nullptr);
Tech(Tcl_Interp* interp = nullptr,
const char* log_filename = nullptr,
const char* metrics_filename = nullptr);
~Tech();

void readLef(const std::string& file_name);
Expand Down
12 changes: 6 additions & 6 deletions src/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ FOREACH_TOOL(X)

int cmd_argc;
char** cmd_argv;
const char* log_filename = nullptr;
const char* metrics_filename = nullptr;
bool no_settings = false;
bool minimize = false;
static const char* log_filename = nullptr;
static const char* metrics_filename = nullptr;
static bool no_settings = false;
static bool minimize = false;

static const char* init_filename = ".openroad";

Expand Down Expand Up @@ -281,7 +281,7 @@ int main(int argc, char* argv[])
the_tech = std::make_unique<ord::Tech>(interp);
the_design = std::make_unique<ord::Design>(the_tech.get());
ord::OpenRoad::setOpenRoad(the_design->getOpenRoad());
ord::initOpenRoad(interp);
ord::initOpenRoad(interp, log_filename, metrics_filename);
if (!findCmdLineFlag(cmd_argc, cmd_argv, "-no_splash")) {
showSplash();
}
Expand Down Expand Up @@ -448,7 +448,7 @@ static int tclAppInit(int& argc,
}
#endif

ord::initOpenRoad(interp);
ord::initOpenRoad(interp, log_filename, metrics_filename);

bool no_splash = findCmdLineFlag(argc, argv, "-no_splash");
if (!no_splash) {
Expand Down
14 changes: 7 additions & 7 deletions src/OpenRoad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ extern int Odbtcl_Init(Tcl_Interp* interp);
extern int Upf_Init(Tcl_Interp* interp);
}

// Main.cc set by main()
extern const char* log_filename;
extern const char* metrics_filename;

namespace ord {

using odb::dbBlock;
Expand Down Expand Up @@ -176,12 +172,16 @@ void OpenRoad::setOpenRoad(OpenRoad* app, bool reinit_ok)

////////////////////////////////////////////////////////////////

void initOpenRoad(Tcl_Interp* interp)
void initOpenRoad(Tcl_Interp* interp,
const char* log_filename,
const char* metrics_filename)
{
OpenRoad::openRoad()->init(interp);
OpenRoad::openRoad()->init(interp, log_filename, metrics_filename);
}

void OpenRoad::init(Tcl_Interp* tcl_interp)
void OpenRoad::init(Tcl_Interp* tcl_interp,
const char* log_filename,
const char* metrics_filename)
{
tcl_interp_ = tcl_interp;

Expand Down
7 changes: 5 additions & 2 deletions src/Tech.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@

namespace ord {

Tech::Tech(Tcl_Interp* interp) : app_(new OpenRoad())
Tech::Tech(Tcl_Interp* interp,
const char* log_filename,
const char* metrics_filename)
: app_(new OpenRoad())
{
if (!interp) {
interp = Tcl_CreateInterp();
Tcl_Init(interp);
app_->init(interp);
app_->init(interp, log_filename, metrics_filename);
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/cts/src/HTreeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1954,8 +1954,7 @@ void HTreeBuilder::createSingleBufferClockNet()

void HTreeBuilder::plotSolution()
{
static int cnt = 0;
auto name = std::string("plot") + std::to_string(cnt++) + ".py";
auto name = std::string("plot_") + clock_.getName() + ".py";
std::ofstream file(name);
file << "import numpy as np\n";
file << "import matplotlib.pyplot as plt\n";
Expand Down
14 changes: 7 additions & 7 deletions src/dbSta/src/PathRenderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

namespace sta {

gui::Painter::Color PathRenderer::signal_color = gui::Painter::red;
gui::Painter::Color PathRenderer::clock_color = gui::Painter::yellow;
const gui::Painter::Color PathRenderer::signal_color = gui::Painter::red;
const gui::Painter::Color PathRenderer::clock_color = gui::Painter::yellow;

PathRenderer::PathRenderer(dbSta* sta) : sta_(sta)
{
Expand Down Expand Up @@ -41,9 +41,9 @@ void PathRenderer::drawObjects(gui::Painter& painter)
const PathRef* prev_path = path_->path(i - 1);
const Pin* pin = path->pin(sta_);
const Pin* prev_pin = prev_path->pin(sta_);
odb::Point pt1 = network->location(pin);
odb::Point pt2 = network->location(prev_pin);
gui::Painter::Color wire_color
const odb::Point pt1 = network->location(pin);
const odb::Point pt2 = network->location(prev_pin);
const gui::Painter::Color wire_color
= sta_->isClock(pin) ? clock_color : signal_color;
painter.setPen(wire_color, true);
painter.drawLine(pt1, pt2);
Expand All @@ -66,8 +66,8 @@ void PathRenderer::highlightInst(const Pin* pin, gui::Painter& painter)
network->staToDb(inst, db_inst, mod_inst);
if (db_inst != nullptr) {
odb::dbBox* bbox = db_inst->getBBox();
odb::Rect rect = bbox->getBox();
gui::Painter::Color inst_color
const odb::Rect rect = bbox->getBox();
const gui::Painter::Color inst_color
= sta_->isClock(pin) ? clock_color : signal_color;
painter.setBrush(inst_color);
painter.drawRect(rect);
Expand Down
4 changes: 2 additions & 2 deletions src/dbSta/src/PathRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class PathRenderer : public gui::Renderer, public AbstractPathRenderer
dbSta* sta_;
// Expanded path is owned by PathRenderer.
std::unique_ptr<PathExpanded> path_;
static gui::Painter::Color signal_color;
static gui::Painter::Color clock_color;
static const gui::Painter::Color signal_color;
static const gui::Painter::Color clock_color;
};

} // namespace sta
66 changes: 48 additions & 18 deletions src/drt/src/gc/FlexGC_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,31 @@ void FlexGCWorker::Impl::initNet_pins_polygonEdges(gcNet* net)
}
}
}

namespace {
bool isPolygonCorner(const frCoord x,
const frCoord y,
const gtl::polygon_90_set_data<frCoord>& poly_set)
{
std::vector<gtl::polygon_90_with_holes_data<frCoord>> polygons;
poly_set.get(polygons);
for (const auto& polygon : polygons) {
for (const auto& pt : polygon) {
if (pt.x() == x && pt.y() == y) {
return true;
}
}
for (auto hole_itr = polygon.begin_holes(); hole_itr != polygon.end_holes();
++hole_itr) {
for (const auto& pt : (*hole_itr)) {
if (pt.x() == x && pt.y() == y) {
return true;
}
}
}
}
return false;
}
} // namespace
void FlexGCWorker::Impl::initNet_pins_polygonCorners_helper(gcNet* net,
gcPin* pin)
{
Expand Down Expand Up @@ -769,26 +793,32 @@ void FlexGCWorker::Impl::initNet_pins_polygonCorners_helper(gcNet* net,
&& nextEdge->getDir() == frDirEnum::E)) {
currCorner->setDir(frCornerDirEnum::SE);
}

// set fixed / route status
if (currCorner->getType() == frCornerTypeEnum::CONVEX) {
currCorner->setFixed(false);
for (auto& rect : net->getRectangles(true)[layerNum]) {
if (isCornerOverlap(currCorner, rect)) {
currCorner->setFixed(true);
break;
if (getTech()->getLayer(layerNum)->getType()
== odb::dbTechLayerType::CUT) {
if (currCorner->getType() == frCornerTypeEnum::CONVEX) {
currCorner->setFixed(false);
for (auto& rect : net->getRectangles(true)[layerNum]) {
if (isCornerOverlap(currCorner, rect)) {
currCorner->setFixed(true);
break;
}
}
}
} else if (currCorner->getType() == frCornerTypeEnum::CONCAVE) {
currCorner->setFixed(true);
auto cornerPt = currCorner->getNextEdge()->low();
for (auto& rect : net->getRectangles(false)[layerNum]) {
if (gtl::contains(rect, cornerPt, true)
&& !gtl::contains(rect, cornerPt, false)) {
currCorner->setFixed(false);
break;
} else if (currCorner->getType() == frCornerTypeEnum::CONCAVE) {
currCorner->setFixed(true);
auto cornerPt = currCorner->getNextEdge()->low();
for (auto& rect : net->getRectangles(false)[layerNum]) {
if (gtl::contains(rect, cornerPt, true)
&& !gtl::contains(rect, cornerPt, false)) {
currCorner->setFixed(false);
break;
}
}
}

} else {
currCorner->setFixed(isPolygonCorner(currCorner->x(),
currCorner->y(),
net->getPolygons(true)[layerNum]));
}
// currCorner->setFixed(prevEdge->isFixed() && nextEdge->isFixed());

Expand Down
3 changes: 0 additions & 3 deletions src/drt/src/gc/FlexGC_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3006,9 +3006,6 @@ void FlexGCWorker::Impl::checkLef58CutSpacing_spc_layer(
const gtl::rectangle_data<frCoord>& markerRect,
frLef58CutSpacingConstraint* con)
{
if (rect1->isFixed() && rect2->isFixed()) {
return;
}
auto layerNum = rect1->getLayerNum();
auto secondLayerNum = rect2->getLayerNum();
auto net1 = rect1->getNet();
Expand Down
1 change: 1 addition & 0 deletions src/drt/src/io/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,7 @@ void io::Parser::setRoutingLayerProperties(odb::dbTechLayer* layer,
tmpLayer->setLef58RightWayOnGridOnlyConstraint(
rightWayOnGridOnlyConstraint.get());
getTech()->addUConstraint(std::move(rightWayOnGridOnlyConstraint));
ALLOW_PIN_AS_FEEDTHROUGH = false;
}
for (auto rule : layer->getTechLayerMinStepRules()) {
if (rule->getMaxEdges() > 1) {
Expand Down
Binary file modified src/gui/resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 2 additions & 22 deletions src/mpl2/src/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void Graphics::startSA()
return;
}

if (only_final_result_ || skip_steps_) {
if (skip_steps_) {
return;
}

Expand All @@ -90,7 +90,7 @@ void Graphics::endSA(const float norm_cost)
return;
}

if (only_final_result_ || skip_steps_) {
if (skip_steps_) {
return;
}

Expand All @@ -113,21 +113,13 @@ bool Graphics::isTargetCluster()

void Graphics::saStep(const std::vector<SoftMacro>& macros)
{
if (only_final_result_) {
return;
}

resetPenalties();
soft_macros_ = macros;
hard_macros_.clear();
}

void Graphics::saStep(const std::vector<HardMacro>& macros)
{
if (only_final_result_) {
return;
}

resetPenalties();
hard_macros_ = macros;
soft_macros_.clear();
Expand Down Expand Up @@ -162,10 +154,6 @@ void Graphics::report(const float norm_cost)

void Graphics::drawResult()
{
if (!only_final_result_) {
return;
}

if (max_level_) {
std::vector<std::vector<odb::Rect>> outlines(max_level_.value() + 1);
int level = 0;
Expand Down Expand Up @@ -221,10 +209,6 @@ void Graphics::penaltyCalculated(float norm_cost)
return;
}

if (only_final_result_) {
return;
}

if (is_skipping_) {
return;
}
Expand Down Expand Up @@ -591,10 +575,6 @@ void Graphics::setTargetClusterId(const int target_cluster_id)

void Graphics::setOutline(const odb::Rect& outline)
{
if (only_final_result_) {
return;
}

outline_ = outline;
}

Expand Down
17 changes: 12 additions & 5 deletions src/mpl2/src/hier_rtlmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,20 @@ void HierRTLMP::run()
resetSAParameters();
}

std::unique_ptr<Mpl2Observer> save_graphics;
if (is_debug_only_final_result_) {
save_graphics = std::move(graphics_);
}

runCoarseShaping();
runHierarchicalMacroPlacement();

if (save_graphics) {
graphics_ = std::move(save_graphics);
graphics_->setMaxLevel(tree_->max_level);
graphics_->drawResult();
}

Pusher pusher(logger_, tree_->root.get(), block_, boundary_to_io_blockage_);
pusher.pushMacrosToCoreBoundaries();

Expand Down Expand Up @@ -314,11 +325,6 @@ void HierRTLMP::runHierarchicalMacroPlacement()
} else {
runHierarchicalMacroPlacementWithoutBusPlanning(tree_->root.get());
}

if (graphics_) {
graphics_->setMaxLevel(tree_->max_level);
graphics_->drawResult();
}
}

void HierRTLMP::resetSAParameters()
Expand Down Expand Up @@ -4122,6 +4128,7 @@ void HierRTLMP::setDebugSkipSteps(bool skip_steps)
void HierRTLMP::setDebugOnlyFinalResult(bool only_final_result)
{
graphics_->setOnlyFinalResult(only_final_result);
is_debug_only_final_result_ = only_final_result;
}

void HierRTLMP::setDebugTargetClusterId(const int target_cluster_id)
Expand Down
1 change: 1 addition & 0 deletions src/mpl2/src/hier_rtlmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ class HierRTLMP
bool skip_macro_placement_ = false;

std::unique_ptr<Mpl2Observer> graphics_;
bool is_debug_only_final_result_{false};
};

class Pusher
Expand Down
Loading

0 comments on commit 928902c

Please sign in to comment.