Skip to content

Add a new API set_node_rc_index() to RRGraphBuilder #1887

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

Merged
merged 7 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions vpr/src/device/rr_graph_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ class RRGraphBuilder {
node_storage_.set_node_direction(id, new_direction);
}

/** @brief Set the rc_index of routing resource node. */
inline void set_node_rc_index(RRNodeId id, NodeRCIndex new_rc_index) {
node_storage_.set_node_rc_index(id, new_rc_index);
}

/* -- Internal data storage -- */
private:
/* TODO: When the refactoring effort finishes,
Expand Down
2 changes: 2 additions & 0 deletions vpr/src/device/rr_graph_fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ struct rr_edge_id_tag;
struct rr_indexed_data_id_tag;
struct rr_switch_id_tag;
struct rr_segment_id_tag;
struct rc_index_tag;

typedef vtr::StrongId<rr_node_id_tag, unsigned int> RRNodeId;
typedef vtr::StrongId<rr_edge_id_tag, unsigned int> RREdgeId;
typedef vtr::StrongId<rr_indexed_data_id_tag, unsigned int> RRIndexedDataId;
typedef vtr::StrongId<rr_switch_id_tag, short> RRSwitchId;
typedef vtr::StrongId<rr_segment_id_tag, short> RRSegmentId;
typedef vtr::StrongId<rc_index_tag, short> NodeRCIndex;

#endif
2 changes: 1 addition & 1 deletion vpr/src/route/clock_connection_builders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ RRNodeId RoutingToClockConnection::create_virtual_clock_network_sink_node(int x,

float R = 0.;
float C = 0.;
rr_graph.set_node_rc_index(node_index, find_create_rr_rc_data(R, C));
rr_graph_builder.set_node_rc_index(node_index, NodeRCIndex(find_create_rr_rc_data(R, C)));
Copy link
Contributor

Choose a reason for hiding this comment

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

@hariszafar-lm Can you quickly check if we can change the data type that function find_create_rr_rc_data() returns? We can avoid these changes.

Copy link
Author

Choose a reason for hiding this comment

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

I tried that before but it gives a lot of errors related to conversions and ambiguating new declaration of NodeRCIndex find_create_rr_rc_data(float, float)

Copy link
Contributor

Choose a reason for hiding this comment

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

No worries. Can you share the output of grep -r "find_create_rr_rc_data" .? So that I know how many times it is called in all the source files. Thanks

Copy link
Author

Choose a reason for hiding this comment

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

Here is the output on the master branch. It has been calling 11 times.

vpr/src/route/clock_connection_builders.cpp:    rr_graph.set_node_rc_index(node_index, find_create_rr_rc_data(R, C));
vpr/src/route/clock_network_builders.cpp:    node.set_rc_index(find_create_rr_rc_data(
vpr/src/route/clock_network_builders.cpp:    node.set_rc_index(find_create_rr_rc_data(
vpr/src/route/rr_graph.cpp:        L_rr_node.set_node_rc_index(inode, find_create_rr_rc_data(R, C));
vpr/src/route/rr_graph.cpp:                            L_rr_node.set_node_rc_index(inode, find_create_rr_rc_data(R, C));
vpr/src/route/rr_graph.cpp:        L_rr_node.set_node_rc_index(node, find_create_rr_rc_data(R, C));
vpr/src/route/rr_graph_timing_params.cpp:        mutable_device_ctx.rr_nodes[inode].set_rc_index(find_create_rr_rc_data(rr_graph.node_R(RRNodeId(inode)), rr_node_C[inode]));
vpr/src/route/rr_graph_uxsdcxx_serializer.h:        node.set_rc_index(find_create_rr_rc_data(R, C));
vpr/src/route/rr_graph_uxsdcxx_serializer.h:        node.set_rc_index(find_create_rr_rc_data(0, 0));
vpr/src/route/rr_rc_data.cpp:short find_create_rr_rc_data(const float R, const float C) {
vpr/src/route/rr_rc_data.h:short find_create_rr_rc_data(const float R, const float C);

Copy link
Contributor

Choose a reason for hiding this comment

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

@hariszafar-lm This is not big. If you want to avoid big changes in this PR. We can do it in a follow-up PR.

Copy link
Author

Choose a reason for hiding this comment

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

We'll look at this in some other PR.


// Use a generic way when adding nodes to lookup.
// However, since the SINK node has the same xhigh/xlow as well as yhigh/ylow, we can probably use a shortcut
Expand Down
8 changes: 4 additions & 4 deletions vpr/src/route/clock_network_builders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ int ClockRib::create_chanx_wire(int x_start,
rr_graph_builder.set_node_coordinates(chanx_node, x_start, y, x_end, y);
rr_graph_builder.set_node_capacity(chanx_node, 1);
rr_graph_builder.set_node_track_num(chanx_node, ptc_num);
node.set_rc_index(find_create_rr_rc_data(
x_chan_wire.layer.r_metal, x_chan_wire.layer.c_metal));
rr_graph_builder.set_node_rc_index(chanx_node, NodeRCIndex(find_create_rr_rc_data(
x_chan_wire.layer.r_metal, x_chan_wire.layer.c_metal)));
rr_graph_builder.set_node_direction(chanx_node, direction);

short seg_index = 0;
Expand Down Expand Up @@ -629,8 +629,8 @@ int ClockSpine::create_chany_wire(int y_start,
rr_graph_builder.set_node_coordinates(chany_node, x, y_start, x, y_end);
rr_graph_builder.set_node_capacity(chany_node, 1);
rr_graph_builder.set_node_track_num(chany_node, ptc_num);
node.set_rc_index(find_create_rr_rc_data(
y_chan_wire.layer.r_metal, y_chan_wire.layer.c_metal));
rr_graph_builder.set_node_rc_index(chany_node, NodeRCIndex(find_create_rr_rc_data(
y_chan_wire.layer.r_metal, y_chan_wire.layer.c_metal)));
rr_graph_builder.set_node_direction(chany_node, direction);

short seg_index = 0;
Expand Down
6 changes: 3 additions & 3 deletions vpr/src/route/rr_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ static void build_rr_sinks_sources(RRGraphBuilder& rr_graph_builder,
rr_graph_builder.set_node_coordinates(inode, i, j, i + type->width - 1, j + type->height - 1);
float R = 0.;
float C = 0.;
L_rr_node.set_node_rc_index(inode, find_create_rr_rc_data(R, C));
rr_graph_builder.set_node_rc_index(inode, NodeRCIndex(find_create_rr_rc_data(R, C)));
rr_graph_builder.set_node_class_num(inode, iclass);
}

Expand Down Expand Up @@ -1485,7 +1485,7 @@ static void build_rr_sinks_sources(RRGraphBuilder& rr_graph_builder,
rr_graph_builder.set_node_capacity(inode, 1);
float R = 0.;
float C = 0.;
L_rr_node.set_node_rc_index(inode, find_create_rr_rc_data(R, C));
rr_graph_builder.set_node_rc_index(inode, NodeRCIndex(find_create_rr_rc_data(R, C)));
rr_graph_builder.set_node_pin_num(inode, ipin);

//Note that we store the grid tile location and side where the pin is located,
Expand Down Expand Up @@ -1674,7 +1674,7 @@ static void build_rr_chan(RRGraphBuilder& rr_graph_builder,
int length = end - start + 1;
float R = length * seg_details[track].Rmetal();
float C = length * seg_details[track].Cmetal();
L_rr_node.set_node_rc_index(node, find_create_rr_rc_data(R, C));
rr_graph_builder.set_node_rc_index(node, NodeRCIndex(find_create_rr_rc_data(R, C)));

rr_graph_builder.set_node_type(node, chan_type);
rr_graph_builder.set_node_track_num(node, track);
Expand Down
4 changes: 2 additions & 2 deletions vpr/src/route/rr_graph_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,8 @@ void t_rr_graph_storage::set_node_cost_index(RRNodeId id, RRIndexedDataId new_co
node.cost_index_ = (size_t)new_cost_index;
}

void t_rr_graph_storage::set_node_rc_index(RRNodeId id, short new_rc_index) {
node_storage_[id].rc_index_ = new_rc_index;
void t_rr_graph_storage::set_node_rc_index(RRNodeId id, NodeRCIndex new_rc_index) {
node_storage_[id].rc_index_ = (size_t)new_rc_index;
}

void t_rr_graph_storage::set_node_capacity(RRNodeId id, short new_capacity) {
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/route/rr_graph_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ class t_rr_graph_storage {
void set_node_type(RRNodeId id, t_rr_type new_type);
void set_node_coordinates(RRNodeId id, short x1, short y1, short x2, short y2);
void set_node_cost_index(RRNodeId, RRIndexedDataId new_cost_index);
void set_node_rc_index(RRNodeId, short new_rc_index);
void set_node_rc_index(RRNodeId, NodeRCIndex new_rc_index);
void set_node_capacity(RRNodeId, short new_capacity);
void set_node_direction(RRNodeId, Direction new_direction);

Expand Down
2 changes: 1 addition & 1 deletion vpr/src/route/rr_graph_timing_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void add_rr_graph_C_from_switches(float C_ipin_cblock) {

//Create the final flywieghted t_rr_rc_data
for (size_t inode = 0; inode < device_ctx.rr_nodes.size(); inode++) {
mutable_device_ctx.rr_nodes[inode].set_rc_index(find_create_rr_rc_data(rr_graph.node_R(RRNodeId(inode)), rr_node_C[inode]));
mutable_device_ctx.rr_graph_builder.set_node_rc_index(RRNodeId(inode), NodeRCIndex(find_create_rr_rc_data(rr_graph.node_R(RRNodeId(inode)), rr_node_C[inode])));
}

free(Couts_to_add);
Expand Down
5 changes: 3 additions & 2 deletions vpr/src/route/rr_graph_uxsdcxx_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,8 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
*/
inline int init_node_timing(int& inode, float C, float R) final {
auto node = (*rr_nodes_)[inode];
node.set_rc_index(find_create_rr_rc_data(R, C));
RRNodeId node_id = node.id();
rr_graph_builder_->set_node_rc_index(node_id, NodeRCIndex(find_create_rr_rc_data(R, C)));
return inode;
}
inline void finish_node_timing(int& /*inode*/) final {}
Expand Down Expand Up @@ -789,7 +790,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
type);
}

node.set_rc_index(find_create_rr_rc_data(0, 0));
rr_graph_builder_->set_node_rc_index(node_id, NodeRCIndex(find_create_rr_rc_data(0, 0)));

return id;
}
Expand Down
4 changes: 0 additions & 4 deletions vpr/src/route/rr_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ void t_rr_node::set_cost_index(RRIndexedDataId new_cost_index) {
storage_->set_node_cost_index(id_, new_cost_index);
}

void t_rr_node::set_rc_index(short new_rc_index) {
storage_->set_node_rc_index(id_, new_rc_index);
}

void t_rr_node::add_side(e_side new_side) {
storage_->add_node_side(id_, new_side);
}
1 change: 0 additions & 1 deletion vpr/src/route/rr_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ class t_rr_node {

public: //Mutators
void set_cost_index(RRIndexedDataId);
void set_rc_index(short);

void set_side(e_side);
void add_side(e_side);
Expand Down