@@ -15,7 +15,6 @@ class t_ext_pin_util_targets;
15
15
class t_pack_molecule ;
16
16
class t_pb ;
17
17
class t_pb_graph_node ;
18
- enum class e_block_pack_status ;
19
18
struct t_ext_pin_util ;
20
19
struct t_lb_router_data ;
21
20
@@ -25,11 +24,22 @@ struct t_lb_router_data;
25
24
struct legalization_cluster_id_tag ;
26
25
typedef vtr::StrongId<legalization_cluster_id_tag, size_t > LegalizationClusterId;
27
26
28
- // FIXME: Make this an enum class and use proper format.
29
- enum e_detailed_routing_stages {
30
- E_DETAILED_ROUTE_AT_END_ONLY = 0 ,
31
- E_DETAILED_ROUTE_FOR_EACH_ATOM,
32
- E_DETAILED_ROUTE_INVALID
27
+ // / @brief The different legalization strategies the cluster legalizer can perform.
28
+ // /
29
+ // / Allows the user of the API to select how thorough the legalizer should be.
30
+ enum class ClusterLegalizationStrategy {
31
+ FULL, // Run the full legalizer (including intra-lb routing)
32
+ SKIP_INTRA_LB_ROUTE // Do all legality checks except intra-lb routing
33
+ };
34
+
35
+ // / @brief The status of the cluster legalization.
36
+ enum class e_block_pack_status {
37
+ BLK_PASSED, // Passed legalization.
38
+ BLK_FAILED_FEASIBLE, // Failed due to block not feasibly being able to go in the cluster.
39
+ BLK_FAILED_ROUTE, // Failed due to intra-lb routing failure.
40
+ BLK_FAILED_FLOORPLANNING, // Failed due to not being compatible with the cluster's current PartitionRegion.
41
+ BLK_FAILED_NOC_GROUP, // Failed due to not being compatible with the cluster's NoC group.
42
+ BLK_STATUS_UNDEFINED // Undefined status. Something went wrong.
33
43
};
34
44
35
45
/*
@@ -49,25 +59,25 @@ struct LegalizationCluster {
49
59
// / FIXME: We should be more careful with how this is allocated. Instead of
50
60
// / pointers, we really should use IDs and store them in a standard
51
61
// / container.
52
- t_pb* cluster_pb ;
62
+ t_pb* pb ;
53
63
54
64
// / @brief The logical block type this cluster represents.
55
- t_logical_block_type_ptr cluster_type ;
65
+ t_logical_block_type_ptr type ;
56
66
57
67
// / @brief The partition region of legal positions this cluster can be placed.
58
68
// / Used to detect if a molecule can physically be placed in a cluster.
59
- PartitionRegion cluster_pr ;
69
+ PartitionRegion pr ;
60
70
61
71
// / @brief The NoC group that this cluster is a part of. Is used to check if
62
72
// / a candidate primitive is in the same NoC group as the atom blocks
63
73
// / that have already been added to the primitive.
64
- NocGroupId cluster_noc_grp_id ;
74
+ NocGroupId noc_grp_id ;
65
75
66
76
// / @brief The router data of the intra lb router used for this cluster.
67
77
// NOTE: This may not actually need to be kept per cluster... Not sure...
68
78
// I think this is passed into the subroutines to prevent repetitive work
69
79
// in the lb router; but I am not sure...
70
- t_lb_router_data* cluster_router_data ;
80
+ t_lb_router_data* router_data ;
71
81
};
72
82
73
83
// FIXME: We should completely remove access to the atom context. The legalizer
@@ -82,19 +92,21 @@ class ClusterLegalizer {
82
92
const t_ext_pin_util& max_external_pin_util);
83
93
public:
84
94
95
+ // Default constructor. Use the init method to initialize the legalizer.
85
96
ClusterLegalizer () = default ;
86
97
87
98
/*
88
99
* @brief Initialize the ClusterLegalizer class. Must be called before use.
89
100
*
90
101
* Allocates internal state.
102
+ * FIXME: See if we can simplify the parameters. Can any of these be inferred?
91
103
*/
92
104
void init (const Prepacker& prepacker,
93
105
const std::vector<t_logical_block_type>& logical_block_types,
94
106
const std::vector<std::string>& target_external_pin_util,
95
107
std::vector<t_lb_type_rr_node>* t_lb_type_rr_graphs,
96
108
size_t t_num_models,
97
- int t_detailed_routing_stage ,
109
+ ClusterLegalizationStrategy t_cluster_legalization_strategy ,
98
110
bool t_enable_pin_feasibility_filter,
99
111
int t_feasible_block_array_size,
100
112
int t_log_verbosity,
@@ -147,27 +159,58 @@ class ClusterLegalizer {
147
159
VTR_ASSERT (false && " Not implemented." );
148
160
}
149
161
162
+ // TODO: It would be nice to have an API to remove a molecule from a cluster.
163
+
150
164
// TODO: Make a better name for this. The basic idea is that it will uncluster
151
165
// all molecules in the cluster and free all aspects of the cluster.
152
166
void destroy_cluster (LegalizationClusterId cluster_id);
153
167
154
168
/*
155
- * @brief Double check that the given cluster is legal.
169
+ * @brief Check that the given cluster is fully legal.
156
170
*
157
171
* This method runs an intra_lb_route on the given cluster. This ignores
158
- * the detailed_routing_stage parameter to this class.
172
+ * the cluster legalization strategy set by the user. This method will not
173
+ * correct the problematic molecules, it will only return true if the
174
+ * cluster is legal and false if it is not.
175
+ *
176
+ * @param cluster_id The ID of the cluster to fully legalize.
177
+ *
178
+ * @return True if the cluster is legal, false otherwise.
159
179
*/
160
180
bool check_cluster_legality (LegalizationClusterId cluster_id);
161
181
162
- inline const LegalizationCluster& get_cluster (LegalizationClusterId cluster_id) const {
182
+ inline t_pb* get_cluster_pb (LegalizationClusterId cluster_id) const {
163
183
VTR_ASSERT_SAFE (cluster_id.is_valid () && (size_t )cluster_id < legalization_clusters.size ());
164
- return legalization_clusters[cluster_id];
184
+ LegalizationCluster cluster = legalization_clusters[cluster_id];
185
+ return cluster.pb ;
165
186
}
166
187
167
- void inline set_detailed_routing_stage (int stage) {
168
- detailed_routing_stage = stage;
188
+ /*
189
+ * @brief Set the legalization strategy of the cluster legalizer.
190
+ *
191
+ * This allows the strategy of the cluster legalizer to change based on the
192
+ * needs of the user. For example, one can set the legalizer to use a more
193
+ * relaxed strategy to insert a batch of molecules in cheaply, saving the
194
+ * full legalizerion for the end (using check_cluster_legality).
195
+ *
196
+ * @param strategy The strategy to set the cluster legalizer to.
197
+ */
198
+ void inline set_legalization_strategy (ClusterLegalizationStrategy strategy) {
199
+ cluster_legalization_strategy = strategy;
169
200
}
170
201
202
+ /*
203
+ * @brief Set how verbose the log messages should be for the cluster legalizer.
204
+ *
205
+ * This allows the user to set the verbosity at different points for easier
206
+ * usability.
207
+ *
208
+ * Set the verbosity to 4 to see most of the log messages on how the molecules
209
+ * move through the legalizer.
210
+ * Set the verbosity to 5 to see all the log messages in the legalizer.
211
+ *
212
+ * @param verbosity The value to set the verbosity to.
213
+ */
171
214
inline void set_log_verbosity (int verbosity) {
172
215
log_verbosity = verbosity;
173
216
}
@@ -176,15 +219,23 @@ class ClusterLegalizer {
176
219
177
220
void reset ();
178
221
222
+ // / @brief Destructor of the class. Calls the reset method.
179
223
~ClusterLegalizer () { reset (); }
180
224
181
225
// TODO: This should be a vector.
226
+ // FIXME: Make this private and create a getter. This may need to be left
227
+ // accessible.
228
+ // FIXME: Something fishy is going on with this. See update_cluster_stats.
229
+ // Need to cross-reference and see what matters and what doesnt for
230
+ // legalization. What variables do we touch and does this function
231
+ // touch it!
182
232
t_cluster_placement_stats* cluster_placement_stats = nullptr ;
183
233
184
234
private:
185
235
// / @brief Lookup table for which cluster each molecule is in.
186
236
std::unordered_map<t_pack_molecule*, LegalizationClusterId> molecule_cluster;
187
-
237
+
238
+ // / @brief List of all legalization clusters.
188
239
vtr::vector<LegalizationClusterId, LegalizationCluster> legalization_clusters;
189
240
190
241
// FIXME: This can be made a vector if the atom netlist is passed into init.
@@ -205,8 +256,8 @@ class ClusterLegalizer {
205
256
206
257
size_t num_models;
207
258
208
- // TODO: Make this a better enum (enum class) .
209
- int detailed_routing_stage ;
259
+ // / @brief The current legalization strategy of the cluster legalizer .
260
+ ClusterLegalizationStrategy cluster_legalization_strategy ;
210
261
211
262
bool enable_pin_feasibility_filter;
212
263
0 commit comments