1
1
2
2
#include < memory>
3
+ #include < optional>
3
4
4
5
#include " FlatPlacementInfo.h"
6
+ #include " initial_placement.h"
7
+ #include " load_flat_place.h"
8
+ #include " noc_place_utils.h"
9
+ #include " pack.h"
10
+ #include " place_constraints.h"
5
11
#include " place_macro.h"
12
+ #include " vpr_context.h"
6
13
#include " vtr_assert.h"
7
14
#include " vtr_log.h"
15
+ #include " vtr_memory.h"
8
16
#include " vtr_time.h"
9
17
#include " vpr_types.h"
10
18
#include " vpr_utils.h"
@@ -53,6 +61,18 @@ void try_place(const Netlist<>& net_list,
53
61
const auto & cluster_ctx = g_vpr_ctx.clustering ();
54
62
const auto & atom_ctx = g_vpr_ctx.atom ();
55
63
64
+ // Initialize the variables in the placement context.
65
+ init_placement_context (g_vpr_ctx.mutable_placement (),
66
+ placer_opts,
67
+ noc_opts,
68
+ directs);
69
+
70
+ const bool cube_bb = g_vpr_ctx.placement ().cube_bb ;
71
+
72
+ VTR_LOG (" \n " );
73
+ VTR_LOG (" Bounding box mode is %s\n " , (cube_bb ? " Cube" : " Per-layer" ));
74
+ VTR_LOG (" \n " );
75
+
56
76
/* Placement delay model is independent of the placement and can be shared across
57
77
* multiple placers if we are performing parallel annealing.
58
78
* So, it is created and initialized once. */
@@ -74,28 +94,11 @@ void try_place(const Netlist<>& net_list,
74
94
}
75
95
}
76
96
77
- g_vpr_ctx.mutable_placement ().cube_bb = is_cube_bb (placer_opts.place_bounding_box_mode , device_ctx.rr_graph );
78
- const bool cube_bb = g_vpr_ctx.placement ().cube_bb ;
79
-
80
- VTR_LOG (" \n " );
81
- VTR_LOG (" Bounding box mode is %s\n " , (cube_bb ? " Cube" : " Per-layer" ));
82
- VTR_LOG (" \n " );
83
-
84
- auto & place_ctx = g_vpr_ctx.mutable_placement ();
85
-
86
97
/* Make the global instance of BlkLocRegistry inaccessible through the getter methods of the
87
98
* placement context. This is done to make sure that the placement stage only accesses its
88
99
* own local instances of BlkLocRegistry.
89
100
*/
90
- place_ctx.lock_loc_vars ();
91
- place_ctx.compressed_block_grids = create_compressed_block_grids ();
92
-
93
- // Alloc and load the placement macros.
94
- place_ctx.place_macros = std::make_unique<PlaceMacros>(directs,
95
- device_ctx.physical_tile_types ,
96
- cluster_ctx.clb_nlist ,
97
- atom_ctx.nlist ,
98
- atom_ctx.lookup );
101
+ g_vpr_ctx.mutable_placement ().lock_loc_vars ();
99
102
100
103
/* Start measuring placement time. The measured execution time will be printed
101
104
* when this object goes out of scope at the end of this function.
@@ -107,18 +110,74 @@ void try_place(const Netlist<>& net_list,
107
110
// Enables fast look-up of atom pins connect to CLB pins
108
111
ClusteredPinAtomPinsLookup netlist_pin_lookup (cluster_ctx.clb_nlist , atom_ctx.nlist , pb_gpin_lookup);
109
112
110
- Placer placer (net_list, placer_opts, analysis_opts, noc_opts, pb_gpin_lookup, netlist_pin_lookup,
113
+ Placer placer (net_list, {}, placer_opts, analysis_opts, noc_opts, pb_gpin_lookup, netlist_pin_lookup,
111
114
flat_placement_info, place_delay_model, cube_bb, is_flat, /* quiet=*/ false );
112
115
113
116
placer.place ();
114
117
115
- vtr::release_memory (place_ctx.compressed_block_grids );
116
-
117
118
/* The placer object has its own copy of block locations and doesn't update
118
119
* the global context directly. We need to copy its internal data structures
119
120
* to the global placement context before it goes out of scope.
120
121
*/
121
- placer.copy_locs_to_global_state (place_ctx);
122
+ placer.copy_locs_to_global_state (g_vpr_ctx.mutable_placement ());
123
+
124
+ // Clean the variables in the placement context. This will deallocate memory
125
+ // used by variables which were allocated in the placement context and are
126
+ // never used outside of placement.
127
+ clean_placement_context (g_vpr_ctx.mutable_placement ());
128
+ }
129
+
130
+ void init_placement_context (PlacementContext& place_ctx,
131
+ const t_placer_opts& placer_opts,
132
+ const t_noc_opts& noc_opts,
133
+ const std::vector<t_direct_inf>& directs) {
134
+ const AtomContext& atom_ctx = g_vpr_ctx.atom ();
135
+ const ClusteringContext& cluster_ctx = g_vpr_ctx.clustering ();
136
+ const DeviceContext& device_ctx = g_vpr_ctx.device ();
137
+
138
+ place_ctx.cube_bb = is_cube_bb (placer_opts.place_bounding_box_mode , device_ctx.rr_graph );
139
+
140
+ place_ctx.compressed_block_grids = create_compressed_block_grids ();
141
+
142
+ // Alloc and load the placement macros.
143
+ place_ctx.place_macros = std::make_unique<PlaceMacros>(directs,
144
+ device_ctx.physical_tile_types ,
145
+ cluster_ctx.clb_nlist ,
146
+ atom_ctx.nlist ,
147
+ atom_ctx.lookup );
148
+
149
+ /* Go through cluster blocks to calculate the tightest placement
150
+ * floorplan constraint for each constrained block.
151
+ */
152
+ propagate_place_constraints (*place_ctx.place_macros );
153
+
154
+ // Compute and store compressed floorplanning constraints.
155
+ alloc_and_load_compressed_cluster_constraints ();
156
+
157
+ /* To make sure the importance of NoC-related cost terms compared to
158
+ * BB and timing cost is determine only through NoC placement weighting factor,
159
+ * we normalize NoC-related cost weighting factors so that they add up to 1.
160
+ * With this normalization, NoC-related cost weighting factors only determine
161
+ * the relative importance of NoC cost terms with respect to each other, while
162
+ * the importance of total NoC cost to conventional placement cost is determined
163
+ * by NoC placement weighting factor.
164
+ * FIXME: Why is this modifying the noc_opts?
165
+ */
166
+ if (noc_opts.noc ) {
167
+ normalize_noc_cost_weighting_factor (const_cast <t_noc_opts&>(noc_opts));
168
+ }
169
+ }
170
+
171
+ void clean_placement_context (PlacementContext& place_ctx) {
172
+ vtr::release_memory (place_ctx.compressed_block_grids );
173
+
174
+ // The cluster constraints are loaded in propagate_place_constraints and are
175
+ // not used outside of placement.
176
+ vtr::release_memory (g_vpr_ctx.mutable_floorplanning ().cluster_constraints );
177
+
178
+ // The compressed cluster constraints are loaded in alloc_and_laod_compressed
179
+ // cluster_constraints and are not used outside of placement.
180
+ vtr::release_memory (g_vpr_ctx.mutable_floorplanning ().compressed_cluster_constraints );
122
181
}
123
182
124
183
static bool is_cube_bb (const e_place_bounding_box_mode place_bb_mode,
0 commit comments