Skip to content

RRGraphView rr_segments() Implementation #1910

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 3 commits into from
Dec 2, 2021
Merged

RRGraphView rr_segments() Implementation #1910

merged 3 commits into from
Dec 2, 2021

Conversation

umariqbal-rs
Copy link
Contributor

@umariqbal-rs umariqbal-rs commented Nov 10, 2021

Description

In this PR, I am implementing RRGraphView::rr_segments(PRSegmentId Seg_Id ) throughout VTR. Every time device_ctx.rr_segment[Seg_Id] was called has been replaced with rr_graph.rr_segment(Seg_Id). In order to do this, I followed a pattern similar to that in the last PR.

Related Issue

Motivation and Context

These changes are a continuation of the RRGraphView API implementation effort.

How Has This Been Tested?

  • All vtr basic and strong tests are passing.

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

@github-actions github-actions bot added the VPR VPR FPGA Placement & Routing Tool label Nov 10, 2021
@umariqbal-rs
Copy link
Contributor Author

umariqbal-rs commented Nov 10, 2021

@tangxifan
I have added RRSegmentId

const vtr::vector<RRSegmentId, t_segment_inf>& segment_inf,

But I got following errors.
image

I think we also need to add it in line line 1874

const std::vector<t_segment_inf>& segment_inf_;

