-
Notifications
You must be signed in to change notification settings - Fork 849
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
cost: add keep_hierarchy pass with max_cost argument #4344
base: main
Are you sure you want to change the base?
Conversation
I'm really interested in your methodology here--can you explain it in detail? |
|
@whitequark Sure: I used |
kernel/cost.cc
Outdated
|
||
static unsigned int y_coef(RTLIL::IdString type) | ||
{ | ||
// clang-format off |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ew. This is convincing me more and more that we should not use clang-format...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible that it doesn't fit our repository. This really should have been a switch/case, but ID($...)
isn't a constant value. Then I wouldn't have to do this. Personally I'm very used to hitting Ctrl+Shift+I to format an entire file I'm working on in VS Code. For shared files I intend to get used to formatting modified lines only, which VS Code does allow me to set a shortcut to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use type.in(...)
which may work better.
kernel/cost.h
Outdated
{ ID($_DFF_P_), 1 }, | ||
{ ID($_DFF_N_), 1 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably add all of the DFF and latch types here, but I don't know what a reasonable cost estimate for them would be (1 seems off).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can look at the sky130hd and asap7 areas for those and the other cells
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say that's out of scope. Want me to make an issue? I added these only because I noticed stat.cc was patching these on its side so I consolidated it into here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is using these costs? Is there any information about where they come from and what they are supposed to model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stat.cc
uses CMOS transistor estimates of these (16). Nothing uses default gate count estimates of these. I was using this logic: by being primitives to be techmapped to, they have a default gate count of 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by being primitives to be techmapped to, they have a default gate count of 1
I am not sure I follow. Wouldn't that make the cost 1 for all the primitives in the list?
kernel/cost.cc
Outdated
} else if (// shift | ||
type == ID($shift) || | ||
type == ID($shiftx)) { | ||
return 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this twice the cost of $shr
? I'm very unconvinced that the cost model is sound.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll inspect some techmapped examples of these gates on Monday
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm quite interested in the functionality of this PR but in order to be convinced that it's a good addition it will require the following:
- A definition of what the costs mean, as well as a clear statement of who they are suitable for and who they are not.
- A clear methodology for calculating the cost, which is not a part of some random script in someone else's repository, but a part of Yosys itself. This includes both:
- A description of the methodology in prose.
- An executable that calculates the costs according to it.
This is pretty intense for the current sole use case which is as a heuristic flattening only modules that aren't huge. For what it's worth, if these were all set to |
Sorry for the spam @zachjs, I accidentally committed changes in ast that I only used to play around |
@whitequark test_cell is now capable of checking whether the cost is a correct post techmap gate count upper bound. This means the coefficients aren't generated programmatically, but at least they are verified, at least for cells covered by test_cell functionality. Use case example:
Open questions:
|
That is much better! I'll take a closer look a bit later. |
I propose we supply a conservative upper bound based on the width of the |
This reverts commit 2cc848a.
68b1008
to
9e67d5c
Compare
Current status and intended usage. I think I'll have to leave it as is for now. I think it's good enough as a heuristic and should move on to more pressing topics
|
Modules being flattened improves QoR in practice. It also makes the yosys runtime take much longer.
This PR creates cost.cc with linear cost models for almost all internal cell types to estimate the size of a module after techmapping. To get most of these numbers, I used a modified version of the
test_cell
command, see emil/gather-cell-size.This PR also adds the
keep_hierarchy
pass which marks all selected modules with that attribute and has an optional-max_cost
integer argument which sets a maximum estimated cost threshold.Effects on runtime and QoR with OpenROAD: TBD