Skip to content

Commit 616629d

Browse files
committed
[lib] add resize for ptc nums
1 parent d687349 commit 616629d

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

libs/librrgraph/src/base/rr_graph_builder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,17 +253,17 @@ void RRGraphBuilder::set_node_ptc_nums(RRNodeId node, const std::string& ptc_str
253253
}
254254

255255
std::string RRGraphBuilder::node_ptc_nums_to_string(RRNodeId node) const {
256-
std::string ret;
257256
if (node_ptc_nums_.empty()) {
258-
return std::to_string(node_storage_.node_ptc_num(node));
257+
return std::to_string(size_t(node_storage_.node_ptc_num(node)));
259258
// VTR_LOG("Node ptc single: %d -> string %s\n", node_storage_.node_ptc_num(node), ret.c_str());
260259
}
261260
VTR_ASSERT(size_t(node) < node_ptc_nums_.size());
262261
if (node_ptc_nums_[node].empty()) {
263-
return std::to_string(node_storage_.node_ptc_num(node));
262+
return std::to_string(size_t(node_storage_.node_ptc_num(node)));
264263
}
264+
std::string ret;
265265
for (size_t iptc = 0; iptc < node_ptc_nums_[node].size(); iptc++) {
266-
ret += std::to_string(node_ptc_nums_[node][iptc]) + ",";
266+
ret += std::to_string(size_t(node_ptc_nums_[node][iptc])) + ",";
267267
}
268268
/* Remove the last comma */
269269
ret.pop_back();

libs/librrgraph/src/base/rr_graph_builder.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,11 @@ class RRGraphBuilder {
343343
inline void resize_nodes(size_t size) {
344344
node_storage_.resize(size);
345345
}
346+
/** @brief This function resize node ptc nums. Only used by RR graph I/O reader and writers. Do not use for internal builder */
347+
inline void resize_node_ptc_nums(size_t size) {
348+
node_ptc_nums_.resize(size);
349+
}
350+
346351

347352
/** @brief This function resize node ptc twist increment; Since it is only used for tileable rr-graph, we don't put it in general resize function*/
348353
inline void resize_ptc_twist_incr(size_t size){

libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
880880
*/
881881
inline void preallocate_rr_nodes_node(void*& /*ctx*/, size_t size) final {
882882
rr_graph_builder_->reserve_nodes(size);
883+
rr_graph_builder_->resize_node_ptc_nums(size);
883884
}
884885
inline int add_rr_nodes_node(void*& /*ctx*/, unsigned int capacity, unsigned int id, uxsd::enum_node_type type) final {
885886
// make_room_in_vector will not allocate if preallocate_rr_nodes_node

0 commit comments

Comments
 (0)