Skip to content

Refactored vpr/src/draw #2049

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 19 commits into from
Jun 9, 2022
Merged

Refactored vpr/src/draw #2049

merged 19 commits into from
Jun 9, 2022

Conversation

jmah76
Copy link
Contributor

@jmah76 jmah76 commented Jun 2, 2022

Refactored the vpr/src/draw folder by splitting draw.cpp into smaller files to reduce file length.

Motivation and Context

Draw.cpp was too long (~3000-4000 lines), now much shorter (~1500 lines).

How It Was Tested

  • VPR Graphics was run once with the changes, then without. The visualizations of both were compared, and were checked if they were relatively the same.
  • Command line scripts in the documentation were tested for expected behaviour.
    • Note: As in Issue --graphics command doesn't seem to work #2001, graphics_commands don't work (throws Unexpected command-line argument, could be that the commands aren't being recognized as graphics commands but normal command line options-- the error message matches that of an options error and not a graphics command error. I think it's because the OP of the options reading code forgot to add subcommands to the --graphics_command argument, which would be needed to collect whatever comes after --graphics_command. This is a bigger issue than I thought, so I'll continue this convo in Issue --graphics command doesn't seem to work #2001 ). This can be fixed in a seperate PR after this PR lands.
  • Buttons on the GUI were pressed and tested for expected behaviour.

@github-actions github-actions bot added the VPR VPR FPGA Placement & Routing Tool label Jun 2, 2022
Copy link
Contributor

@vaughnbetz vaughnbetz left a comment

Choose a reason for hiding this comment

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

Nice refactoring; I have some further suggestions though.

@@ -0,0 +1,65 @@
#Packing pin usage report
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this file accidentally added? It looks like an output file that shouldn't go in the repo.

@@ -34,6 +34,13 @@
#include "globals.h"
#include "draw_color.h"
#include "draw.h"
#include "draw_basic.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be good to add to the top-level comment at the top of this file: say what kinds of functions should go in this file (or say put new functions in helper files if at all possible).

* could be caused by the user clicking on a routing resource, toggled, or
* fan-in/fan-out of a highlighted node.
*/
bool draw_if_net_highlighted(ClusterNetId inet) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If there is no corresponding comment for this function in the .h file, duplicate or summarize this comment there (we're moving toward commenting what a function does in the .h file, and how it works in the .cpp file if necessary).

//Returns the set of rr nodes which connect driver to sink
static std::vector<int> trace_routed_connection_rr_nodes(
std::vector<int> trace_routed_connection_rr_nodes(
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate this comment (or move it) in the .h file.

@@ -3787,7 +944,7 @@ bool trace_routed_connection_rr_nodes_recurr(const t_rt_node* rt_node,
}

//Find the edge between two rr nodes
static t_edge_size find_edge(int prev_inode, int inode) {
t_edge_size find_edge(int prev_inode, int inode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate this comment in the .h file

# include "place_macro.h"
# include "buttons.h"

void toggle_nets(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy or move "what function does" comments from .cpp to the .h file where you can.

@@ -0,0 +1,122 @@
/* draw_triangle.cpp contains functions that draw triangles.*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you say what they are used for?

Copy link
Contributor

Choose a reason for hiding this comment

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

(They are generally used for showing switching in the routing, the direction of signals, and such.)

# include "place_macro.h"
# include "buttons.h"

void draw_triangle_along_line(ezgl::renderer* g, ezgl::point2d start, ezgl::point2d end, float relative_position = 1., float arrow_size = DEFAULT_ARROW_SIZE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Move function-level comments from .cpp file to here (the how to call and what do I do part).

@@ -163,6 +163,9 @@ typedef struct {
* save_graphics_file_base: Base of save graphis file name (i.e. before extension)
* pres_fac: present congestion cost factor
*/
/* Note: t_draw_struct is used in the same way as a Context, but cannot be a Context because Contexts are
* not copyable, while t_draw_struct must be.
Copy link
Contributor

Choose a reason for hiding this comment

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

Say why it must be copied; graphics commands feature uses that to do save an restore of the drawing state.

@@ -0,0 +1,571 @@
/*draw_xtoy.cpp contains all functions that draw lines from one point to another.*/
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rename this file. I initially read it as being a "toy". It is really drawing the edges between routing resource (rr) nodes, so a better name would be
draw_rr_edges.cpp

Copy link
Contributor

@vaughnbetz vaughnbetz left a comment

Choose a reason for hiding this comment

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

Changes look good so merging. One nit on adding a space after /* and before */ in one spot at least.

@@ -0,0 +1,133 @@
/*draw_mux.cpp contains all functions that draw muxes.*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Small nit, but good to add these spaces ...

@vaughnbetz vaughnbetz merged commit ba52c3a into master Jun 9, 2022
@vaughnbetz vaughnbetz deleted the draw_refactor branch June 9, 2022 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VPR VPR FPGA Placement & Routing Tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants