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

grt/rsz: write spef for estimated parasitics #5656

Merged
merged 18 commits into from
Sep 11, 2024

Conversation

joaomai
Copy link
Contributor

@joaomai joaomai commented Aug 26, 2024

Fixes #4441.

Added as an option to the estimate_parasitics command, using -spef_file to pass the file path as an argument, writing one or more files based on how many corners there are.
The information is written to the file during estimation, writing the net data before RC reduction is performed.

I'm unsure about the units in the header, using the same ones from the rcx header currently.

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

src/rsz/src/EstimateWireParasitics.cc Outdated Show resolved Hide resolved
src/rsz/src/EstimateWireParasitics.cc Outdated Show resolved Hide resolved
src/rsz/src/EstimateWireParasitics.cc Outdated Show resolved Hide resolved
src/rsz/src/EstimateWireParasitics.cc Outdated Show resolved Hide resolved
src/rsz/src/EstimateWireParasitics.cc Outdated Show resolved Hide resolved
src/rsz/src/EstimateWireParasitics.cc Outdated Show resolved Hide resolved
src/rsz/src/EstimateWireParasitics.cc Outdated Show resolved Hide resolved
src/rsz/src/EstimateWireParasitics.cc Outdated Show resolved Hide resolved
src/rsz/src/EstimateWireParasitics.cc Outdated Show resolved Hide resolved
src/rsz/src/EstimateWireParasitics.cc Outdated Show resolved Hide resolved
Signed-off-by: João Mai <[email protected]>
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

src/rsz/src/Resizer.tcl Outdated Show resolved Hide resolved
Comment on lines 237 to 238
void estimateParasitics(ParasiticsSrc src, const char* file_path = "");
void estimateWireParasitics(const char* path = "");
Copy link
Member

Choose a reason for hiding this comment

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

std::string_view is more flexible than char*

Copy link
Member

Choose a reason for hiding this comment

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

There is a request to take

 std::map<Corner*, std::ostream*>& spef_files

instead of a file_path so that the client can control the output (to a ofstream or a ststream). The .i could handle setting these up for file based output.

Copy link
Member

Choose a reason for hiding this comment

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

Note that corners could be a subset of all available corners

Copy link
Member

Choose a reason for hiding this comment

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

You could keep the write to file version an an overload that uses the other API as its implementation.

src/rsz/include/rsz/Resizer.hh Outdated Show resolved Hide resolved
src/rsz/include/rsz/Resizer.hh Outdated Show resolved Hide resolved
src/rsz/include/rsz/Resizer.hh Outdated Show resolved Hide resolved
file_path.append(suffix);
}

spef_file[corner].open(file_path, std::ofstream::out);
Copy link
Member

Choose a reason for hiding this comment

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

You should check that open succeeded

src/rsz/src/EstimateWireParasitics.cc Outdated Show resolved Hide resolved

void Resizer::writeSpefPorts(Corner* corner, dbNetwork* network)
{
auto pin_iter = network->pinIterator(network->topInstance());
Copy link
Member

Choose a reason for hiding this comment

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

sta is old fashioned and this pointer must be freed by the caller. The easiest is to store the result value in a unique_ptr.

Comment on lines 814 to 817
network->staToDb(pin, iterm, bterm, moditerm, modbterm);

spef_file[corner] << bterm->getName() << " ";
if (bterm->getIoType() == odb::dbIoType::INPUT) {
Copy link
Member

Choose a reason for hiding this comment

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

What if this isn't a bterm? An iterm is possible and a mod* should be an error.

@rovinski
Copy link
Collaborator

Not sure I'm fond of -spef as a flag to estimate_parasitics. Couldn't this instead use the existing API by doing write_spef after estimate_parasitics? You could print a message during write_spef indicating what kind of parasitics it's writing (global vs. detailed).

@maliberty
Copy link
Member

sta reduces the parasitics so you can't write them afterwards except in reduced form which isn't that helpful.

@rovinski
Copy link
Collaborator

But could you, e.g., just add a Tcl hook or a SWIG hook which determines which function to call? Or are you saying that to write the SPEF without reduced parasitics then it has to be written out immediately?

@maliberty
Copy link
Member

Yes they have to be written immediately as the unreduced form is not stored anywhere. Storing it would be quite expensive on the off change someone wants to write them out.

@rovinski
Copy link
Collaborator

That's fair then.

@maliberty
Copy link
Member

@joaomai there is some feedback that still needs addressing before this can be merged.

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

src/grt/src/MakeWireParasitics.cpp Outdated Show resolved Hide resolved
src/rsz/include/rsz/SpefWriter.hh Outdated Show resolved Hide resolved
src/rsz/include/rsz/SpefWriter.hh Outdated Show resolved Hide resolved
src/rsz/include/rsz/SpefWriter.hh Outdated Show resolved Hide resolved
src/rsz/include/rsz/SpefWriter.hh Outdated Show resolved Hide resolved
src/rsz/src/SpefWriter.cc Outdated Show resolved Hide resolved
Signed-off-by: João Mai <[email protected]>
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

src/rsz/include/rsz/SpefWriter.hh Outdated Show resolved Hide resolved
Signed-off-by: João Mai <[email protected]>
Copy link
Contributor

github-actions bot commented Sep 6, 2024

clang-tidy review says "All clean, LGTM! 👍"

src/grt/src/GlobalRouter.cpp Outdated Show resolved Hide resolved
src/rsz/src/EstimateWireParasitics.cc Show resolved Hide resolved
src/grt/src/MakeWireParasitics.cpp Outdated Show resolved Hide resolved
src/rsz/include/rsz/Resizer.hh Outdated Show resolved Hide resolved
Copy link
Contributor

github-actions bot commented Sep 6, 2024

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Contributor

github-actions bot commented Sep 6, 2024

clang-tidy review says "All clean, LGTM! 👍"

@joaomai joaomai requested a review from eder-matheus September 6, 2024 13:24
Copy link
Contributor

@eder-matheus eder-matheus left a comment

Choose a reason for hiding this comment

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

Other than the two comments, it looks good to me. I'll approve, but will wait for @maliberty final review.

src/rsz/src/EstimateWireParasitics.cc Outdated Show resolved Hide resolved
src/rsz/src/EstimateWireParasitics.cc Outdated Show resolved Hide resolved
src/rsz/src/Resizer.i Show resolved Hide resolved
src/rsz/src/SpefWriter.cc Outdated Show resolved Hide resolved
Copy link
Contributor

github-actions bot commented Sep 9, 2024

clang-tidy review says "All clean, LGTM! 👍"

@joaomai joaomai requested a review from eder-matheus September 9, 2024 19:50
@eder-matheus
Copy link
Contributor

@maliberty Any more comments? I believe we need your approval to merge this PR.

src/rsz/include/rsz/SpefWriter.hh Outdated Show resolved Hide resolved
src/rsz/include/rsz/SpefWriter.hh Outdated Show resolved Hide resolved
src/rsz/include/rsz/SpefWriter.hh Outdated Show resolved Hide resolved
src/rsz/src/SpefWriter.cc Outdated Show resolved Hide resolved
src/rsz/include/rsz/SpefWriter.hh Outdated Show resolved Hide resolved
src/rsz/src/SpefWriter.cc Outdated Show resolved Hide resolved
src/rsz/src/SpefWriter.cc Outdated Show resolved Hide resolved
src/rsz/src/SpefWriter.cc Outdated Show resolved Hide resolved
src/rsz/src/EstimateWireParasitics.cc Outdated Show resolved Hide resolved
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

src/rsz/src/SpefWriter.cc Outdated Show resolved Hide resolved
Signed-off-by: João Mai <[email protected]>
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Member

@maliberty maliberty left a comment

Choose a reason for hiding this comment

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

Nearly there

@@ -281,29 +281,26 @@ void Resizer::estimateParasitics(ParasiticsSrc src)
void Resizer::estimateParasitics(ParasiticsSrc src,
std::map<Corner*, std::ostream*>& spef_streams)
{
SpefWriter* spef_writer = nullptr;
Copy link
Member

Choose a reason for hiding this comment

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

Its better to use std::unique_ptr and avoid manual memory management (eg exception safety).

auto it = spef_streams_.find(corner);
if (it == spef_streams_.end()) {
return;
spef_streams_.clear();
Copy link
Member

Choose a reason for hiding this comment

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

Its going be destructed so there is no need to clear first. The dtor doesn't need to be defined.

}

void SpefWriter::writeSpefPorts(Corner* corner)
std::string getIoDirectionText(const odb::dbIoType& ioType)
Copy link
Member

Choose a reason for hiding this comment

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

char would do for a return type.

@joaomai joaomai requested a review from maliberty September 11, 2024 04:35
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

src/rsz/src/SpefWriter.cc Show resolved Hide resolved
Signed-off-by: João Mai <[email protected]>
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

src/rsz/src/SpefWriter.cc Show resolved Hide resolved
Signed-off-by: João Mai <[email protected]>
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@@ -64,7 +64,7 @@ class SpefWriter
SpefWriter(Logger* logger,
dbSta* sta,
std::map<Corner*, std::ostream*>& spef_streams);
~SpefWriter();
~SpefWriter() = default;
Copy link
Member

Choose a reason for hiding this comment

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

Not needed as the compiler will generate this automatically.

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@joaomai joaomai requested a review from maliberty September 11, 2024 15:40
@maliberty maliberty enabled auto-merge September 11, 2024 15:41
@maliberty maliberty merged commit 9085a6e into The-OpenROAD-Project:master Sep 11, 2024
10 checks passed
@donn
Copy link
Contributor

donn commented Sep 11, 2024

Great work!

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.

Dumping estimated parasitics as SPEF
6 participants