Skip to content

Commit e753094

Browse files
author
Nathan Shreve
committed
Refactored LookaheadProfiler
1 parent c747096 commit e753094

File tree

2 files changed

+32
-49
lines changed

2 files changed

+32
-49
lines changed

vpr/src/route/lookahead_profiler.cpp

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//
2-
// Created by shrevena on 08/06/24.
3-
//
4-
51
#include <sstream>
62

73
#include "globals.h"
@@ -31,7 +27,7 @@ void LookaheadProfiler::record(int iteration,
3127
VTR_LOG_ERROR("Could not open lookahead_verifier_info.csv");
3228
throw vtr::VtrError("Could not open lookahead_verifier_info.csv",
3329
"lookahead_profiler.cpp",
34-
32);
30+
28);
3531
}
3632

3733
lookahead_verifier_csv_
@@ -62,57 +58,47 @@ void LookaheadProfiler::record(int iteration,
6258
}
6359

6460
if (!lookahead_verifier_csv_.is_open()) {
65-
if (toggle_warn_) {
66-
VTR_LOG_WARN("lookahead_verifier_info.csv is not open");
67-
toggle_warn_ = false;
68-
}
69-
70-
return;
71-
} else {
72-
toggle_warn_ = true;
61+
VTR_LOG_ERROR("lookahead_verifier_info.csv is not open.");
62+
throw vtr::VtrError("lookahead_verifier_info.csv is not open.",
63+
"lookahead_profiler.cpp",
64+
62);
7365
}
7466

7567
// The default value in RouteTree::update_from_heap() is -1; only calls which descend from route_net()
7668
// pass in an iteration value, which is the only context in which we want to profile.
7769
if (iteration < 1)
7870
return;
7971

80-
RRNodeId source_inode = branch_inodes.back(); // Not necessarily an actual SOURCE node.
72+
RRNodeId source_inode = branch_inodes.back(); // Not necessarily a SOURCE node.
8173
RRNodeId sink_inode = branch_inodes.front();
8274

8375
VTR_ASSERT(rr_graph.node_type(sink_inode) == SINK);
76+
VTR_ASSERT(net_id != ParentNetId::INVALID());
77+
VTR_ASSERT(target_net_pin_index != OPEN);
8478

8579
/* Get sink node attributes (atom block name, atom block model, cluster type, tile dimensions) */
8680

