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: Bidirectional A* #6486

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kbieganski
Copy link
Contributor

Implements bidirectional A* for DRT.

Unfortunately, usually this doesn't improve run time. I think the main problem performance-wise is the cost map which wasn't there in the original A*. But the approach seems promising:

Design Branch RSS [GB] Time [s] Wirelength
asap7/aes Baseline 4.3527 497.538 76299
asap7/aes Bidirectional A* 3.53801 528.685 76085
asap7/ibex Baseline 5.46439 685.251 116574
asap7/ibex Bidirectional A* 4.39161 716.15 116305
nangate45/aes Baseline 1.52102 427.31 311438
nangate45/aes Bidirectional A* 1.71426 449.323 311349
nangate45/black_parrot Baseline 9.07848 2843.38
nangate45/black_parrot Bidirectional A* 9.76452 2815.57
nangate45/ibex Baseline 1.54163 264.78 331945
nangate45/ibex Bidirectional A* 1.57943 262.21 332115

What's interesting is that it often produces slightly shorter wirelength.

I probably won't be working on this for now, but putting it out there so that perhaps other people could expand on it, or share some ideas.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

@@ -30,6 +30,7 @@

#include <boost/container/flat_map.hpp>
#include <boost/container/flat_set.hpp>
#include <boost/unordered/unordered_flat_map.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'boost/unordered/unordered_flat_map.hpp' file not found [clang-diagnostic-error]

#include <boost/unordered/unordered_flat_map.hpp>
         ^

@@ -49,7 +49,8 @@ class FlexWavefrontGrid
frCoord distIn,
frCost pathCostIn,
frCost costIn,
const std::bitset<WAVEFRONTBITSIZE>& backTraceBufferIn = {})
const std::bitset<WAVEFRONTBITSIZE>& backTraceBufferIn = {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of undeclared identifier 'WAVEFRONTBITSIZE' [clang-diagnostic-error]

                    const std::bitset<WAVEFRONTBITSIZE>& backTraceBufferIn = {},
                                      ^

@@ -49,7 +49,8 @@
frCoord distIn,
frCost pathCostIn,
frCost costIn,
const std::bitset<WAVEFRONTBITSIZE>& backTraceBufferIn = {})
const std::bitset<WAVEFRONTBITSIZE>& backTraceBufferIn = {},
const std::array<frCost, WAVEFRONTBUFFERSIZE>& backTraceCostsIn = {})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of undeclared identifier 'WAVEFRONTBUFFERSIZE' [clang-diagnostic-error]

                    const std::array<frCost, WAVEFRONTBUFFERSIZE>& backTraceCostsIn = {})
                                             ^

@@ -87,6 +89,10 @@
{
return backTraceBuffer_;
}
const std::array<frCost, WAVEFRONTBUFFERSIZE>& getBackTraceCosts() const
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of undeclared identifier 'WAVEFRONTBUFFERSIZE' [clang-diagnostic-error]

  const std::array<frCost, WAVEFRONTBUFFERSIZE>& getBackTraceCosts() const
                           ^

@@ -115,14 +121,19 @@
std::bitset<WAVEFRONTBITSIZE> mask = WAVEFRONTBUFFERHIGHMASK;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of undeclared identifier 'WAVEFRONTBITSIZE' [clang-diagnostic-error]

    std::bitset<WAVEFRONTBITSIZE> mask = WAVEFRONTBUFFERHIGHMASK;
                ^

}
frCost prevCost = backTraceCosts_[0];
backTraceCosts_[0] = cost;
return {retBS, prevCost};
}
void setSrcTaperBox(const frBox3D* b) { srcTaperBox = b; }
const frBox3D* getSrcTaperBox() const { return srcTaperBox; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: unknown type name 'frBox3D' [clang-diagnostic-error]

  const frBox3D* getSrcTaperBox() const { return srcTaperBox; }
        ^

@@ -139,6 +150,7 @@
bool prevViaUp_;
frCoord tLength_; // length since last turn
std::bitset<WAVEFRONTBITSIZE> backTraceBuffer_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of undeclared identifier 'WAVEFRONTBITSIZE' [clang-diagnostic-error]

  std::bitset<WAVEFRONTBITSIZE> backTraceBuffer_;
              ^

@@ -139,6 +150,7 @@
bool prevViaUp_;
frCoord tLength_; // length since last turn
std::bitset<WAVEFRONTBITSIZE> backTraceBuffer_;
std::array<frCost, WAVEFRONTBUFFERSIZE> backTraceCosts_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of undeclared identifier 'WAVEFRONTBUFFERSIZE' [clang-diagnostic-error]

  std::array<frCost, WAVEFRONTBUFFERSIZE> backTraceCosts_;
                     ^

@@ -139,6 +150,7 @@
bool prevViaUp_;
frCoord tLength_; // length since last turn
std::bitset<WAVEFRONTBITSIZE> backTraceBuffer_;
std::array<frCost, WAVEFRONTBUFFERSIZE> backTraceCosts_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: private field 'backTraceCosts_' is not used [clang-diagnostic-unused-private-field]

  std::array<frCost, WAVEFRONTBUFFERSIZE> backTraceCosts_;
                                          ^

@@ -139,6 +150,7 @@
bool prevViaUp_;
frCoord tLength_; // length since last turn
std::bitset<WAVEFRONTBITSIZE> backTraceBuffer_;
std::array<frCost, WAVEFRONTBUFFERSIZE> backTraceCosts_;
const frBox3D* srcTaperBox = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: unknown type name 'frBox3D' [clang-diagnostic-error]

  const frBox3D* srcTaperBox = nullptr;
        ^

@kbieganski kbieganski force-pushed the drt-bidir-astar branch 2 times, most recently from 16f0600 to 8f74934 Compare January 7, 2025 21:02
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

frCoord distIn,
frCost pathCostIn,
frCost costIn,
const std::bitset<WAVEFRONTBITSIZE>& backTraceBufferIn = {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of undeclared identifier 'WAVEFRONTBITSIZE' [clang-diagnostic-error]

      const std::bitset<WAVEFRONTBITSIZE>& backTraceBufferIn = {},
                        ^

frCost pathCostIn,
frCost costIn,
const std::bitset<WAVEFRONTBITSIZE>& backTraceBufferIn = {},
const std::array<frCost, WAVEFRONTBUFFERSIZE>& backTraceCostsIn = {})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of undeclared identifier 'WAVEFRONTBUFFERSIZE' [clang-diagnostic-error]

      const std::array<frCost, WAVEFRONTBUFFERSIZE>& backTraceCostsIn = {})
                               ^

@rovinski
Copy link
Collaborator

rovinski commented Jan 8, 2025

I believe bidirectional A* was tried several years ago and dropped also because there was no performance benefit. Same for a line search approach that was tried.

@bangqixu
Copy link

bangqixu commented Jan 9, 2025

Great work! Just some drive-by comments. One of the major challenges of applying bidirectional A* search is that when the two waves meet, they don't necessarily meet in a DRC-free way. One simple example is that, they could meet where they haven't travelled long enough on the layer thus causing minimum area violation (this is just the simplest example I can think of and there can be many other such design rules). With unidirectional A* search, there are heuristics to help avoid such violations. With bidirectional A*, we probably need some new heuristics (sorry if you already have it in the code because I have not read in details).

That being said, the runtime comparison here may not reflect the performance of uni/bidirectional A* searches themselves because bidirectional A* may be dealing with more DRCs for the reason above. Without a search algorithm benchmarking utility, the closest thing I can think of is to run one iteration of detail route and only allow each net to be routed once. If the DRC numbers do not differ too much, then the comparison probably can better reflect the raw performance between uni/bidirectional.

kbieganski and others added 3 commits January 10, 2025 17:05
Co-authored-by: Maciej Torhan <[email protected]>
Signed-off-by: Krzysztof Bieganski <[email protected]>
Signed-off-by: Maciej Torhan <[email protected]>
Signed-off-by: Krzysztof Bieganski <[email protected]>
Signed-off-by: Krzysztof Bieganski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants