Skip to content

Move rr_graph_reader & rr_graph_writer to librrgraph. #2101

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 25 commits into from
Aug 11, 2022

Conversation

oscarcheng105
Copy link
Contributor

@oscarcheng105 oscarcheng105 commented Jul 21, 2022

Description

In this PR rr_graph_reader and rr_graph_writer from vpr/src/route are moved to librrgraph. We also avoid dependencies from vpr and try moving the vpr dependencies to the according libraries.

MOVED/ADDED FILES

  1. The following Files/DataStructures/Functions from vpr are moved/added to librrgraph to avoid vpr dependencies:
  • rr_graph_reader.h/.cpp
  • rr_graph_writer.h/.cpp
  • rr_graph_uxsdcxx_serializer.h
  • uxsdcxx generator
  • rr_graph.xsd
  • rr_metadata.h/.cpp
  • rr_rc_data.h/.cpp
  • check_rr_graph.h/.cpp
  • rr_graph_utils.h/.cpp
  • rr_graph_storage_utils.h
  • describe_rr_node.h/.cpp
  • get_parallel_segs.h/.cpp
  • alloc_and_load_rr_indexed_data.h/.cpp
  1. The following Files/Data-structures/Functions from vpr are moved/added to libarchfpga to avoid vpr dependencies:
  • device_grid.h/.cpp
  • histogram.h/.cpp
  • graph_type.h
  • chan_width.h
  • route_type.h
  • cost_indices.h
  • base_cost_type.h
  • unified_to_parallel_seg_index.h
  1. The following Files/DataStructures/Functions from vpr are moved to libvtrutil to avoid vpr dependencies:
  • vpr_error.h/.cpp

MAJOR CODE CHANGES

  1. The parameters of the following functions are modified. Data Structures in DeviceContext are now passed in directly as parameters to avoid dependency on DeviceContext (VprContext):
  • load_rr_file
  • write_rr_graph
  • rr_node_metadata
  • rr_edge_metadata
  • add_rr_node_metadata
  • add_rr_edge_metadata
  • find_create_rr_rc_data
  • check_rr_graph
  • check_rr_node
  • describe_rr_node
  • alloc_and_load_rr_indexed_data

*Parameters of subroutines local to the module are also changed accordingly regarding the parameter change from above.

  1. The following private variables are added to data structures in rr_graph_uxsdcxx_serializer.h to accommodate the parameter changes:
  • std::vector<t_rr_rc_data>* rr_rc_data added to RrGraphSerializer
  • const int virtual_clock_network_root_idx added to RrGraphSerializer
  • const bool echo_enabled added to RrGraphSerializer
  • const char* echo_file_name added to RrGraphSerializer
  • MetadataStorage<int>* rr_node_metadata_ added to MetadataBind
  • MetadataStorage<std::tuple<int, int, short>>* rr_edge_metadata_ added to MetadataBind
  1. Declaration of the following Data-structures/Functions are removed from vpr, re-declared in the according library, and made as dependency again to files in vpr that reference them:
  • DeviceGrid removed from vpr/src/route, moved to libarchfpga
  • histogram removed from vpr/src/util, moved to libarchfpga
  • t_unified_to_parallel_seg_index removed from rr_graph2.h, moved to libarchfpga
  • get_parallel_segs removed from rr_graph2.h, moved to libarchfpga
  • e_route_type removed from vpr_types.h, moved to libarchfpga
  • e_base_cost_type removed from vpr_types.h, moved to libarchfpga
  • e_cost_indices removed from vpr_types.h, moved to libarchfpga
  • t_chan_width removed from vpr_types.h, moved to libarchfpga
  • describe_rr_node removed from rr_graph.h, moved to librrgraph
  • alloc_and_load_rr_indexed_data removed from rr_graph_indexed_data.h, moved to librrgraph
  • e_graph_type (aka t_graph_type) removed from rr_graph.h, moved to librrgraph
  • rr_graph_util (vpr/src/route) merged to librrgraph

