Skip to content
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

Fix fixed clusters issue #2495

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Conversation

soheilshahrouz
Copy link
Contributor

Description

When a large number of clustered blocks are fixed, placement takes a very long time. This is because for picking a random block, we exhaust all blocks until we find a movable block. If most clustered blocks are fixed, it would take a long time to exhaust fixed blocks by random selection. This PR stores movable blocks in a vtr::vector so that a movable random block can be selected more quickly. It also makes reading the placement file more robust.

Related Issue

Issue 2484

How Has This Been Tested?

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 VPR VPR FPGA Placement & Routing Tool lang-cpp C/C++ code labels Feb 27, 2024
@soheilshahrouz
Copy link
Contributor Author

Link to QoR results for Titan benchmarks. They are the same as master.

@vaughnbetz
Copy link
Contributor

  1. @soheilshahrouz tells me there is a bug to fix.
  2. Please add a comparison to master (normalize results to master)
  3. Check runtime / QoR on the original issue and summarize the result.

vpr/src/base/vpr_context.h Show resolved Hide resolved
vpr/src/place/initial_placement.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot added the libarchfpga Library for handling FPGA Architecture descriptions label Apr 17, 2024
@soheilshahrouz
Copy link
Contributor Author

@vaughnbetz
I applied your comments. Ready for review.

@vaughnbetz
Copy link
Contributor

Please summarize the relative runtime, cpd, wirelength etc. of the master vs. this fix.
Please run the original issue and post the new runtime.
I also have a few suggestions on the code; happy to have a zoom meeting if you'd like to discuss.

@soheilshahrouz
Copy link
Contributor Author

branch Place time Place WL Place CPD
this PR 0.992 1.00 1.00
master 1.000 1.00 1.00

@vaughnbetz
Copy link
Contributor

Issue runtime: was a few days, now is less than 5 min so it is fixed.

@@ -126,6 +126,8 @@ ClusterBlockId propose_block_to_move(const t_placer_opts& placer_opts,
ClusterNetId* net_from,
int* pin_from);

const std::vector<ClusterBlockId>& movable_blocks_per_type(const t_logical_block_type& blk_type);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a doxygen comment for this routine.

}

std::unordered_set<ClusterBlockId> tried_from_blocks;
auto found_blocks = place_ctx.movable_blocks_per_type.find(logical_blk_type_index);
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like we should store movable_blocks_per_type in a vector instead of an unordered_map for speed.

auto& place_ctx = g_vpr_ctx.mutable_placement();
const std::vector<ClusterBlockId>& movable_blocks_per_type(const t_logical_block_type& blk_type) {
// empty vector is declared static to avoid re-allocation every time the function is called
static std::vector<ClusterBlockId> empty_vector;
Copy link
Contributor

Choose a reason for hiding this comment

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

the load_movable_blocks_per_type function could instead just load a vector for each block type in the netlist (movable_blocks_per_type) and return that vector. Types with no movable blocks would just return an empty vector that way (naturally, without special ifs and static varaibles).

That seems simpler, and if we use a vector of vectors like that it might be faster. I suggest switching to that style.

@vaughnbetz
Copy link
Contributor

@soheilshahrouz : need to resolve a conflict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang-cpp C/C++ code libarchfpga Library for handling FPGA Architecture descriptions VPR VPR FPGA Placement & Routing Tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants