27
27
#include " clustered_netlist_fwd.h"
28
28
#include " globals.h"
29
29
#include " physical_types.h"
30
- #include " physical_types_util.h"
31
30
#include " placer_globals.h"
32
31
#include " move_utils.h"
33
32
#include " place_timing_update.h"
@@ -82,6 +81,7 @@ static const float cross_count[MAX_FANOUT_CROSSING_COUNT] = {/* [0..49] */ 1.0,
82
81
static vtr::NdMatrix<float , 2 > chanx_place_cost_fac ({0 , 0 }); // [0...device_ctx.grid.width()-2]
83
82
static vtr::NdMatrix<float , 2 > chany_place_cost_fac ({0 , 0 }); // [0...device_ctx.grid.height()-2]
84
83
84
+ namespace {
85
85
/* *
86
86
* @brief For each of the vectors in this struct, there is one entry per cluster level net:
87
87
* [0...cluster_ctx.clb_nlist.nets().size()-1].
@@ -105,16 +105,13 @@ struct PLNetCost {
105
105
vtr::vector<ClusterNetId, double > proposed_net_cost;
106
106
vtr::vector<ClusterNetId, NetUpdateState> bb_update_status;
107
107
};
108
- static struct PLNetCost pl_net_cost;
109
108
110
109
/* The following arrays are used by the try_swap function for speed. */
111
110
112
111
/* *
113
- * The wire length estimation is based on the bounding box of the net. In the case of the 2D architecture,
112
+ * @brief The wire length estimation is based on the bounding box of the net. In the case of the 2D architecture,
114
113
* we use a 3D BB with the z-dimension (layer) set to 1. In the case of 3D architecture, there 2 types of bounding box:
115
114
* 3D and per-layer. The type is determined at the beginning of the placement and stored in the placement context.
116
- *
117
- *
118
115
* If the bonding box is of the type 3D, ts_bb_coord_new and ts_bb_edge_new are used. Otherwise, layer_ts_bb_edge_new and
119
116
* layer_ts_bb_coord_new are used.
120
117
*/
@@ -129,12 +126,11 @@ struct TSInfo {
129
126
/* [0...num_afftected_nets] -> net_id of the affected nets */
130
127
std::vector<ClusterNetId> ts_nets_to_update;
131
128
};
132
- static struct TSInfo ts_info;
133
129
134
130
/* *
135
131
* @brief This class is used to hide control flows needed to distinguish 2d and 3d placement
136
132
*/
137
- class BB2D3DControlFlow {
133
+ class BBUpdater {
138
134
bool cube_bb = false ;
139
135
140
136
public:
@@ -146,7 +142,13 @@ class BB2D3DControlFlow {
146
142
void set_ts_bb_coord (const ClusterNetId& net_id);
147
143
void set_ts_edge (const ClusterNetId& net_id);
148
144
};
149
- static BB2D3DControlFlow bb_2d_3d_control_flow;
145
+ } // namespace
146
+
147
+ static struct PLNetCost pl_net_cost;
148
+
149
+ static struct TSInfo ts_info;
150
+
151
+ static BBUpdater bb_updater;
150
152
151
153
/* *
152
154
* @param net
@@ -478,27 +480,28 @@ static double wirelength_crossing_count(size_t fanout);
478
480
static void set_bb_delta_cost (const int num_affected_nets, double & bb_delta_c);
479
481
480
482
/* ****************************** End of Function definitions ************************************/
483
+ namespace {
481
484
// Initialize the ts vectors
482
- void BB2D3DControlFlow ::init (size_t num_nets, bool cube_bb_in) {
485
+ void BBUpdater ::init (size_t num_nets, bool cube_bb_in) {
483
486
const int num_layers = g_vpr_ctx.device ().grid .get_num_layers ();
484
487
485
488
cube_bb = cube_bb_in;
489
+ // Either 3D BB or per layer BB data structure are used, not both.
486
490
if (cube_bb) {
487
491
ts_info.ts_bb_edge_new .resize (num_nets, t_bb ());
488
492
ts_info.ts_bb_coord_new .resize (num_nets, t_bb ());
489
493
} else {
490
- VTR_ASSERT_SAFE (!cube_bb);
491
494
ts_info.layer_ts_bb_edge_new .resize (num_nets, std::vector<t_2D_bb>(num_layers, t_2D_bb ()));
492
495
ts_info.layer_ts_bb_coord_new .resize (num_nets, std::vector<t_2D_bb>(num_layers, t_2D_bb ()));
493
496
}
494
497
495
- /* This initialize the whole matrix to OPEN which is an invalid value*/
498
+ /* This initializes the whole matrix to OPEN which is an invalid value*/
496
499
ts_info.ts_layer_sink_pin_count .resize ({num_nets, size_t (num_layers)}, OPEN);
497
500
498
501
ts_info.ts_nets_to_update .resize (num_nets, ClusterNetId::INVALID ());
499
502
}
500
503
501
- void BB2D3DControlFlow ::get_non_updatable_bb (const ClusterNetId& net) {
504
+ void BBUpdater ::get_non_updatable_bb (const ClusterNetId& net) {
502
505
if (cube_bb)
503
506
::get_non_updatable_bb (net,
504
507
ts_info.ts_bb_coord_new[net],
@@ -509,15 +512,7 @@ void BB2D3DControlFlow::get_non_updatable_bb(const ClusterNetId& net) {
509
512
ts_info.ts_layer_sink_pin_count[size_t (net)]);
510
513
}
511
514
512
- bool BB2D3DControlFlow::is_driver (const t_physical_tile_type_ptr& blk_type, const ClusterPinId& blk_pin) {
513
- auto & cluster_ctx = g_vpr_ctx.clustering ();
514
- if (cube_bb)
515
- return cluster_ctx.clb_nlist .pin_type (blk_pin) == PinType::DRIVER;
516
- else
517
- return get_pin_type_from_pin_physical_num (blk_type, tile_pin_index (blk_pin)) == e_pin_type::DRIVER;
518
- }
519
-
520
- void BB2D3DControlFlow::update_bb (ClusterNetId net_id, t_physical_tile_loc pin_old_loc, t_physical_tile_loc pin_new_loc, bool is_driver) {
515
+ void BBUpdater::update_bb (ClusterNetId net_id, t_physical_tile_loc pin_old_loc, t_physical_tile_loc pin_new_loc, bool is_driver) {
521
516
if (cube_bb)
522
517
::update_bb (net_id,
523
518
ts_info.ts_bb_edge_new[net_id],
@@ -536,14 +531,14 @@ void BB2D3DControlFlow::update_bb(ClusterNetId net_id, t_physical_tile_loc pin_o
536
531
is_driver);
537
532
}
538
533
539
- double BB2D3DControlFlow ::get_net_cost (const ClusterNetId& net_id) {
534
+ double BBUpdater ::get_net_cost (const ClusterNetId& net_id) {
540
535
if (cube_bb)
541
536
return ::get_net_cost (net_id, ts_info.ts_bb_coord_new [net_id]);
542
537
else
543
538
return ::get_net_layer_bb_wire_cost (net_id, ts_info.layer_ts_bb_coord_new [net_id], ts_info.ts_layer_sink_pin_count [size_t (net_id)]);
544
539
}
545
540
546
- void BB2D3DControlFlow ::set_ts_bb_coord (const ClusterNetId& net_id) {
541
+ void BBUpdater ::set_ts_bb_coord (const ClusterNetId& net_id) {
547
542
auto & place_move_ctx = g_placer_ctx.mutable_move ();
548
543
if (cube_bb) {
549
544
place_move_ctx.bb_coords [net_id] = ts_info.ts_bb_coord_new [net_id];
@@ -552,14 +547,16 @@ void BB2D3DControlFlow::set_ts_bb_coord(const ClusterNetId& net_id) {
552
547
}
553
548
}
554
549
555
- void BB2D3DControlFlow ::set_ts_edge (const ClusterNetId& net_id) {
550
+ void BBUpdater ::set_ts_edge (const ClusterNetId& net_id) {
556
551
auto & place_move_ctx = g_placer_ctx.mutable_move ();
557
552
if (cube_bb) {
558
553
place_move_ctx.bb_num_on_edges [net_id] = ts_info.ts_bb_edge_new [net_id];
559
554
} else {
560
555
place_move_ctx.layer_bb_num_on_edges [net_id] = ts_info.layer_ts_bb_edge_new [net_id];
561
556
}
562
557
}
558
+ } // namespace
559
+
563
560
// Returns true if 'net' is driven by one of the blocks in 'blocks_affected'
564
561
static bool driven_by_moved_block (const ClusterNetId net,
565
562
const int num_blocks,
@@ -589,7 +586,7 @@ static void update_net_bb(const ClusterNetId& net,
589
586
// For small nets brute-force bounding box update is faster
590
587
591
588
if (pl_net_cost.bb_update_status [net] == NetUpdateState::NOT_UPDATED_YET) { // Only once per-net
592
- bb_2d_3d_control_flow .get_non_updatable_bb (net);
589
+ bb_updater .get_non_updatable_bb (net);
593
590
}
594
591
} else {
595
592
// For large nets, update bounding box incrementally
@@ -598,17 +595,17 @@ static void update_net_bb(const ClusterNetId& net,
598
595
t_physical_tile_type_ptr blk_type = physical_tile_type (blk);
599
596
int pin_width_offset = blk_type->pin_width_offset [iblk_pin];
600
597
int pin_height_offset = blk_type->pin_height_offset [iblk_pin];
601
- bool is_driver = bb_2d_3d_control_flow. is_driver (blk_type, blk_pin);
598
+ bool is_driver = cluster_ctx. clb_nlist . pin_type ( blk_pin) == PinType::DRIVER ;
602
599
603
600
// Incremental bounding box update
604
- bb_2d_3d_control_flow .update_bb (net,
605
- {pl_moved_block.old_loc .x + pin_width_offset,
606
- pl_moved_block.old_loc .y + pin_height_offset,
607
- pl_moved_block.old_loc .layer },
608
- {pl_moved_block.new_loc .x + pin_width_offset,
609
- pl_moved_block.new_loc .y + pin_height_offset,
610
- pl_moved_block.new_loc .layer },
611
- is_driver);
601
+ bb_updater .update_bb (net,
602
+ {pl_moved_block.old_loc .x + pin_width_offset,
603
+ pl_moved_block.old_loc .y + pin_height_offset,
604
+ pl_moved_block.old_loc .layer },
605
+ {pl_moved_block.new_loc .x + pin_width_offset,
606
+ pl_moved_block.new_loc .y + pin_height_offset,
607
+ pl_moved_block.new_loc .layer },
608
+ is_driver);
612
609
}
613
610
}
614
611
@@ -1905,7 +1902,7 @@ static void set_bb_delta_cost(const int num_affected_nets, double& bb_delta_c) {
1905
1902
inet_affected++) {
1906
1903
ClusterNetId net_id = ts_info.ts_nets_to_update [inet_affected];
1907
1904
1908
- pl_net_cost.proposed_net_cost [net_id] = bb_2d_3d_control_flow .get_net_cost (net_id);
1905
+ pl_net_cost.proposed_net_cost [net_id] = bb_updater .get_net_cost (net_id);
1909
1906
1910
1907
bb_delta_c += pl_net_cost.proposed_net_cost [net_id] - pl_net_cost.net_cost [net_id];
1911
1908
}
@@ -2046,14 +2043,14 @@ void update_move_nets(int num_nets_affected) {
2046
2043
inet_affected++) {
2047
2044
ClusterNetId net_id = ts_info.ts_nets_to_update [inet_affected];
2048
2045
2049
- bb_2d_3d_control_flow .set_ts_bb_coord (net_id);
2046
+ bb_updater .set_ts_bb_coord (net_id);
2050
2047
2051
2048
for (int layer_num = 0 ; layer_num < g_vpr_ctx.device ().grid .get_num_layers (); layer_num++) {
2052
2049
place_move_ctx.num_sink_pin_layer [size_t (net_id)][layer_num] = ts_info.ts_layer_sink_pin_count [size_t (net_id)][layer_num];
2053
2050
}
2054
2051
2055
2052
if (cluster_ctx.clb_nlist .net_sinks (net_id).size () >= SMALL_NET) {
2056
- bb_2d_3d_control_flow .set_ts_edge (net_id);
2053
+ bb_updater .set_ts_edge (net_id);
2057
2054
}
2058
2055
2059
2056
pl_net_cost.net_cost [net_id] = pl_net_cost.proposed_net_cost [net_id];
@@ -2259,7 +2256,7 @@ void free_place_move_structs() {
2259
2256
}
2260
2257
2261
2258
void init_try_swap_net_cost_structs (size_t num_nets, bool cube_bb) {
2262
- bb_2d_3d_control_flow .init (num_nets, cube_bb);
2259
+ bb_updater .init (num_nets, cube_bb);
2263
2260
}
2264
2261
2265
2262
void free_try_swap_net_cost_structs () {
0 commit comments