OTHER CODE CHANGE

  1. VTR_ENABLE_CAPNPROTO added to librrgraph/CMakeLists.txt

  2. generate_rr_graph_serializers moved from vpr/CMakeLists.txt to `librrgraph/CMakeLists.txt

UPDATES

  1. Files in Librrgraph are categorized into three folders:
  • io for files regarding read/write purposes.
  • utils for utility functions.
  • base for rest of the files in librrgraph.
  1. The following data structures are combined into rr_graph_type.h (librrgraph/base) for builder/general usage:
  • e_graph_type in graph_type.h
  • e_route_type in route_type.h
  • t_chan_width in chan_width.h
  • t_unified_to_parallel_seg_index.h in unified_to_parallel_seg_index.h
  1. The following data structures are combined into rr_graph_cost.h (librrgraph/base) for router usage:
  • e_base_cost_type in base_cost_type.h
  • e_cost_indices in cost_indices.h

Related Issue

Motivation and Context

As devised by the mentor #2000

How Has This Been Tested?

The changes passed the two regression tests vtr_reg_basic and vtr_reg_strong.

Types of changes

  • Bug fix (change which fixes an issue)
  • New feature (change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

@oscarcheng105 oscarcheng105 requested a review from tangxifan July 21, 2022 00:12
@github-actions github-actions bot added libarchfpga Library for handling FPGA Architecture descriptions libvtrutil VPR VPR FPGA Placement & Routing Tool labels Jul 21, 2022
@tangxifan
Copy link
Contributor

tangxifan commented Jul 21, 2022

Notes

  • doc build is already failling on the current master. This PR has no touch on doc.
  • There are 6.5k lines of code changes but most of them are moving the files around. Note that all the files under vpr/src/route/gen are auto generated which contain 6k lines of codes. Actual code changes are small

@tangxifan
Copy link
Contributor

tangxifan commented Jul 21, 2022

Todo list on this PR:

@tangxifan
Copy link
Contributor

@tangxifan
Copy link
Contributor

Memo @oscarcheng105

@vaughnbetz
Copy link
Contributor

Needs a make format.

Copy link
Contributor

@tangxifan tangxifan left a comment

Choose a reason for hiding this comment

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

@oscarcheng105 Just some comments to categorize source files.
Also, to group header files, we need your information about what are the client functions of these data types/structures.
There are five major clients of RRGraph:

  • Placer
  • Router
  • routing resource graph builder
  • GUI (drawer)
  • Timing analyzer

Suggest to follow this thread to group headers. We can go through them one by one, once you can provide details.

NOTES

  1. The following is a list of files that references the migrated data-structures mentioned previously:

    e_graph_type/t_graph_type in graph_type.h

    • First Layer
      • rr_graph_uxsdcxx_serializer.h (librrgraph)
      • rr_graph_reader.h (librrgraph)
      • check_rr_graph_.h (librrgraph)
      • rr_graph.h (vpr/src/route)
    • Second Layer
      • rr_graph_uxsdcxx_serializer.h -> rr_graph_writer.h (librrgraph)
      • rr_graph.h -> place_and_route.h (vpr/src/base)
      • rr_graph.h -> vpr_api.cpp (vpr/src/base)
      • rr_graph.h -> route_common.cpp (vpr/src/route)
      • rr_graph.h -> router_delay_profiling.cpp (vpr/src/route)
      • rr_graph.h -> time_place_lookup.cpp (vpr/src/place)
      • rr_graph.h -> main.cpp (utils/route_diag/src)
    • Third Layer
      • place_and_route.cpp -> place.cpp (vpr/src/place)
      • place_and_route.cpp -> test_connection_router.cpp (vpr/test)

    t_unified_to_parallel_seg_index in unified_to_parallel_seg_index.h

    • First Layer
      • get_parallel_segs.h (librrgraph)
      • rr_graph_uxsdcxx_serializer.h (librrgraph)
      • rr_graph2.h (vpr/src/route)
    • Second Layer
      • rr_graph2.h -> clock_network_builders.h (vpr/src/route)
      • rr_graph2.h -> rr_graph.cpp (vpr/src/route)
    • Third Layer
      • clock_network_builders.h -> rr_graph_clock.h (vpr/src/route)

    e_route_type in route_type.h

    • First Layer
      • check_rr_graph.h (librrgraph)
      • vpr_types.h (vpr/src/base)
    • Second Layer
      • vpr_types.h -> read_options.h (vpr/src/base)
      • vpr_types.h -> stats.cpp (vpr/src/base)
      • vpr_types.h -> check_route.cpp (vpr/src/route)
      • vpr_types.h -> draw_types.h (vpr/src/draw)
    • Fourth Layer
      • draw_types.h -> draw_global -> draw.h (vpr/src/draw)

    e_base_cost_type in base_cost_type.h

    • First Layer
      • rr_graph_reader.h (librrgraph)
      • rr_graph_uxsdcxx_serializer.h (librrgraph)
      • vpr_types.h (vpr/src/base)
    • Second Layer
      • rr_graph_uxsdcxx_serializer.h -> rr_graph_writer.h (librrgraph)
      • vpr_types.h -> read_options.h (vpr/src/base)
      • vpr_types.h -> rr_graph.cpp (vpr/src/route)
      • vpr_types.h -> rr_graph_indexed_data.cpp (vpr/src/route)

    e_cost_indices in cost_indices.h

    • First Layer
      • rr_graph_uxsdcxx_serializer.h (librrgraph)
      • vpr_types.h (vpr/src/base)
    • Second Layer
      • vpr_types.h -> rr_graph.h (vpr/src/route)
      • vpr_types.h -> rr_graph_indexed_data.cpp (vpr/src/route)
      • vpr_types.h -> router_lookahead_map.cpp (vpr/src/route)
      • vpr_types.h -> router_lookahead.h (vpr/src/route)
      • vpr_types.h -> route_timing.h (vpr/src/route)
    • Third Layer
      • rr_graph.h -> router_lookahead_extended_map.cpp (vpr/src/route)
    • Fourth Layer
      • vpr_types.h -> rr_graph2.h -> clock_connection_builders.cpp (vpr/src/route)

    t_chan_width in chan_width.h

    • First Layer
      • check_rr_graph.h (librrgrpah)
      • rr_graph_reader.h (librrgraph)
      • rr_graph_writer.h (librrgraph)
      • rr_graph_uxsdcxx_serializer.h (librrgraph)
      • vpr_types.h (vpr/src/base)
    • Second Layer
      • vpr_types.h -> place_and_route.h (vpr/src/base)
      • vpr_types.h -> vpr_api.h (vpr/src/base)
      • vpr_types.h -> vpr_context.h (vpr/srce/base)
      • vpr_types.h -> timing_place_lookup.cpp (vpr/src/place)
      • vpr_types.h -> build_switchblocks.h (vpr/src/route)
      • vpr_types.h -> cb_metrics.cpp (vpr/src/route)
      • vpr_types.h -> route_common.cpp (vpr/src/route)
      • vpr_types.h -> router_delay_profiling.h (vpr/src/route)
      • vpr_types.h -> rr_graph.h (vpr/src/route)
      • vpr_types.h -> rr_graph2.cpp (vpr/src/route)
      • vpr_types.h -> rr_graph_sbox.cpp (vpr/src/route)
    • Third Layer
      • rr_graph.h -> rr_graph_clock.cpp (vpr/src/route)
    • Fourth Layer
      • rr_graph.h -> main.cpp (utils/route_diag/src)

@vaughnbetz vaughnbetz requested a review from acomodi July 28, 2022 17:49
@vaughnbetz
Copy link
Contributor

@acomodi: we suggest you review this in case it interacts with the interchange format; also a big restructuring so worth reviewing in any case.

@vaughnbetz
Copy link
Contributor

vaughnbetz commented Jul 28, 2022

To do: please add vtr and titan QoR data to sh[ow no degradations in runtime, or unexpected QoR changes. See the developer guide and check both the vtr and titan benchmarks.

@tangxifan
Copy link
Contributor

@oscarcheng105

Templates to provide QoR test summary: #1972 (comment)

Documentation about test: https://docs.verilogtorouting.org/en/latest/README.developers/#tests

@oscarcheng105
Copy link
Contributor Author

@vaughnbetz @tangxifan
QoR tests are completed with Master and Feature Branch and quick summary is given below. QoR comparison files are also attached.
vtr_reg_qor_chain_depop test:
Flow run time 0.37% on average.
critical path delay 0% on average.
Peak memory usage -0.03% on average.
titan_quick_qor test:
flow run time 0.11% on average.
critical path delay 0% on average.
Peak memory usage 0% on average.
vtr_reg_qor_chain_depop.xlsx
titan_quick_qor_master.xlsx


static bool has_adjacent_channel(const t_rr_node& node, const DeviceGrid& grid);
static bool has_adjacent_channel(const RRGraphView& rr_graph, const DeviceGrid& grid, const t_rr_node& node);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a mark here. This function need a refactoring. We should use RRNodeId rather than t_rr_node which is now an internal data of RRGraph

@@ -494,13 +497,13 @@ void check_rr_node(int inode, enum e_route_type route_type, const DeviceContext&
//Don't worry about disconnect PINs which have no adjacent channels (i.e. on the device perimeter)
bool check_for_out_edges = true;
if (rr_type == IPIN || rr_type == OPIN) {
if (!has_adjacent_channel(rr_graph.rr_nodes()[inode], device_ctx.grid)) {
if (!has_adjacent_channel(rr_graph, grid, rr_graph.rr_nodes()[inode])) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a mark, rr_nodes() just expose the internal node storage directly to client function, which should be avoid. I suggest to rework this function later.

/** @brief Return the node-level storage structure for queries from client functions */
inline const t_rr_graph_storage& rr_nodes() const {
return node_storage_;
}

@@ -138,9 +138,11 @@ void search_and_highlight(GtkWidget* /*widget*/, ezgl::application* app) {
bool highlight_rr_nodes(int hit_node) {
t_draw_state* draw_state = get_draw_state_vars();

//TODO: fixed sized char array may cause overflow.
Copy link
Contributor

Choose a reason for hiding this comment

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

@vaughnbetz I am not sure why there is a fixed-length message string here. But it looks dangerous to me. Just a reminder here. See if you do need to fix it.

Copy link
Contributor

@tangxifan tangxifan left a comment

Choose a reason for hiding this comment

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

LGTM

@vaughnbetz : I have gone through another round of code view. I am satisfied with the code changes. QoR results have been uploaded as well, showing almost zero overhead on critical metric. Waiting for your decision.

@vaughnbetz vaughnbetz merged commit 3afe583 into verilog-to-routing:master Aug 11, 2022
@vaughnbetz
Copy link
Contributor

Thanks! Merged.

@oscarcheng105 oscarcheng105 mentioned this pull request Sep 2, 2022
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libarchfpga Library for handling FPGA Architecture descriptions libvtrutil VPR VPR FPGA Placement & Routing Tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants