@@ -417,11 +417,12 @@ bool is_legal_swap_to_location(ClusterBlockId blk, t_pl_loc to) {
417
417
// (neccessarily) translationally invariant for an arbitrary macro
418
418
419
419
auto & device_ctx = g_vpr_ctx.device ();
420
+ auto & cluster_ctx = g_vpr_ctx.clustering ();
420
421
421
422
if (to.x < 0 || to.x >= int (device_ctx.grid .width ())
422
423
|| to.y < 0 || to.y >= int (device_ctx.grid .height ())
423
424
|| to.z < 0 || to.z >= device_ctx.grid [to.x ][to.y ].type ->capacity
424
- || (device_ctx.grid [to.x ][to.y ].type != physical_tile_type (blk))) {
425
+ || ! is_tile_compatible (device_ctx.grid [to.x ][to.y ].type , cluster_ctx. clb_nlist . block_type (blk))) {
425
426
return false ;
426
427
}
427
428
return true ;
@@ -482,7 +483,7 @@ ClusterBlockId pick_from_block() {
482
483
return ClusterBlockId::INVALID ();
483
484
}
484
485
485
- bool find_to_loc_uniform (t_physical_tile_type_ptr type,
486
+ bool find_to_loc_uniform (t_logical_block_type_ptr type,
486
487
float rlim,
487
488
const t_pl_loc from,
488
489
t_pl_loc& to) {
@@ -495,29 +496,25 @@ bool find_to_loc_uniform(t_physical_tile_type_ptr type,
495
496
//
496
497
// This ensures that such blocks don't get locked down too early during placement (as would be the
497
498
// case with a physical distance rlim)
498
- auto & grid = g_vpr_ctx.device ().grid ;
499
-
500
- auto from_type = grid[from.x ][from.y ].type ;
501
499
502
500
// Retrieve the compressed block grid for this block type
503
- const auto & to_compressed_block_grid = g_vpr_ctx.placement ().compressed_block_grids [type->index ];
504
- const auto & from_compressed_block_grid = g_vpr_ctx.placement ().compressed_block_grids [from_type->index ];
501
+ const auto & compressed_block_grid = g_vpr_ctx.placement ().compressed_block_grids [type->index ];
505
502
506
503
// Determine the rlim in each dimension
507
- int rlim_x = std::min<int >(to_compressed_block_grid .compressed_to_grid_x .size (), rlim);
508
- int rlim_y = std::min<int >(to_compressed_block_grid .compressed_to_grid_y .size (), rlim); /* for aspect_ratio != 1 case. */
504
+ int rlim_x = std::min<int >(compressed_block_grid .compressed_to_grid_x .size (), rlim);
505
+ int rlim_y = std::min<int >(compressed_block_grid .compressed_to_grid_y .size (), rlim); /* for aspect_ratio != 1 case. */
509
506
510
507
// Determine the coordinates in the compressed grid space of the current block
511
- int cx_from = grid_to_compressed (from_compressed_block_grid .compressed_to_grid_x , from.x );
512
- int cy_from = grid_to_compressed (from_compressed_block_grid .compressed_to_grid_y , from.y );
508
+ int cx_from = grid_to_compressed (compressed_block_grid .compressed_to_grid_x , from.x );
509
+ int cy_from = grid_to_compressed (compressed_block_grid .compressed_to_grid_y , from.y );
513
510
514
511
// Determine the valid compressed grid location ranges
515
512
int min_cx = std::max (0 , cx_from - rlim_x);
516
- int max_cx = std::min<int >(to_compressed_block_grid .compressed_to_grid_x .size () - 1 , cx_from + rlim_x);
513
+ int max_cx = std::min<int >(compressed_block_grid .compressed_to_grid_x .size () - 1 , cx_from + rlim_x);
517
514
int delta_cx = max_cx - min_cx;
518
515
519
516
int min_cy = std::max (0 , cy_from - rlim_y);
520
- int max_cy = std::min<int >(to_compressed_block_grid .compressed_to_grid_y .size () - 1 , cy_from + rlim_y);
517
+ int max_cy = std::min<int >(compressed_block_grid .compressed_to_grid_y .size () - 1 , cy_from + rlim_y);
521
518
522
519
int cx_to = OPEN;
523
520
int cy_to = OPEN;
@@ -544,19 +541,19 @@ bool find_to_loc_uniform(t_physical_tile_type_ptr type,
544
541
//
545
542
// The candidates are stored in a flat_map so we can efficiently find the set of valid
546
543
// candidates with upper/lower bound.
547
- auto y_lower_iter = to_compressed_block_grid .grid [cx_to].lower_bound (min_cy);
548
- if (y_lower_iter == to_compressed_block_grid .grid [cx_to].end ()) {
544
+ auto y_lower_iter = compressed_block_grid .grid [cx_to].lower_bound (min_cy);
545
+ if (y_lower_iter == compressed_block_grid .grid [cx_to].end ()) {
549
546
continue ;
550
547
}
551
548
552
- auto y_upper_iter = to_compressed_block_grid .grid [cx_to].upper_bound (max_cy);
549
+ auto y_upper_iter = compressed_block_grid .grid [cx_to].upper_bound (max_cy);
553
550
554
551
if (y_lower_iter->first > min_cy) {
555
552
// No valid blocks at this x location which are within rlim_y
556
553
//
557
554
// Fall back to allow the whole y range
558
- y_lower_iter = to_compressed_block_grid .grid [cx_to].begin ();
559
- y_upper_iter = to_compressed_block_grid .grid [cx_to].end ();
555
+ y_lower_iter = compressed_block_grid .grid [cx_to].begin ();
556
+ y_upper_iter = compressed_block_grid .grid [cx_to].end ();
560
557
561
558
min_cy = y_lower_iter->first ;
562
559
max_cy = (y_upper_iter - 1 )->first ;
@@ -588,33 +585,7 @@ bool find_to_loc_uniform(t_physical_tile_type_ptr type,
588
585
if (cx_from == cx_to && cy_from == cy_to) {
589
586
continue ; // Same from/to location -- try again for new y-position
590
587
} else {
591
- VTR_ASSERT (cx_to != OPEN);
592
- VTR_ASSERT (cy_to != OPEN);
593
-
594
- // Convert to true (uncompressed) grid locations
595
- to.x = to_compressed_block_grid.compressed_to_grid_x [cx_to];
596
- to.y = to_compressed_block_grid.compressed_to_grid_y [cy_to];
597
-
598
- auto & place_ctx = g_vpr_ctx.placement ();
599
- auto & cluster_ctx = g_vpr_ctx.clustering ();
600
-
601
- auto blocks = place_ctx.grid_blocks [to.x ][to.y ].blocks ;
602
- bool impossible_swap = false ;
603
- for (auto blk : blocks) {
604
- if (blk == ClusterBlockId::INVALID ()) {
605
- continue ;
606
- }
607
-
608
- auto block_type = cluster_ctx.clb_nlist .block_type (blk);
609
- if (!is_tile_compatible (from_type, block_type)) {
610
- impossible_swap = true ;
611
- break ;
612
- }
613
- }
614
-
615
- if (!impossible_swap) {
616
- legal = true ;
617
- }
588
+ legal = true ;
618
589
}
619
590
}
620
591
}
@@ -624,11 +595,22 @@ bool find_to_loc_uniform(t_physical_tile_type_ptr type,
624
595
return false ;
625
596
}
626
597
598
+ VTR_ASSERT (cx_to != OPEN);
599
+ VTR_ASSERT (cy_to != OPEN);
600
+
601
+ // Convert to true (uncompressed) grid locations
602
+ to.x = compressed_block_grid.compressed_to_grid_x [cx_to];
603
+ to.y = compressed_block_grid.compressed_to_grid_y [cy_to];
604
+
605
+ auto & grid = g_vpr_ctx.device ().grid ;
606
+
607
+ auto to_type = grid[to.x ][to.y ].type ;
608
+
627
609
// Each x/y location contains only a single type, so we can pick a random
628
610
// z (capcity) location
629
- to.z = vtr::irand (type ->capacity - 1 );
611
+ to.z = vtr::irand (to_type ->capacity - 1 );
630
612
631
- VTR_ASSERT_MSG (grid[to. x ][to. y ]. type == type, " Type must match " );
613
+ VTR_ASSERT_MSG (is_tile_compatible (to_type, type) , " Type must be compatible " );
632
614
VTR_ASSERT_MSG (grid[to.x ][to.y ].width_offset == 0 , " Should be at block base location" );
633
615
VTR_ASSERT_MSG (grid[to.x ][to.y ].height_offset == 0 , " Should be at block base location" );
634
616
0 commit comments