Skip to content

Gui external heatmaps#10005

Open
openroad-ci wants to merge 11 commits intoThe-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:gui-external-heatmaps
Open

Gui external heatmaps#10005
openroad-ci wants to merge 11 commits intoThe-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:gui-external-heatmaps

Conversation

@openroad-ci
Copy link
Copy Markdown
Collaborator

@openroad-ci openroad-ci commented Mar 31, 2026

Summary

  • Introduce ExternalHeatMapDataSource as a generic class to support loading heatmap data externally
  • Introduce utl::CsvParser
  • Introduce load_external_heatmap command

Type of Change

  • New feature

Impact

None of the current designs should be affected by this change.

Verification

  • I have verified that the local build succeeds (./etc/Build.sh).
  • I have run the relevant tests and they pass.
  • My code follows the repository's formatting guidelines.
  • I have signed my commits (DCO).

Related Issues

NA

Signed-off-by: osamahammad21 <osama21@aucegypt.edu>
Signed-off-by: osamahammad21 <osama21@aucegypt.edu>
…nal-heatmaps

Signed-off-by: osamahammad21 <osama21@aucegypt.edu>
Signed-off-by: osamahammad21 <osama21@aucegypt.edu>
Signed-off-by: Osama <osama21@aucegypt.edu>
Signed-off-by: Osama <osama21@aucegypt.edu>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for loading external heatmaps from CSV files. It introduces the ExternalHeatMapDataSource class to handle coordinate-based data and a CsvParser utility for reading the input files. Review feedback highlights a potential crash when processing root chips in hierarchical designs, suggests pre-allocating memory for data entries to improve performance, and notes that the current CSV parsing logic lacks support for quoted fields or escaped characters.

auto* unfolded_chip
= db_->getUnfoldedModel()->findUnfoldedChip(chiplet_name);
if (unfolded_chip != nullptr) {
chip = unfolded_chip->chip_inst_path.back()->getMasterChip();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Accessing unfolded_chip->chip_inst_path.back() without checking if the path is empty can lead to a crash if chiplet_name refers to the top-level chip in an unfolded model. Hierarchical designs typically have an empty path for the root chip.

      if (unfolded_chip->chip_inst_path.empty()) {
        chip = db_->getChip();
      } else {
        chip = unfolded_chip->chip_inst_path.back()->getMasterChip();
      }

}
chiplet_name = csv_rows[0][0];
heatmap_name = csv_rows[0][1];
std::vector<ExternalHeatMapDataSource::Entry> data;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Reserving space in the data vector can improve performance by avoiding multiple reallocations, especially for large CSV files.

  std::vector<ExternalHeatMapDataSource::Entry> data;
  data.reserve(csv_rows.size() - 1);

Comment on lines +46 to +48
while (std::getline(ss, cell, delimiter)) {
cells.push_back(trim(cell));
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The current CSV parsing logic using std::getline with a delimiter is very basic and does not handle standard CSV features like quoted fields (which may contain the delimiter or newlines) or escaped characters. While sufficient for simple numeric data, consider using a more robust parser if this utility is intended for general use within the utl namespace.

Copy link
Copy Markdown
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

}
const std::string short_name
= "External_" + std::to_string(owned_heat_maps_.size() + 1);
auto source = std::make_shared<ExternalHeatMapDataSource>(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "gui::ExternalHeatMapDataSource" is directly included [misc-include-cleaner]

  auto source = std::make_shared<ExternalHeatMapDataSource>(
                                 ^

source->setTransform(transform);
registerHeatMap(source.get());
owned_heat_maps_.push_back(std::move(source));
return short_name;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: constness of 'short_name' prevents automatic move [performance-no-automatic-move]

  return short_name;
         ^

#include <map>
#include <memory>
#include <optional>
#include <sstream>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: included header optional is not used directly [misc-include-cleaner]

Suggested change
#include <sstream>
#include <sstream>

#include <memory>
#include <optional>
#include <sstream>
#include <string>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: included header sstream is not used directly [misc-include-cleaner]

Suggested change
#include <string>
#include <string>

#include "heatMapSetup.h"
#include "odb/db.h"
#include "utl/Logger.h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: included header Logger.h is not used directly [misc-include-cleaner]

Suggested change


namespace {

static std::string trim(const std::string& s)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::string" is directly included [misc-include-cleaner]

src/utl/src/CsvParser.cpp:7:

+ #include <string>


} // namespace

std::vector<std::vector<std::string>> readCsv(const std::string& file_path,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::vector" is directly included [misc-include-cleaner]

src/utl/src/CsvParser.cpp:7:

+ #include <vector>


std::vector<std::vector<std::string>> rows;
std::string line;
while (std::getline(in, line)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::getline" is directly included [misc-include-cleaner]

  while (std::getline(in, line)) {
              ^

std::vector<std::string> cells;
std::stringstream ss(line);
std::string cell;
while (std::getline(ss, cell, delimiter)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::getline" is directly included [misc-include-cleaner]

    while (std::getline(ss, cell, delimiter)) {
                ^

while (std::getline(ss, cell, delimiter)) {
cells.push_back(trim(cell));
}
rows.push_back(std::move(cells));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::move" is directly included [misc-include-cleaner]

src/utl/src/CsvParser.cpp:7:

+ #include <utility>

Signed-off-by: Osama <osama21@aucegypt.edu>
@osamahammad21 osamahammad21 requested a review from maliberty March 31, 2026 12:32
file_path,
csv_rows[0].size());
}
const std::string chiplet_name = csv_rows[0][0];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why is chiplet_name here? that seems somewhat specific

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To support 3D designs. When you have multiple chiplets in a system, the chiplet name is needed to apply the correct transformation per chiplet.

gui->dumpHeatMap(name, file);
}

std::string load_external_heatmap(const std::string& file_path)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

no tcl command, maybe call this load_heatmap (unless it's specific to the chiplet, in which case that should be clear from the name


namespace {

static std::string trim(const std::string& s)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use boost::trim ?

@osamahammad21
Copy link
Copy Markdown
Member

@vvbandeira @sombraSoft macOS build is failing while the bazel build in the CI is passing. Is this normal?

@maliberty
Copy link
Copy Markdown
Member

Mac is running with --//:platform=gui but the regular build is not (yet). The error is in gui so it only appears there but is probably not mac specific.

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.

4 participants