Skip to content

Commit 1f056de

Browse files
HackerFooacomodi
authored andcommitted
Remove cached segment map from connection map lookahead file.
Signed-off-by: Dusty DeWeese <[email protected]> Signed-off-by: Keith Rothman <[email protected]>
1 parent c3832c5 commit 1f056de

File tree

3 files changed

+18
-29
lines changed

3 files changed

+18
-29
lines changed

libs/libvtrcapnproto/connection_map.capnp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ struct VprFloatEntry {
2020
struct VprCostMap {
2121
costMap @0 :Matrix.Matrix((Matrix.Matrix(VprCostEntry)));
2222
offset @1 :Matrix.Matrix(VprVector2D);
23-
segmentMap @2 :List(Int64);
23+
depField @2 :List(Int64);
2424
penalty @3 :Matrix.Matrix(VprFloatEntry);
2525
}

vpr/src/route/connection_box_lookahead_map.cpp

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,8 @@ static vtr::Point<T> closest_point_in_rect(const vtr::Rect<T>& r, const vtr::Poi
110110
}
111111
}
112112

113-
// resize internal data structures
114-
void CostMap::set_counts(size_t seg_count, size_t box_count) {
115-
cost_map_.clear();
116-
offset_.clear();
117-
penalty_.clear();
118-
cost_map_.resize({seg_count, box_count});
119-
offset_.resize({seg_count, box_count});
120-
penalty_.resize({seg_count, box_count});
121-
seg_count_ = seg_count;
122-
box_count_ = box_count;
123-
113+
// build the segment map
114+
void CostMap::build_segment_map() {
124115
const auto& device_ctx = g_vpr_ctx.device();
125116
segment_map_.resize(device_ctx.rr_nodes.size());
126117
for (size_t i = 0; i < segment_map_.size(); ++i) {
@@ -133,6 +124,18 @@ void CostMap::set_counts(size_t seg_count, size_t box_count) {
133124
}
134125
}
135126

127+
// resize internal data structures
128+
void CostMap::set_counts(size_t seg_count, size_t box_count) {
129+
cost_map_.clear();
130+
offset_.clear();
131+
penalty_.clear();
132+
cost_map_.resize({seg_count, box_count});
133+
offset_.resize({seg_count, box_count});
134+
penalty_.resize({seg_count, box_count});
135+
seg_count_ = seg_count;
136+
box_count_ = box_count;
137+
}
138+
136139
// cached node -> segment map
137140
int CostMap::node_to_segment(int from_node_ind) const {
138141
return segment_map_[from_node_ind];
@@ -638,6 +641,7 @@ void ConnectionBoxMapLookahead::compute(const std::vector<t_segment_inf>& segmen
638641
auto& device_ctx = g_vpr_ctx.device();
639642
cost_map_.set_counts(segment_inf.size(),
640643
device_ctx.connection_boxes.num_connection_box_types());
644+
cost_map_.build_segment_map();
641645

642646
VTR_ASSERT(REPRESENTATIVE_ENTRY_METHOD == util::SMALLEST);
643647
RoutingCosts all_delay_costs;
@@ -1053,22 +1057,13 @@ static void FromFloat(VprFloatEntry::Builder* out, const float& in) {
10531057
}
10541058

10551059
void CostMap::read(const std::string& file) {
1060+
build_segment_map();
10561061
MmapFile f(file);
10571062

10581063
::capnp::ReaderOptions opts = default_large_capnp_opts();
10591064
::capnp::FlatArrayMessageReader reader(f.getData(), opts);
10601065

10611066
auto cost_map = reader.getRoot<VprCostMap>();
1062-
1063-
{
1064-
const auto& segment_map = cost_map.getSegmentMap();
1065-
segment_map_.resize(segment_map.size());
1066-
auto dst_iter = segment_map_.begin();
1067-
for (const auto& src : segment_map) {
1068-
*dst_iter++ = src;
1069-
}
1070-
}
1071-
10721067
{
10731068
const auto& offset = cost_map.getOffset();
10741069
ToNdMatrix<2, VprVector2D, std::pair<int, int>>(
@@ -1093,13 +1088,6 @@ void CostMap::write(const std::string& file) const {
10931088

10941089
auto cost_map = builder.initRoot<VprCostMap>();
10951090

1096-
{
1097-
auto segment_map = cost_map.initSegmentMap(segment_map_.size());
1098-
for (size_t i = 0; i < segment_map_.size(); ++i) {
1099-
segment_map.set(i, segment_map_[i]);
1100-
}
1101-
}
1102-
11031091
{
11041092
auto offset = cost_map.initOffset();
11051093
FromNdMatrix<2, VprVector2D, std::pair<int, int>>(

vpr/src/route/connection_box_lookahead_map.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ typedef std::unordered_map<RoutingCostKey, float, HashRoutingCostKey> RoutingCos
5050
class CostMap {
5151
public:
5252
void set_counts(size_t seg_count, size_t box_count);
53+
void build_segment_map();
5354
int node_to_segment(int from_node_ind) const;
5455
util::Cost_Entry find_cost(int from_seg_index, ConnectionBoxId box_id, int delta_x, int delta_y) const;
5556
void set_cost_map(const RoutingCosts& delay_costs, const RoutingCosts& base_costs);

0 commit comments

Comments
 (0)