87-
if (atom_block_names_.find(sink_inode) == atom_block_names_.end()) {
88-
if (net_id != ParentNetId::INVALID() && target_net_pin_index != OPEN) {
89-
atom_block_names_[sink_inode] = net_list.block_name(net_list.net_pin_block(net_id, target_net_pin_index));
90-
91-
AtomBlockId atom_block_id = g_vpr_ctx.atom().nlist.find_block(atom_block_names_[sink_inode]);
92-
atom_block_models_[sink_inode] = g_vpr_ctx.atom().nlist.block_model(atom_block_id)->name;
81+
if (net_pin_blocks_.find(sink_inode) == net_pin_blocks_.end()) {
82+
net_pin_blocks_[sink_inode] = net_list.net_pin_block(net_id, target_net_pin_index);
9383

94-
ClusterBlockId cluster_block_id = atom_to_cluster(atom_block_id);
84+
AtomBlockId atom_block_id = g_vpr_ctx.atom().nlist.find_block(net_list.block_name(net_pin_blocks_[sink_inode]));
85+
sink_atom_block_[sink_inode] = g_vpr_ctx.atom().nlist.block_model(atom_block_id);
9586

96-
cluster_block_types_[sink_inode] = g_vpr_ctx.clustering().clb_nlist.block_type(cluster_block_id)->name;
87+
ClusterBlockId cluster_block_id = atom_to_cluster(atom_block_id);
88+
sink_cluster_block_[sink_inode] = g_vpr_ctx.clustering().clb_nlist.block_type(cluster_block_id);
9789

98-
auto tile_type = physical_tile_type(cluster_block_id);
99-
tile_dimensions_[sink_inode] = std::pair(std::to_string(tile_type->width), std::to_string(tile_type->height));
100-
} else {
101-
atom_block_names_[sink_inode] = "--";
102-
atom_block_models_[sink_inode] = "--";
103-
cluster_block_types_[sink_inode] = "--";
104-
tile_dimensions_[sink_inode] = {"--", "--"};
105-
}
90+
tile_types_[sink_inode] = physical_tile_type(cluster_block_id);
10691
}
10792

108-
VTR_ASSERT_SAFE(atom_block_models_.find(sink_inode) != atom_block_models_.end());
109-
VTR_ASSERT_SAFE(cluster_block_types_.find(sink_inode) != cluster_block_types_.end());
110-
VTR_ASSERT_SAFE(tile_dimensions_.find(sink_inode) != tile_dimensions_.end());
93+
VTR_ASSERT_SAFE(sink_atom_block_.find(sink_inode) != sink_atom_block_.end());
94+
VTR_ASSERT_SAFE(sink_cluster_block_.find(sink_inode) != sink_cluster_block_.end());
95+
VTR_ASSERT_SAFE(tile_types_.find(sink_inode) != tile_types_.end());
11196

112-
const std::string& block_name = atom_block_names_[sink_inode];
113-
const std::string& atom_block_model = atom_block_models_[sink_inode];
114-
const std::string& cluster_block_type = cluster_block_types_[sink_inode];
115-
const auto& [tile_width, tile_height] = tile_dimensions_[sink_inode];
97+
const std::string& block_name = net_list.block_name(net_pin_blocks_[sink_inode]);
98+
const std::string atom_block_model = sink_atom_block_[sink_inode]->name;
99+
const std::string cluster_block_type = sink_cluster_block_[sink_inode]->name;
100+
const std::string tile_width = std::to_string(tile_types_[sink_inode]->width);
101+
const std::string tile_height = std::to_string(tile_types_[sink_inode]->height);
116102

117103
/* Iterate through the given path and record information for each node */
118104
for (size_t nodes_from_sink = 2; nodes_from_sink < branch_inodes.size(); ++nodes_from_sink) { // Distance one node away is always 0. (IPIN->SINK)

vpr/src/route/lookahead_profiler.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
class LookaheadProfiler {
1616
public:
1717
LookaheadProfiler()
18-
: is_empty_(true)
19-
, toggle_warn_(true) {}
18+
: is_empty_(true) {}
2019

2120
LookaheadProfiler(const LookaheadProfiler&) = delete;
2221
LookaheadProfiler& operator=(const LookaheadProfiler&) = delete;
@@ -48,16 +47,14 @@ class LookaheadProfiler {
4847
std::ofstream lookahead_verifier_csv_;
4948
///@brief Whether the output file is empty/not yet opened.
5049
bool is_empty_;
51-
///@brief Whether to creat a warning if the output csv is not open. Used to avoid repeated warnings.
52-
bool toggle_warn_;
53-
///@brief A map from sink node IDs to the names of their atom blocks.
54-
std::unordered_map<RRNodeId, std::string> atom_block_names_;
55-
///@brief A map from sink node IDs to the names of the models of their atom blocks.
56-
std::unordered_map<RRNodeId, std::string> atom_block_models_;
57-
///@brief A map from sink node IDs to the names of the types of their clusters.
58-
std::unordered_map<RRNodeId, std::string> cluster_block_types_;
59-
///@brief A map from sink node IDs to the dimensions of their tiles (width, height).
60-
std::unordered_map<RRNodeId, std::pair<std::string, std::string>> tile_dimensions_;
50+
///@brief A map from sink node IDs to their atom blocks' IDs.
51+
std::unordered_map<RRNodeId, ParentBlockId> net_pin_blocks_;
52+
///@brief A map from sink node IDs to a pointer to the model of their atom blocks.
53+
std::unordered_map<RRNodeId, const t_model*> sink_atom_block_;
54+
///@brief A map from sink node IDs to a pointer to their cluster blocks.
55+
std::unordered_map<RRNodeId, t_logical_block_type_ptr> sink_cluster_block_;
56+
///@brief A map from sink node IDs to a pointer to their tiles' types.
57+
std::unordered_map<RRNodeId, t_physical_tile_type_ptr> tile_types_;
6158
};
6259

6360
#endif //VTR_LOOKAHEAD_PROFILER_H

0 commit comments

Comments
 (0)