Skip to content

[Place] Expand search range for sparse blocks #2960

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

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

Conversation

amin1377
Copy link
Contributor

@amin1377 amin1377 commented Apr 1, 2025

This PR addresses Issue #2959. The solution to fix the problem is a bit different from the one stated there, though. To ensure moving sparse blocks (e.g., IO blocks), we expand the search range to include the whole column if the number of compatible blocks in the given column is less than a certain threshold (currently, this number is set to 3)

The above update changed the placement of the top picture to the placement of the bottom one (where there is only one IO block left on the top).
Screenshot 2025-04-01 151404


Screenshot 2025-04-01 150305

@github-actions github-actions bot added VPR VPR FPGA Placement & Routing Tool lang-cpp C/C++ code labels Apr 1, 2025
@amin1377 amin1377 requested a review from vaughnbetz April 1, 2025 19:37
Copy link
Contributor

@soheilshahrouz soheilshahrouz left a comment

Choose a reason for hiding this comment

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

I think the implementation can be made more modular by adding another function to modify the search limit instead of modifying when you're searching for a compatibale location.

@soheilshahrouz
Copy link
Contributor

Does the described problem happen only when IO blocks are located at the top/bottom rows? What if they are initially placed at left/right sides of the device?

@amin1377
Copy link
Contributor Author

amin1377 commented Apr 1, 2025

Does the described problem happen only when IO blocks are located at the top/bottom rows? What if they are initially placed at left/right sides of the device?

I'm not entirely sure, but given that the x-axis of the compressed grid is fully dense, I don't think this happens for the x-axis.

@amin1377
Copy link
Contributor Author

amin1377 commented Apr 2, 2025

Does the described problem happen only when IO blocks are located at the top/bottom rows? What if they are initially placed at left/right sides of the device?

I'm not entirely sure, but given that the x-axis of the compressed grid is fully dense, I don't think this happens for the x-axis.

Upon further discussion with @soheilshahrouz, it seems likely that the same issue occurs along the x-axis. So, it would make sense to expand the x-axis range limit if the number of compatible blocks in a given row falls below a certain threshold. Otherwise, there’s a bias toward placing IO blocks on the top and bottom edges rather than on the left and right.

I’ll look into this in a separate PR.

@tpagarani FYI

@amin1377
Copy link
Contributor Author

amin1377 commented Apr 3, 2025

@soheilshahrouz: I’ve addressed all your comments and implemented the changes you requested. Since the code has changed significantly since your last review, I’d appreciate it if you could take another look. Thanks!

@vaughnbetz
Copy link
Contributor

You should add QoR data on a couple of big benchmark suites.

@vaughnbetz
Copy link
Contributor

Also summarize the QoR-related regtest failrues (basic has two failing QoR, but it is because the wirelength improved a lot (45%) on two small circuits which is certainly fine!
I'd run at least one more benchmark suite if Titan shows some degradation, to see if it's real or not. We can accept a degradation and retune if needed but I'd like to understand it.

@vaughnbetz
Copy link
Contributor

Results on 3 seeds show the cpd degradation isn't consistent (the other 2 seeds were fine). I think this is good to merge. Can you also add a link to the 3 seed data here for posterity @amin1377 ?

@vaughnbetz
Copy link
Contributor

It looks like some golden results need to be updated. I looked at the parmys basic failure and it is a single small design that improved too much, so it's not a problem (actually it's good news):
[Fail]
k6_frac_N10_mem32K_40nm.xml/multiclock_separate_and_latch.v/common routed_wirelength relative value 0.4 outside of range [0.6,1.5], above absolute threshold 5.0 and not equal to golden value: 10.0

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.

Some fragile code in there that I think should be changed.

// TODO: Currently this is how we determine whether
// the moving block is of type IO. We need to have a function
// to infer IO type index (similar to what's done for CLBs)
if (block_type->index == 1 && !block_constrained) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't do this.

  1. We have a function to check if a physical tile type is an IO type in physical_type_util.h (is_io_type). You could use that to build a check of whether a logical block type is an IO type (by checking what blocks are compatible with that physical tile). Perhaps we already have such a function; if not we should make one as it is a useful utility. See

    if (is_io_type(type) && pad_loc_type == e_pad_loc_type::RANDOM) {
    for an example of is_io_type.

  2. Some devices have IOs in columns (area IO). You should check what happens on stratix 10, which has column IO, and I think you should test this code on it and make sure it makes sense (I suspect it should be modified or turned off in that case). Possibly you should just change the whole test for whether you do this or not to check a condition on whether the current block type has a perimeter style, and you could precompute a table of which IO types have perimeter style locations with a preprocessing step that looks at the grid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, thanks! I added a function to check for that and am now testing it to make sure it works as expected. I’ll post the results for both SIV and S10 once I have them.

@@ -28,6 +28,51 @@ void set_placer_breakpoint_reached(bool flag) {
f_placer_breakpoint_reached = flag;
}

/**
* @brief Adjust the search range based on the block type and constraints
*
Copy link
Contributor

Choose a reason for hiding this comment

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

Should explain a bit about why and how you adjust the search range.

Copy link
Contributor Author

@amin1377 amin1377 Apr 26, 2025

Choose a reason for hiding this comment

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

Added the following:

* If the block is an IO block, we expand the search range to cover the whole column
 * We found empirically that this is a good strategy for IO blocks, given they are located in
 * the periphery for most FPGA architectures

@vaughnbetz
Copy link
Contributor

@github-actions github-actions bot added the libarchfpga Library for handling FPGA Architecture descriptions label Apr 26, 2025
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.

I'm OK with this if S10 works well, but see my comment on removing the IO check and instead checking for < SPARSE_BLOCK_THRESHOLD (which you could set to 3 or so). Should be a little simpler and more general.

* Given their sparsity, we expand the y-axis search range
* to include all blocks in the column
*/
const t_compressed_block_grid& compressed_block_grid = g_vpr_ctx.placement().compressed_block_grids[block_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.

You could make this code work well for area-IO (e.g. stratix 10 where IOs are in columns) and for other sparse blocks by just checking if the number of blocks in the compressed columns is less than some threshold. I suspect you don't actually need to check if it is an IO block -- IOs are just an example of this kind of pattern.

(I still like the utility to check if a logical block type is an IO though).

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 actually tried that a while ago by not specifying the block type and simply expanding the search range if the number of blocks in the chosen column was less than 3. However, after making that change, in the example I mentioned earlier, we encountered the same issue where the IO blocks became scattered between the top and bottom edges.

@vaughnbetz
Copy link
Contributor

vaughnbetz commented Apr 28, 2025 via email

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.

3 participants