@@ -287,12 +287,12 @@ static void comp_td_costs(const PlaceDelayModel& delay_model, float *timing_cost
287
287
288
288
static e_swap_result assess_swap (float delta_c, float t);
289
289
290
- static bool find_to (t_type_ptr type , float rlim,
290
+ static bool find_to (t_type_ptr from_type, t_type_ptr to_type , float rlim,
291
291
int x_from, int y_from,
292
292
int *px_to, int *py_to, int *pz_to);
293
293
static void find_to_location (t_type_ptr type, float rlim,
294
294
int x_from, int y_from,
295
- int *px_to, int *py_to, int *pz_to);
295
+ int *px_to, int *py_to, int *pz_to, bool is_equivalent );
296
296
297
297
static void get_non_updateable_bb (ClusterNetId net_id, t_bb *bb_coord_new);
298
298
@@ -353,8 +353,6 @@ static void generate_post_place_timing_reports(const t_placer_opts& placer_opts,
353
353
const SetupTimingInfo& timing_info,
354
354
const PlacementDelayCalculator& delay_calc);
355
355
356
- static std::vector<int > get_available_placement_itypes (t_type_ptr type);
357
- static bool check_if_legal_placement (t_type_ptr cluster_type, t_type_ptr grid_type);
358
356
/* ****************************************************************************/
359
357
void try_place (t_placer_opts placer_opts,
360
358
t_annealing_sched annealing_sched,
@@ -1233,6 +1231,8 @@ static int setup_blocks_affected(ClusterBlockId b_from, int x_to, int y_to, int
1233
1231
1234
1232
b_to = place_ctx.grid_blocks [x_to][y_to].blocks [z_to];
1235
1233
1234
+ t_type_ptr cluster_to_type = g_vpr_ctx.clustering ().clb_nlist .block_type (b_to);
1235
+ t_type_ptr grid_from_type = g_vpr_ctx.device ().grid [x_from][y_from].type ;
1236
1236
// Check whether the to_location is empty
1237
1237
if (b_to == EMPTY_BLOCK_ID) {
1238
1238
@@ -1254,7 +1254,7 @@ static int setup_blocks_affected(ClusterBlockId b_from, int x_to, int y_to, int
1254
1254
blocks_affected.moved_blocks [imoved_blk].swapped_from_is_empty = true ;
1255
1255
blocks_affected.num_moved_blocks ++;
1256
1256
1257
- } else if (b_to != INVALID_BLOCK_ID) {
1257
+ } else if (b_to != INVALID_BLOCK_ID && cluster_to_type-> is_available_tile_index (grid_from_type-> index ) ) {
1258
1258
1259
1259
// Does not allow a swap with a macro yet
1260
1260
get_imacro_from_iblk (&imacro, b_to, pl_macros, num_pl_macros);
@@ -1297,7 +1297,10 @@ static int setup_blocks_affected(ClusterBlockId b_from, int x_to, int y_to, int
1297
1297
blocks_affected.moved_blocks [imoved_blk].swapped_from_is_empty = false ;
1298
1298
blocks_affected.num_moved_blocks ++;
1299
1299
1300
- } // Finish swapping the blocks and setting up blocks_affected
1300
+ } else {
1301
+ abort_swap = true ;
1302
+ return (abort_swap);
1303
+ }// Finish swapping the blocks and setting up blocks_affected
1301
1304
1302
1305
return (abort_swap);
1303
1306
@@ -1355,7 +1358,7 @@ static int find_affected_blocks(ClusterBlockId b_from, int x_to, int y_to, int z
1355
1358
if ( curr_x_to < 1 || curr_x_to >= int (device_ctx.grid .width ())
1356
1359
|| curr_y_to < 1 || curr_y_to >= int (device_ctx.grid .height ())
1357
1360
|| curr_z_to < 0
1358
- || device_ctx.grid [curr_x_to][curr_y_to].type != cluster_ctx. clb_nlist . block_type (curr_b_from )) {
1361
+ || !cluster_ctx. clb_nlist . block_type (curr_b_from)-> is_available_tile_index ( device_ctx.grid [curr_x_to][curr_y_to].type -> index )) {
1359
1362
abort_swap = true ;
1360
1363
} else {
1361
1364
abort_swap = setup_blocks_affected (curr_b_from, curr_x_to, curr_y_to, curr_z_to);
@@ -1415,11 +1418,18 @@ static e_swap_result try_swap(float t,
1415
1418
1416
1419
auto cluster_from_type = cluster_ctx.clb_nlist .block_type (b_from);
1417
1420
auto grid_from_type = g_vpr_ctx.device ().grid [x_from][y_from].type ;
1421
+ VTR_ASSERT (cluster_from_type->is_available_tile_index (grid_from_type->index ));
1418
1422
1419
- VTR_ASSERT (check_if_legal_placement (cluster_from_type, grid_from_type));
1423
+ t_type_ptr to_block_type = cluster_ctx.clb_nlist .block_type (b_from);
1424
+ int rand_block_type = vtr::irand (to_block_type->num_equivalent_tiles );
1425
+ if (rand_block_type != 0 ) {
1426
+ to_block_type = to_block_type->equivalent_tiles [rand_block_type-1 ];
1427
+ }
1420
1428
1421
- if (!find_to (cluster_ctx.clb_nlist .block_type (b_from), rlim, x_from, y_from, &x_to, &y_to, &z_to))
1422
- return REJECTED;
1429
+ VTR_ASSERT (cluster_from_type->is_available_tile_index (to_block_type->index ));
1430
+
1431
+ if (!find_to (cluster_from_type, to_block_type, rlim, x_from, y_from, &x_to, &y_to, &z_to))
1432
+ return REJECTED;
1423
1433
1424
1434
#if 0
1425
1435
auto& grid = g_vpr_ctx.device().grid;
@@ -1449,7 +1459,7 @@ static e_swap_result try_swap(float t,
1449
1459
1450
1460
// Find all the nets affected by this swap and update thier bounding box
1451
1461
int num_nets_affected = find_affected_nets_and_update_costs (place_algorithm, delay_model, bb_delta_c, timing_delta_c, delay_delta_c);
1452
-
1462
+
1453
1463
if (place_algorithm == PATH_TIMING_DRIVEN_PLACE) {
1454
1464
/* in this case we redefine delta_c as a combination of timing and bb. *
1455
1465
*additionally, we normalize all values, therefore delta_c is in *
@@ -1730,7 +1740,7 @@ static void update_td_delta_costs(const PlaceDelayModel& delay_model, const Clus
1730
1740
}
1731
1741
}
1732
1742
1733
- static bool find_to (t_type_ptr type , float rlim,
1743
+ static bool find_to (t_type_ptr from_type, t_type_ptr to_type , float rlim,
1734
1744
int x_from, int y_from,
1735
1745
int *px_to, int *py_to, int *pz_to) {
1736
1746
@@ -1747,9 +1757,7 @@ static bool find_to(t_type_ptr type, float rlim,
1747
1757
1748
1758
auto & grid = g_vpr_ctx.device ().grid ;
1749
1759
auto & place_ctx = g_vpr_ctx.placement ();
1750
-
1751
- auto grid_type = grid[x_from][y_from].type ;
1752
- VTR_ASSERT (check_if_legal_placement (type, grid_type));
1760
+ auto & cluster_ctx = g_vpr_ctx.clustering ();
1753
1761
1754
1762
int rlx = min<float >(grid.width () - 1 , rlim);
1755
1763
int rly = min<float >(grid.height () - 1 , rlim); /* Added rly for aspect_ratio != 1 case. */
@@ -1768,27 +1776,27 @@ static bool find_to(t_type_ptr type, float rlim,
1768
1776
}
1769
1777
1770
1778
num_tries = 0 ;
1771
- itype = type ->index ;
1779
+ itype = to_type ->index ;
1772
1780
1773
1781
do { /* Until legal */
1774
1782
is_legal = true ;
1775
1783
1776
1784
/* Limit the number of tries when searching for an alternative position */
1777
- if (num_tries >= 2 * min (active_area / (type ->width * type ->height ), num_legal_pos[itype]) + 10 ) {
1785
+ if (num_tries >= 2 * min (active_area / (to_type ->width * to_type ->height ), num_legal_pos[itype]) + 10 ) {
1778
1786
/* Tried randomly searching for a suitable position */
1779
1787
return false ;
1780
1788
} else {
1781
1789
num_tries++;
1782
1790
}
1783
1791
1784
- find_to_location (type , rlim, x_from, y_from,
1785
- px_to, py_to, pz_to);
1792
+ find_to_location (to_type , rlim, x_from, y_from,
1793
+ px_to, py_to, pz_to, from_type != to_type );
1786
1794
1787
1795
if ((x_from == *px_to) && (y_from == *py_to)) {
1788
1796
is_legal = false ;
1789
1797
} else if (*px_to > max_x || *px_to < min_x || *py_to > max_y || *py_to < min_y) {
1790
1798
is_legal = false ;
1791
- } else if (grid[*px_to][*py_to]. type != grid[x_from][y_from ].type ) {
1799
+ } else if (to_type != grid[*px_to][*py_to ].type ) {
1792
1800
is_legal = false ;
1793
1801
} else {
1794
1802
/* Find z_to and test to validate that the "to" block is *not* fixed */
@@ -1797,7 +1805,11 @@ static bool find_to(t_type_ptr type, float rlim,
1797
1805
*pz_to = vtr::irand (grid[*px_to][*py_to].type ->capacity - 1 );
1798
1806
}
1799
1807
ClusterBlockId b_to = place_ctx.grid_blocks [*px_to][*py_to].blocks [*pz_to];
1800
- if ((b_to != EMPTY_BLOCK_ID) && (place_ctx.block_locs [b_to].is_fixed == true )) {
1808
+ auto b_to_type = cluster_ctx.clb_nlist .block_type (b_to);
1809
+ auto grid_from_type = grid[x_from][y_from].type ;
1810
+
1811
+ if (b_to != EMPTY_BLOCK_ID &&
1812
+ ((place_ctx.block_locs [b_to].is_fixed == true ) || (!b_to_type->is_available_tile_index (grid_from_type->index )))) {
1801
1813
is_legal = false ;
1802
1814
}
1803
1815
}
@@ -1810,13 +1822,13 @@ static bool find_to(t_type_ptr type, float rlim,
1810
1822
vpr_throw (VPR_ERROR_PLACE, __FILE__, __LINE__," in routine find_to: (x_to,y_to) = (%d,%d)\n " , *px_to, *py_to);
1811
1823
}
1812
1824
1813
- VTR_ASSERT (check_if_legal_placement (type, grid[*px_to][*py_to].type ));
1825
+ VTR_ASSERT (from_type-> is_available_tile_index ( grid[*px_to][*py_to].type -> index ));
1814
1826
return true ;
1815
1827
}
1816
1828
1817
1829
static void find_to_location (t_type_ptr type, float rlim,
1818
1830
int x_from, int y_from,
1819
- int *px_to, int *py_to, int *pz_to) {
1831
+ int *px_to, int *py_to, int *pz_to, bool is_equivalent ) {
1820
1832
1821
1833
auto & device_ctx = g_vpr_ctx.device ();
1822
1834
auto & grid = device_ctx.grid ;
@@ -1834,7 +1846,7 @@ static void find_to_location(t_type_ptr type, float rlim,
1834
1846
int max_y = min<float >(grid.height () - 1 , y_from + rly);
1835
1847
1836
1848
*pz_to = 0 ;
1837
- if (int (grid.width () / 4 ) < rlx || int (grid.height () / 4 ) < rly || num_legal_pos[itype] < active_area) {
1849
+ if (int (grid.width () / 4 ) < rlx || int (grid.height () / 4 ) < rly || num_legal_pos[itype] < active_area || is_equivalent ) {
1838
1850
int ipos = vtr::irand (num_legal_pos[itype] - 1 );
1839
1851
*px_to = legal_pos[itype][ipos].x ;
1840
1852
*py_to = legal_pos[itype][ipos].y ;
@@ -2848,7 +2860,7 @@ static void initial_placement_pl_macros(int macros_max_num_tries, int * free_loc
2848
2860
2849
2861
bool no_free_locations = true ;
2850
2862
// Loop over all the possible equivalent tiles
2851
- for (int itype : get_available_placement_itypes ( cluster_ctx.clb_nlist .block_type (blk_id)) ) {
2863
+ for (int itype : cluster_ctx.clb_nlist .block_type (blk_id)-> available_tiles_indices ) {
2852
2864
if (free_locations[itype] >= pl_macros[imacro].num_blocks ) {
2853
2865
no_free_locations = false ;
2854
2866
} else {
@@ -2935,7 +2947,7 @@ static void initial_placement_blocks(int * free_locations, enum e_pad_loc_type p
2935
2947
*/
2936
2948
bool no_free_locations = true ;
2937
2949
// Loop over all the possible equivalent tiles
2938
- for (int itype : get_available_placement_itypes ( cluster_ctx.clb_nlist .block_type (blk_id)) ) {
2950
+ for (int itype : cluster_ctx.clb_nlist .block_type (blk_id)-> available_tiles_indices ) {
2939
2951
if (free_locations[itype] > 0 ) {
2940
2952
no_free_locations = false ;
2941
2953
} else {
@@ -2983,6 +2995,7 @@ static void initial_placement_blocks(int * free_locations, enum e_pad_loc_type p
2983
2995
2984
2996
static void initial_placement_location (int * free_locations, int itype,
2985
2997
int *pipos, int *px_to, int *py_to, int *pz_to) {
2998
+
2986
2999
*pipos = vtr::irand (free_locations[itype] - 1 );
2987
3000
*px_to = legal_pos[itype][*pipos].x ;
2988
3001
*py_to = legal_pos[itype][*pipos].y ;
@@ -3236,8 +3249,7 @@ static void check_place(const t_placer_costs& costs,
3236
3249
if (EMPTY_BLOCK_ID == bnum || INVALID_BLOCK_ID == bnum)
3237
3250
continue ;
3238
3251
3239
- // Check if block has been placed in a valid location
3240
- if (!check_if_legal_placement (cluster_ctx.clb_nlist .block_type (bnum), device_ctx.grid [i][j].type )) {
3252
+ if (!cluster_ctx.clb_nlist .block_type (bnum)->is_available_tile_index (device_ctx.grid [i][j].type ->index )) {
3241
3253
VTR_LOG_ERROR (
3242
3254
" Block %zu type (%s) does not match grid location (%zu,%zu) type (%s).\n " ,
3243
3255
size_t (bnum), cluster_ctx.clb_nlist .block_type (bnum)->name , i, j, device_ctx.grid [i][j].type ->name );
@@ -3376,22 +3388,3 @@ static void generate_post_place_timing_reports(const t_placer_opts& placer_opts,
3376
3388
3377
3389
timing_reporter.report_timing_setup (placer_opts.post_place_timing_report_file , *timing_info.setup_analyzer (), analysis_opts.timing_report_npaths );
3378
3390
}
3379
-
3380
- static std::vector<int > get_available_placement_itypes (t_type_ptr type) {
3381
- std::vector<int > itypes (1 , type->index );
3382
-
3383
- for (int itype = 0 ; itype < type->num_equivalent_tiles ; itype++) {
3384
- itypes.push_back (type->equivalent_tiles [itype]->index );
3385
- }
3386
-
3387
- return itypes;
3388
- }
3389
-
3390
- static bool check_if_legal_placement (t_type_ptr cluster_type, t_type_ptr grid_type) {
3391
- std::vector<int > itypes = get_available_placement_itypes (cluster_type);
3392
- if (std::find (itypes.begin (), itypes.end (), grid_type->index ) != itypes.end ()) {
3393
- return true ;
3394
- }
3395
-
3396
- return false ;
3397
- }
0 commit comments