Skip to content

Commit

Permalink
Merge pull request #6478 from jmolloy/nothreads
Browse files Browse the repository at this point in the history
[drt] Only spawn new threads when distributed_ is true
  • Loading branch information
maliberty authored Jan 10, 2025
2 parents aa3b8de + bc644e4 commit 02a9604
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/drt/include/triton_route/TritonRoute.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class TritonRoute
std::mutex results_mutex_;
int results_sz_{0};
unsigned int cloud_sz_{0};
boost::asio::thread_pool dist_pool_{1};
std::optional<boost::asio::thread_pool> dist_pool_;

void initDesign();
void gr();
Expand Down
16 changes: 11 additions & 5 deletions src/drt/src/TritonRoute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ TritonRoute::TritonRoute()
router_cfg_(std::make_unique<RouterConfiguration>()),
gui_(gui::Gui::get())
{
if (distributed_) {
dist_pool_.emplace(1);
}
}

TritonRoute::~TritonRoute() = default;
Expand Down Expand Up @@ -109,6 +112,9 @@ void TritonRoute::setDebugTA(bool on)
void TritonRoute::setDistributed(bool on)
{
distributed_ = on;
if (distributed_ && !dist_pool_.has_value()) {
dist_pool_.emplace(1);
}
}

void TritonRoute::setDebugWriteNetTracks(bool on)
Expand Down Expand Up @@ -957,7 +963,7 @@ int TritonRoute::main()
dist_->sendJob(msg, dist_ip_.c_str(), dist_port_, result);
});
} else {
asio::post(dist_pool_, boost::bind(&TritonRoute::sendDesignDist, this));
asio::post(*dist_pool_, boost::bind(&TritonRoute::sendDesignDist, this));
}
}
initDesign();
Expand Down Expand Up @@ -986,7 +992,7 @@ int TritonRoute::main()
writer.updateDb(db_, router_cfg_.get(), true);
}
if (distributed_) {
asio::post(dist_pool_, [this]() {
asio::post(*dist_pool_, [this]() {
dst::JobMessage msg(dst::JobMessage::GRDR_INIT,
dst::JobMessage::BROADCAST),
result;
Expand All @@ -1009,7 +1015,7 @@ int TritonRoute::main()
prep();
ta();
if (distributed_) {
asio::post(dist_pool_,
asio::post(*dist_pool_,
boost::bind(&TritonRoute::sendDesignUpdates, this, ""));
}
dr();
Expand All @@ -1022,7 +1028,7 @@ int TritonRoute::main()
void TritonRoute::pinAccess(const std::vector<odb::dbInst*>& target_insts)
{
if (distributed_) {
asio::post(dist_pool_, [this]() {
asio::post(*dist_pool_, [this]() {
sendDesignDist();
dst::JobMessage msg(dst::JobMessage::PIN_ACCESS,
dst::JobMessage::BROADCAST),
Expand All @@ -1042,7 +1048,7 @@ void TritonRoute::pinAccess(const std::vector<odb::dbInst*>& target_insts)
pa.setDebug(debug_.get(), db_);
if (distributed_) {
pa.setDistributed(dist_ip_, dist_port_, shared_volume_, cloud_sz_);
dist_pool_.join();
dist_pool_->join();
}
pa.main();
io::Writer writer(getDesign(), logger_);
Expand Down
4 changes: 3 additions & 1 deletion src/drt/src/dr/FlexDR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,9 @@ void FlexDR::processWorkersBatchDistributed(
int& version,
IterationProgress& iter_prog)
{
router_->dist_pool_.join();
if (router_->dist_pool_.has_value()) {
router_->dist_pool_->join();
}
if (version++ == 0 && !design_->hasUpdates()) {
std::string serializedViaData;
serializeViaData(via_data_, serializedViaData);
Expand Down

0 comments on commit 02a9604

Please sign in to comment.