Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drt: decoupling of the OR singleton from DRT core code #6658

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
6 changes: 3 additions & 3 deletions src/drt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,11 @@ target_include_directories(drt_lib

target_link_libraries(drt_lib
PUBLIC
odb
stt
stt_lib
OpenSTA
utl_lib
dst
dbSta
dbSta_lib
Threads::Threads
OpenMP::OpenMP_CXX
${Boost_LIBRARIES}
Expand All @@ -162,6 +161,7 @@ target_sources(drt
src/pa/FlexPA_graphics.cpp
src/MakeTritonRoute.cpp
src/GraphicsFactory.cpp
src/ORDBInterface.cpp
)

target_include_directories(drt
Expand Down
13 changes: 5 additions & 8 deletions src/drt/include/triton_route/TritonRoute.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

#pragma once

#include <tcl.h>

#include <boost/asio/thread_pool.hpp>
#include <list>
#include <memory>
Expand All @@ -52,10 +50,6 @@ namespace utl {
class Logger;
}

namespace gui {
class Gui;
}

namespace stt {
class SteinerTreeBuilder;
}
Expand All @@ -78,6 +72,7 @@ struct FlexDRViaData;
class frMarker;
struct RouterConfiguration;
class AbstractGraphicsFactory;
class AbstractORDBInterface;

struct ParamStruct
{
Expand Down Expand Up @@ -113,7 +108,9 @@ class TritonRoute
utl::Logger* logger,
dst::Distributed* dist,
stt::SteinerTreeBuilder* stt_builder,
std::unique_ptr<AbstractGraphicsFactory> graphics_factory);
std::unique_ptr<AbstractGraphicsFactory> graphics_factory,
std::unique_ptr<AbstractORDBInterface> or_db_interface,
int num_threads);

frDesign* getDesign() const { return design_.get(); }
utl::Logger* getLogger() const { return logger_; }
Expand Down Expand Up @@ -213,7 +210,6 @@ class TritonRoute
std::unique_ptr<FlexDR> dr_; // kept for single stepping
stt::SteinerTreeBuilder* stt_builder_{nullptr};
int num_drvs_{-1};
gui::Gui* gui_{nullptr};
dst::Distributed* dist_{nullptr};
bool distributed_{false};
std::string dist_ip_;
Expand All @@ -226,6 +222,7 @@ class TritonRoute
std::optional<boost::asio::thread_pool> dist_pool_;
std::unique_ptr<FlexPA> pa_{nullptr};
std::unique_ptr<AbstractGraphicsFactory> graphics_factory_{nullptr};
std::unique_ptr<AbstractORDBInterface> or_db_interface_{nullptr};

void initDesign();
void initGraphics();
Expand Down
45 changes: 45 additions & 0 deletions src/drt/src/AbstractORDBInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (c) 2025, Precision Innovations Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

#pragma once

namespace drt {

class AbstractORDBInterface
{
public:
virtual ~AbstractORDBInterface() = default;
virtual void readDb(const char* file_name) = 0;
virtual void writeDb(const char* file_name) = 0;
};

} // namespace drt
8 changes: 2 additions & 6 deletions src/drt/src/GraphicsFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@

namespace drt {

GraphicsFactory::GraphicsFactory()
{
}
GraphicsFactory::~GraphicsFactory()
{
}
GraphicsFactory::GraphicsFactory() = default;
GraphicsFactory::~GraphicsFactory() = default;

void GraphicsFactory::reset(frDebugSettings* settings,
frDesign* design,
Expand Down
9 changes: 8 additions & 1 deletion src/drt/src/MakeTritonRoute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "triton_route/MakeTritonRoute.h"

#include "GraphicsFactory.h"
#include "ORDBInterface.h"
#include "dr/FlexDR_graphics.h"
#include "ord/OpenRoad.hh"
#include "pa/FlexPA_graphics.h"
Expand Down Expand Up @@ -70,14 +71,20 @@ void initTritonRoute(OpenRoad* openroad)
sta::evalTclInit(tcl_interp, sta::drt_tcl_inits);

drt::TritonRoute* router = openroad->getTritonRoute();

std::unique_ptr<drt::AbstractGraphicsFactory> graphics_factory
= std::make_unique<drt::GraphicsFactory>();

std::unique_ptr<drt::ORDBInterface> or_db_interface
= std::make_unique<drt::ORDBInterface>();

router->init(openroad->getDb(),
openroad->getLogger(),
openroad->getDistributed(),
openroad->getSteinerTreeBuilder(),
std::move(graphics_factory));
std::move(graphics_factory),
std::move(or_db_interface),
ord::OpenRoad::openRoad()->getThreadCount());
}

} // namespace ord
49 changes: 49 additions & 0 deletions src/drt/src/ORDBInterface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (c) 2025, Precision Innovations Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

#include "ORDBInterface.h"

#include "ord/OpenRoad.hh"

namespace drt {

void ORDBInterface::readDb(const char* file_name)
{
ord::OpenRoad::openRoad()->readDb(file_name);
}

void ORDBInterface::writeDb(const char* file_name)
{
ord::OpenRoad::openRoad()->writeDb(file_name);
}

} // namespace drt
48 changes: 48 additions & 0 deletions src/drt/src/ORDBInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (c) 2025, Precision Innovations Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

#pragma once

#include "AbstractORDBInterface.h"

namespace drt {

class ORDBInterface : public AbstractORDBInterface
{
public:
ORDBInterface() = default;
~ORDBInterface() = default;
void readDb(const char* file_name) override;
void writeDb(const char* file_name) override;
};

} // namespace drt
Loading