but when find the call hierarchy of segment_inf_; its called in line 1152,1184,1553 and others.
inline int get_segment_id(const t_segment_inf*& segment) final {

which causes me to change in many files, and pass RRSegmentId there.
Can you please review how we will move next?Because I already made changes in a lot of files that didn't worked.

@tangxifan
Copy link
Contributor

@umariqbal-rs If the changes are within the file rr_graph_uxsdcxx_serializer.h, it is o.k.

You may need to change some APIs, where convert the int id to RRSegmentId.
Also

inline const t_segment_inf* add_segments_segment(void*& /*ctx*/, int id) final {

inline int get_segment_id(const t_segment_inf*& segment) final {

For the alloc_and_load_rr_indexed_data(), you may just need to do a data type conversion here (from std::vector to vtr::vector), in order to avoid large code changes

alloc_and_load_rr_indexed_data(
segment_inf_,
*wire_to_rr_ipin_switch_,
base_cost_type_);

@umariqbal-rs
Copy link
Contributor Author

@tangxifan
I have added RRSegmentId in

inline int get_segment_id(const t_segment_inf*& segment) final {

and
return &segment_inf_.at(RRSegmentId(id));

and where it is needed in rr_graph_uxsdcxx_serializer.h
I also done type conversion from std to vtr in
alloc_and_load_rr_indexed_data(
segment_inf_,
*wire_to_rr_ipin_switch_,
base_cost_type_);

this function is declared in rr_graph_indexed_data.cpp
void alloc_and_load_rr_indexed_data(const vtr::vector<RRSegmentId, t_segment_inf>& segment_inf,

when we followup its call hierarchy it needs us to change in many others files and functions.
Although I have changed in where it is needed.
But I want your suggestions how can I avoid these large code changes and avoiding to stuck in last.
Please review it and suggest me how can i move forward.

@tangxifan
Copy link
Contributor

@umariqbal-rs

For the alloc_and_load_rr_indexed_data(), you just do a data type conversion before calling this function (from std::vector to vtr::vector). I suggested not to change the data type of the arguments of the function.
Just like what you did in the vpr/src/route/rr_graph.cpp file.

@umariqbal-rs
Copy link
Contributor Author

umariqbal-rs commented Nov 15, 2021

@tangxifan
I have done what you said above from std to vtr

size_t num_segments = segment_inf_.size();

Is this you suggested me to do?

But still I am having an error
image
In function alloc_and_load_rr_indexed_data() at segment_inf,
‘std::vector<t_segment_inf>’ is an inaccessible base of ‘vtr::vector<vtr::StrongId<rr_segment_id_tag, short int>, t_segment_inf>’.
this is the error I am having.

Can you Please review it and suggest me how to resolve this ?

@tangxifan
Copy link
Contributor

@umariqbal-rs

You need to create a local copy of the segment_inf here

/* Create a temp copy to convert from vtr::vector to std::vector
 * This is required because the ``alloc_and_load_rr_indexed_data()`` function supports only std::vector data type for ``rr_segments``
 * Note that this is a dirty fix (to avoid massive code changes)
 * TODO: The ``alloc_and_load_rr_indexed_data()`` function should embrace ``vtr::vector`` for ``rr_segments``
 */
std::vector<RRSegmentId, t_segment_inf> temp_rr_segs;
rr_seg.reserve(segment_inf_.size());
for (const auto& temp_rr_seg : temp_rr_segs) {
  rr_seg.push_back(temp_rr_seg);
}
alloc_and_load_rr_indexed_data(
            temp_rr_segs,
            *wire_to_rr_ipin_switch_,
            base_cost_type_);

@tangxifan
Copy link
Contributor

@umariqbal-rs please also resolve merging conflicts.

@github-actions github-actions bot added the libarchfpga Library for handling FPGA Architecture descriptions label Nov 16, 2021
@umariqbal-rs
Copy link
Contributor Author

umariqbal-rs commented Nov 16, 2021

@tangxifan
I have added what you suggested me to do.

std::vector<RRSegmentId, t_segment_inf> temp_rr_segs;

But I encountered with following errors.
image

no type named ‘value_type’ in ‘struct t_segment_inf’
  rebind<_Tp>::other _Tp_alloc_type;

and

 no members matching ‘std::vector<vtr::StrongId<rr_segment_id_tag, short int>, t_segment_inf>::_Base {aka std::_Vector_base<vtr::StrongId<rr_segment_id_tag, short int>, t_segment_inf>}::_M_get_Tp_allocator’ in ‘std::vector<vtr::StrongId<rr_segment_id_tag, short int>, t_segment_inf>::_Base’ {aka ‘struct std::_Vector_base<vtr::StrongId<rr_segment_id_tag, short int>, t_segment_inf>’}
       using _Base::_M_get_Tp_allocator;

Can you Please review it and suggest me how can we move forward.

@tangxifan
Copy link
Contributor

@umariqbal-rs Sorry for the typo. It should be std::vector<t_segment_inf>

@tangxifan
Copy link
Contributor

@umariqbal-rs I see errors in read_rr_graph. Please double check in the rr_graph_reader.cpp files if you have fill the rr_segments correctly.

@umariqbal-rs
Copy link
Contributor Author

@tangxifan
I have checked it .
This is you suggested me to replace
this line
//device_ctx.rr_segments = segment_inf;
with this

    size_t num_segments = segment_inf.size();
    device_ctx.rr_segments.reserve(num_segments);
    for (long unsigned int iseg = 0; iseg < num_segments; ++iseg) {
    	device_ctx.rr_segments.push_back(segment_inf[iseg]);
    }

size_t num_segments = segment_inf.size();

can you Please review it is anything i did wrong?

@tangxifan
Copy link
Contributor

@umariqbal-rs I think it is because we did not clear the device_ctx.rr_segments before reserve.

Can you add it to this file

device_ctx.rr_segments.clear();

device_ctx.rr_switch_inf.clear();

@umariqbal-rs
Copy link
Contributor Author

tangxifan
I have changed avove what you mentioned to do but still issues in Unit Tests and R Strong test.
I think issue is in rr_graph_reader.cpp.
Here are changes I did in rr_graph_reader.cpp.
vtr::vector<RRSegmentId, t_segment_inf> temp_segment_inf;
I created a temporary vtr::vector copy with RRSegmentId, because we need to assign it to device_ctx.rr_segments = temp_segment_inf;
https://github.com/RapidSilicon/vtr-verilog-to-routing/actions/runs/1471678377

Can you Please review and suggest me how can we move forward.

@umariqbal-rs umariqbal-rs marked this pull request as ready for review November 19, 2021 07:03
@github-actions github-actions bot removed the libarchfpga Library for handling FPGA Architecture descriptions label Nov 24, 2021
@umariqbal-rs
Copy link
Contributor Author

umariqbal-rs commented Nov 29, 2021

QoR tests are complete and quick summary is given below. QoR comparison files are also attached.
vtr_reg_qor_chain_depop test
Flow run time -1.48% on average.
critical path delay 0% on average.
Peak memory usage -0.02% on average
vtr_reg_qor_chain_depop_comp.xlsx

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.

@umariqbal-rs Minor changes required. It looks o.k.

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.

Looks o.k. to me. Some minor changes required but we can do it in a follow-up PR.

@umariqbal-rs
Copy link
Contributor Author

umariqbal-rs commented Dec 1, 2021

QoR tests are complete and quick summary is given below. QoR comparison files are also attached.
vtr_reg_qor_chain_depop test
Flow run time 1% on average.
critical path delay 0% on average.
Peak memory usage 0.42% on average
titan_quick_qor test:
flow run time 0.76% on average.
critical path delay 0% on average.
Peak memory usage 0.01% on average
titan_quick_qor.xlsx
vtr_reg_qor_chain_depop_comp.xlsx

@tangxifan
Copy link
Contributor

@umariqbal-rs Look good. I propose to merge now. Remember to create a follow-up PR to correct the comments.
@vaughnbetz If you see any issue, just flag it. We will follow up.


inline const t_segment_inf& rr_segments(RRSegmentId seg_id) const {
Copy link
Contributor

Choose a reason for hiding this comment

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

From @vaughnbetz: in future, we should think about more high-level API, e.g.,
seg_timing()
seg_delay()
seg_length()

@tangxifan
Copy link
Contributor

@umariqbal-rs I have discussed with @vaughnbetz today this PR. We have the green light to merge.
However, we have a follow-up PR to create, which should do the following task

  • Fix the bug on the code comments (as I pointed out in code review)
  • Remove the rr_segments from DeviceContext. Since we have updated all the client functions, we can safely remove it from DeviceContext. It will avoid confusing developers and keep the idea clear: RRGraphView should be the only data structure to store any routing-resource -related data.

Let me know what you think.

@tangxifan tangxifan merged commit d79f7db into verilog-to-routing:master Dec 2, 2021
@tangxifan tangxifan deleted the api_rr_segments_graphview branch December 2, 2021 19:08
@umariqbal-rs
Copy link
Contributor Author

OK sure. I am currently working on edge_switch() .we will follow rr_segments along with edge_swtich and edge_sink_node().
Is that fine ?

@tangxifan
Copy link
Contributor

@umariqbal-rs I do not suggest to do so. It may increase your debugging complexity. But I am open. If you do not see any challenge, we can go in this way.

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