Skip to content

Add a new API set_node_coordinates() to RRGraphBuilder #1853

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 5 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions vpr/src/device/rr_graph_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ void RRGraphBuilder::add_node_to_all_locs(RRNodeId node) {
void RRGraphBuilder::clear() {
node_lookup_.clear();
}

void RRGraphBuilder::set_node_coordinates(RRNodeId id, short x1, short y1, short x2, short y2) {
node_storage_.set_node_coordinates(id, x1, y1, x2, y2);
}
3 changes: 3 additions & 0 deletions vpr/src/device/rr_graph_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class RRGraphBuilder {
/** @brief Clear all the underlying data storage */
void clear();

/** @brief Set the node coordinate */
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably isn't too cpu critical so can leave here. But should get a QoR spreadsheet to check we haven't slowed things down noticably; if there's a slowdown, marking this function as inline and adding the function body to the header should recapture the speed. For very short functions like this, inline works well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have shared the QoR sheets. Please let me know if this needs to be inlined after seenig QoR comparisons.

void set_node_coordinates(RRNodeId id, short x1, short y1, short x2, short y2);

/* -- Internal data storage -- */
private:
/* TODO: When the refactoring effort finishes,
Expand Down
3 changes: 2 additions & 1 deletion vpr/src/route/clock_connection_builders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ void RoutingToClockConnection::create_switches(const ClockRRGraphBuilder& clock_
RRNodeId RoutingToClockConnection::create_virtual_clock_network_sink_node(int x, int y) {
auto& device_ctx = g_vpr_ctx.mutable_device();
auto& rr_graph = device_ctx.rr_nodes;
auto& rr_graph_builder = device_ctx.rr_graph_builder;
auto& node_lookup = device_ctx.rr_graph_builder.node_lookup();
rr_graph.emplace_back();
RRNodeId node_index = RRNodeId(rr_graph.size() - 1);
Expand All @@ -106,7 +107,7 @@ RRNodeId RoutingToClockConnection::create_virtual_clock_network_sink_node(int x,
int ptc = max_ptc + 1;

rr_graph.set_node_ptc_num(node_index, ptc);
rr_graph.set_node_coordinates(node_index, x, y, x, y);
rr_graph_builder.set_node_coordinates(node_index, x, y, x, y);
rr_graph.set_node_capacity(node_index, 1);
rr_graph.set_node_cost_index(node_index, SINK_COST_INDEX);
rr_graph.set_node_type(node_index, SINK);
Expand Down
10 changes: 6 additions & 4 deletions vpr/src/route/clock_network_builders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,9 @@ int ClockRib::create_chanx_wire(int x_start,
rr_nodes->emplace_back();
auto node_index = rr_nodes->size() - 1;
auto node = rr_nodes->back();
RRNodeId chanx_node = RRNodeId(node_index);

node.set_coordinates(x_start, y, x_end, y);
rr_graph_builder.set_node_coordinates(chanx_node, x_start, y, x_end, y);
node.set_type(CHANX);
node.set_capacity(1);
node.set_track_num(ptc_num);
Expand All @@ -345,7 +346,7 @@ int ClockRib::create_chanx_wire(int x_start,

/* Add the node to spatial lookup */
auto& rr_graph = (*rr_nodes);
RRNodeId chanx_node = RRNodeId(node_index);

/* TODO: Will replace these codes with an API add_node_to_all_locs() of RRGraphBuilder */
for (int ix = rr_graph.node_xlow(chanx_node); ix <= rr_graph.node_xhigh(chanx_node); ++ix) {
for (int iy = rr_graph.node_ylow(chanx_node); iy <= rr_graph.node_yhigh(chanx_node); ++iy) {
Expand Down Expand Up @@ -623,8 +624,9 @@ int ClockSpine::create_chany_wire(int y_start,
rr_nodes->emplace_back();
auto node_index = rr_nodes->size() - 1;
auto node = rr_nodes->back();
RRNodeId chany_node = RRNodeId(node_index);

node.set_coordinates(x, y_start, x, y_end);
rr_graph_builder.set_node_coordinates(chany_node, x, y_start, x, y_end);
node.set_type(CHANY);
node.set_capacity(1);
node.set_track_num(ptc_num);
Expand All @@ -651,7 +653,7 @@ int ClockSpine::create_chany_wire(int y_start,

/* Add the node to spatial lookup */
auto& rr_graph = (*rr_nodes);
RRNodeId chany_node = RRNodeId(node_index);

/* TODO: Will replace these codes with an API add_node_to_all_locs() of RRGraphBuilder */
for (int ix = rr_graph.node_xlow(chany_node); ix <= rr_graph.node_xhigh(chany_node); ++ix) {
for (int iy = rr_graph.node_ylow(chany_node); iy <= rr_graph.node_yhigh(chany_node); ++iy) {
Expand Down
8 changes: 4 additions & 4 deletions vpr/src/route/rr_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,7 @@ static void build_rr_sinks_sources(RRGraphBuilder& rr_graph_builder,

/* Things common to both SOURCEs and SINKs. */
L_rr_node.set_node_capacity(inode, class_inf[iclass].num_pins);
L_rr_node.set_node_coordinates(inode, i, j, i + type->width - 1, j + type->height - 1);
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));
Expand Down Expand Up @@ -1488,7 +1488,7 @@ static void build_rr_sinks_sources(RRGraphBuilder& rr_graph_builder,
//For those pins located on multiple sides, we save the rr node index
//for the pin on all sides at which it exists
//As such, multipler driver problem can be avoided.
L_rr_node.set_node_coordinates(inode, i + width_offset, j + height_offset, i + width_offset, j + height_offset);
rr_graph_builder.set_node_coordinates(inode, i + width_offset, j + height_offset, i + width_offset, j + height_offset);
L_rr_node.add_node_side(inode, side);

// Sanity check
Expand Down Expand Up @@ -1660,10 +1660,10 @@ static void build_rr_chan(RRGraphBuilder& rr_graph_builder,
L_rr_node.set_node_capacity(node, 1); /* GLOBAL routing handled elsewhere */

if (chan_type == CHANX) {
L_rr_node.set_node_coordinates(node, start, y_coord, end, y_coord);
rr_graph_builder.set_node_coordinates(node, start, y_coord, end, y_coord);
} else {
VTR_ASSERT(chan_type == CHANY);
L_rr_node.set_node_coordinates(node, x_coord, start, x_coord, end);
rr_graph_builder.set_node_coordinates(node, x_coord, start, x_coord, end);
}

int length = end - start + 1;
Expand Down
3 changes: 2 additions & 1 deletion vpr/src/route/rr_graph_uxsdcxx_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,9 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {

inline int init_node_loc(int& inode, int ptc, int xhigh, int xlow, int yhigh, int ylow) final {
auto node = (*rr_nodes_)[inode];
RRNodeId node_id = node.id();

node.set_coordinates(xlow, ylow, xhigh, yhigh);
rr_graph_builder_->set_node_coordinates(node_id, xlow, ylow, xhigh, yhigh);
node.set_ptc_num(ptc);
return inode;
}
Expand Down
8 changes: 0 additions & 8 deletions vpr/src/route/rr_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ void t_rr_node::set_type(t_rr_type new_type) {
storage_->set_node_type(id_, new_type);
}

/*
* Pass in two coordinate variables describing location of node.
* They do not have to be in any particular order.
*/
void t_rr_node::set_coordinates(short x1, short y1, short x2, short y2) {
storage_->set_node_coordinates(id_, x1, y1, x2, y2);
}

void t_rr_node::set_ptc_num(short new_ptc_num) {
storage_->set_node_ptc_num(id_, new_ptc_num);
}
Expand Down
2 changes: 0 additions & 2 deletions vpr/src/route/rr_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ class t_rr_node {
public: //Mutators
void set_type(t_rr_type new_type);

void set_coordinates(short x1, short y1, short x2, short y2);

void set_capacity(short);

void set_ptc_num(short);
Expand Down