@@ -287,7 +287,7 @@ 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 (ClusterBlockId blk, t_type_ptr 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,
@@ -1225,14 +1225,19 @@ static int setup_blocks_affected(ClusterBlockId b_from, int x_to, int y_to, int
1225
1225
ClusterBlockId b_to;
1226
1226
int abort_swap = false ;
1227
1227
1228
- auto & place_ctx = g_vpr_ctx.mutable_placement ();
1228
+ auto & place_ctx = g_vpr_ctx.mutable_placement ();
1229
+ auto clb_nlist = g_vpr_ctx.clustering ().clb_nlist ;
1230
+ auto grid = g_vpr_ctx.device ().grid ;
1229
1231
1230
1232
x_from = place_ctx.block_locs [b_from].x ;
1231
1233
y_from = place_ctx.block_locs [b_from].y ;
1232
1234
z_from = place_ctx.block_locs [b_from].z ;
1233
1235
1234
1236
b_to = place_ctx.grid_blocks [x_to][y_to].blocks [z_to];
1235
1237
1238
+ auto cluster_to_type = clb_nlist.block_type (b_to);
1239
+ auto grid_from_type = grid[x_from][y_from].type ;
1240
+
1236
1241
// Check whether the to_location is empty
1237
1242
if (b_to == EMPTY_BLOCK_ID) {
1238
1243
@@ -1254,7 +1259,8 @@ static int setup_blocks_affected(ClusterBlockId b_from, int x_to, int y_to, int
1254
1259
blocks_affected.moved_blocks [imoved_blk].swapped_from_is_empty = true ;
1255
1260
blocks_affected.num_moved_blocks ++;
1256
1261
1257
- } else if (b_to != INVALID_BLOCK_ID) {
1262
+ // If location is not empty checks that the block in the `to` location is compatible with the `from` location
1263
+ } else if (b_to != INVALID_BLOCK_ID && check_if_legal_placement (cluster_to_type, grid_from_type)) {
1258
1264
1259
1265
// Does not allow a swap with a macro yet
1260
1266
get_imacro_from_iblk (&imacro, b_to, pl_macros, num_pl_macros);
@@ -1285,6 +1291,7 @@ static int setup_blocks_affected(ClusterBlockId b_from, int x_to, int y_to, int
1285
1291
blocks_affected.moved_blocks [imoved_blk].swapped_from_is_empty = false ;
1286
1292
blocks_affected.num_moved_blocks ++;
1287
1293
1294
+ // Finish swapping the blocks and setting up blocks_affected
1288
1295
imoved_blk = blocks_affected.num_moved_blocks ;
1289
1296
blocks_affected.moved_blocks [imoved_blk].block_num = b_to;
1290
1297
blocks_affected.moved_blocks [imoved_blk].xold = x_to;
@@ -1296,8 +1303,10 @@ static int setup_blocks_affected(ClusterBlockId b_from, int x_to, int y_to, int
1296
1303
blocks_affected.moved_blocks [imoved_blk].swapped_to_was_empty = false ;
1297
1304
blocks_affected.moved_blocks [imoved_blk].swapped_from_is_empty = false ;
1298
1305
blocks_affected.num_moved_blocks ++;
1299
-
1300
- } // Finish swapping the blocks and setting up blocks_affected
1306
+ } else {
1307
+ abort_swap = true ;
1308
+ return (abort_swap);
1309
+ }
1301
1310
1302
1311
return (abort_swap);
1303
1312
@@ -1355,7 +1364,7 @@ static int find_affected_blocks(ClusterBlockId b_from, int x_to, int y_to, int z
1355
1364
if ( curr_x_to < 1 || curr_x_to >= int (device_ctx.grid .width ())
1356
1365
|| curr_y_to < 1 || curr_y_to >= int (device_ctx.grid .height ())
1357
1366
|| curr_z_to < 0
1358
- || device_ctx.grid [curr_x_to][curr_y_to].type != cluster_ctx. clb_nlist . block_type (curr_b_from )) {
1367
+ || ! check_if_legal_placement (cluster_ctx. clb_nlist . block_type (curr_b_from), device_ctx.grid [curr_x_to][curr_y_to].type )) {
1359
1368
abort_swap = true ;
1360
1369
} else {
1361
1370
abort_swap = setup_blocks_affected (curr_b_from, curr_x_to, curr_y_to, curr_z_to);
@@ -1418,8 +1427,16 @@ static e_swap_result try_swap(float t,
1418
1427
1419
1428
VTR_ASSERT (check_if_legal_placement (cluster_from_type, grid_from_type));
1420
1429
1421
- if (!find_to (cluster_ctx.clb_nlist .block_type (b_from), rlim, x_from, y_from, &x_to, &y_to, &z_to))
1430
+ t_type_ptr to_block_type = cluster_ctx.clb_nlist .block_type (b_from);
1431
+ int rand_block_type = vtr::irand (to_block_type->num_equivalent_tiles );
1432
+ if (rand_block_type != 0 ) {
1433
+ to_block_type = to_block_type->equivalent_tiles [rand_block_type-1 ];
1434
+ }
1435
+
1436
+
1437
+ if (!find_to (b_from, to_block_type, rlim, x_from, y_from, &x_to, &y_to, &z_to)) {
1422
1438
return REJECTED;
1439
+ }
1423
1440
1424
1441
#if 0
1425
1442
auto& grid = g_vpr_ctx.device().grid;
@@ -1535,6 +1552,7 @@ static e_swap_result try_swap(float t,
1535
1552
place_ctx.block_locs [b_from].y = blocks_affected.moved_blocks [iblk].yold ;
1536
1553
place_ctx.block_locs [b_from].z = blocks_affected.moved_blocks [iblk].zold ;
1537
1554
}
1555
+
1538
1556
}
1539
1557
1540
1558
/* Resets the num_moved_blocks, but do not free blocks_moved array. Defensive Coding */
@@ -1730,7 +1748,7 @@ static void update_td_delta_costs(const PlaceDelayModel& delay_model, const Clus
1730
1748
}
1731
1749
}
1732
1750
1733
- static bool find_to (t_type_ptr type, float rlim,
1751
+ static bool find_to (ClusterBlockId blk, t_type_ptr type, float rlim,
1734
1752
int x_from, int y_from,
1735
1753
int *px_to, int *py_to, int *pz_to) {
1736
1754
@@ -1745,11 +1763,11 @@ static bool find_to(t_type_ptr type, float rlim,
1745
1763
bool is_legal;
1746
1764
int itype;
1747
1765
1748
- auto & grid = g_vpr_ctx.device ().grid ;
1749
- auto & place_ctx = g_vpr_ctx.placement ();
1766
+ auto & grid = g_vpr_ctx.device ().grid ;
1767
+ auto & place_ctx = g_vpr_ctx.placement ();
1750
1768
1751
- auto grid_type = grid[x_from][y_from]. type ;
1752
- VTR_ASSERT (check_if_legal_placement (type, grid_type ));
1769
+ auto cluster_type = g_vpr_ctx. clustering (). clb_nlist . block_type (blk) ;
1770
+ VTR_ASSERT (check_if_legal_placement (cluster_type, type ));
1753
1771
1754
1772
int rlx = min<float >(grid.width () - 1 , rlim);
1755
1773
int rly = min<float >(grid.height () - 1 , rlim); /* Added rly for aspect_ratio != 1 case. */
@@ -1788,7 +1806,7 @@ static bool find_to(t_type_ptr type, float rlim,
1788
1806
is_legal = false ;
1789
1807
} else if (*px_to > max_x || *px_to < min_x || *py_to > max_y || *py_to < min_y) {
1790
1808
is_legal = false ;
1791
- } else if (grid[*px_to][*py_to].type != grid[x_from][y_from]. type ) {
1809
+ } else if (! check_if_legal_placement (cluster_type, grid[*px_to][*py_to].type ) ) {
1792
1810
is_legal = false ;
1793
1811
} else {
1794
1812
/* Find z_to and test to validate that the "to" block is *not* fixed */
@@ -1810,7 +1828,7 @@ static bool find_to(t_type_ptr type, float rlim,
1810
1828
vpr_throw (VPR_ERROR_PLACE, __FILE__, __LINE__," in routine find_to: (x_to,y_to) = (%d,%d)\n " , *px_to, *py_to);
1811
1829
}
1812
1830
1813
- VTR_ASSERT (check_if_legal_placement (type , grid[*px_to][*py_to].type ));
1831
+ VTR_ASSERT (check_if_legal_placement (cluster_type , grid[*px_to][*py_to].type ));
1814
1832
return true ;
1815
1833
}
1816
1834
@@ -1834,19 +1852,23 @@ static void find_to_location(t_type_ptr type, float rlim,
1834
1852
int max_y = min<float >(grid.height () - 1 , y_from + rly);
1835
1853
1836
1854
*pz_to = 0 ;
1837
- if (int (grid.width () / 4 ) < rlx || int (grid.height () / 4 ) < rly || num_legal_pos[itype] < active_area) {
1855
+
1856
+ // TODO: Must check how to find a new location now that we have equivalent tiles.
1857
+ // XXX: Lines which are commented out prevented to find equivalent tiles to swap with. They are temporarily disabled
1858
+
1859
+ // if (int(grid.width() / 4) < rlx || int(grid.height() / 4) < rly || num_legal_pos[itype] < active_area) {
1838
1860
int ipos = vtr::irand (num_legal_pos[itype] - 1 );
1839
1861
*px_to = legal_pos[itype][ipos].x ;
1840
1862
*py_to = legal_pos[itype][ipos].y ;
1841
1863
*pz_to = legal_pos[itype][ipos].z ;
1842
- } else {
1843
- int x_rel = vtr::irand (max (0 , max_x - min_x));
1844
- int y_rel = vtr::irand (max (0 , max_y - min_y));
1845
- *px_to = min_x + x_rel;
1846
- *py_to = min_y + y_rel;
1847
- *px_to = (*px_to) - grid[*px_to][*py_to].width_offset ; /* align it */
1848
- *py_to = (*py_to) - grid[*px_to][*py_to].height_offset ; /* align it */
1849
- }
1864
+ // } else {
1865
+ // int x_rel = vtr::irand(max(0, max_x - min_x));
1866
+ // int y_rel = vtr::irand(max(0, max_y - min_y));
1867
+ // *px_to = min_x + x_rel;
1868
+ // *py_to = min_y + y_rel;
1869
+ // *px_to = (*px_to) - grid[*px_to][*py_to].width_offset; /* align it */
1870
+ // *py_to = (*py_to) - grid[*px_to][*py_to].height_offset; /* align it */
1871
+ // }
1850
1872
}
1851
1873
1852
1874
static e_swap_result assess_swap (float delta_c, float t) {
@@ -3388,6 +3410,10 @@ static std::vector<int> get_available_placement_itypes(t_type_ptr type) {
3388
3410
}
3389
3411
3390
3412
static bool check_if_legal_placement (t_type_ptr cluster_type, t_type_ptr grid_type) {
3413
+ if (cluster_type->index == grid_type->index ) {
3414
+ return true ;
3415
+ }
3416
+
3391
3417
std::vector<int > itypes = get_available_placement_itypes (cluster_type);
3392
3418
if (std::find (itypes.begin (), itypes.end (), grid_type->index ) != itypes.end ()) {
3393
3419
return true ;
0 commit comments