Skip to content

Commit 5166e39

Browse files
committed
revert to the version before fixing memory leaks, but making nightly_test5 well
1 parent 0942bb0 commit 5166e39

File tree

10 files changed

+184
-173
lines changed

10 files changed

+184
-173
lines changed

libs/libarchfpga/src/cad_types.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ struct t_pack_patterns {
120120
* Linked list for easy insertion/deletion
121121
*/
122122
struct t_cluster_placement_primitive {
123-
t_cluster_placement_primitive() {
124-
pb_graph_node = nullptr;
125-
next_primitive = nullptr;
126-
}
127123
t_pb_graph_node* pb_graph_node;
128124
t_cluster_placement_primitive* next_primitive;
129125
bool valid;

vpr/src/base/vpr_context.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,13 @@ struct ClusteringHelperContext : public Context {
306306
std::map<t_logical_block_type_ptr, size_t> num_used_type_instances;
307307

308308
// Stats keeper for placement information during packing/clustering
309-
std::vector<t_cluster_placement_stats> cluster_placement_stats;
309+
t_cluster_placement_stats* cluster_placement_stats;
310310

311311
// total number of models in the architecture
312312
int num_models;
313313

314314
int max_cluster_size;
315-
std::vector<t_pb_graph_node*> primitives_list;
315+
t_pb_graph_node** primitives_list;
316316

317317
bool enable_pin_feasibility_filter;
318318
int feasible_block_array_size;
@@ -327,8 +327,7 @@ struct ClusteringHelperContext : public Context {
327327
t_ext_pin_util_targets target_external_pin_util;
328328

329329
~ClusteringHelperContext() {
330-
cluster_placement_stats.clear();
331-
primitives_list.clear();
330+
delete[] primitives_list;
332331
}
333332
};
334333

vpr/src/base/vpr_types.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void free_pack_molecules(t_pack_molecule* list_of_pack_molecules) {
227227
/**
228228
* Free linked lists found in cluster_placement_stats_list
229229
*/
230-
void free_cluster_placement_stats(std::vector<t_cluster_placement_stats>& cluster_placement_stats_list) {
230+
void free_cluster_placement_stats(t_cluster_placement_stats* cluster_placement_stats_list) {
231231
t_cluster_placement_primitive *cur, *next;
232232
auto& device_ctx = g_vpr_ctx.device();
233233

@@ -260,5 +260,7 @@ void free_cluster_placement_stats(std::vector<t_cluster_placement_stats>& cluste
260260
}
261261
delete cluster_placement_stats_list[index].valid_primitives[j];
262262
}
263+
delete[] cluster_placement_stats_list[index].valid_primitives;
263264
}
265+
delete[] cluster_placement_stats_list;
264266
}

vpr/src/base/vpr_types.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,13 @@ struct t_chain_info {
426426
* Contains linked lists to placement locations based on status of primitive
427427
*/
428428
struct t_cluster_placement_stats {
429-
int num_pb_types; ///<num primitive pb_types inside complex block
430-
bool has_long_chain; ///<specifies if this cluster has a molecule placed in it that belongs to a long chain (a chain that spans more than one cluster)
431-
const t_pack_molecule* curr_molecule; ///<current molecule being considered for packing
432-
std::vector<t_cluster_placement_primitive*> valid_primitives; ///<[0..num_pb_types-1] ptrs to linked list of valid primitives, for convenience, each linked list head is empty
433-
t_cluster_placement_primitive* in_flight; ///<ptrs to primitives currently being considered
434-
t_cluster_placement_primitive* tried; ///<ptrs to primitives that are open but current logic block unable to pack to
435-
t_cluster_placement_primitive* invalid; ///<ptrs to primitives that are invalid
429+
int num_pb_types; ///<num primitive pb_types inside complex block
430+
bool has_long_chain; ///<specifies if this cluster has a molecule placed in it that belongs to a long chain (a chain that spans more than one cluster)
431+
const t_pack_molecule* curr_molecule; ///<current molecule being considered for packing
432+
t_cluster_placement_primitive** valid_primitives; ///<[0..num_pb_types-1] ptrs to linked list of valid primitives, for convenience, each linked list head is empty
433+
t_cluster_placement_primitive* in_flight; ///<ptrs to primitives currently being considered
434+
t_cluster_placement_primitive* tried; ///<ptrs to primitives that are open but current logic block unable to pack to
435+
t_cluster_placement_primitive* invalid; ///<ptrs to primitives that are invalid
436436
};
437437

438438
/******************************************************************
@@ -1673,6 +1673,6 @@ void free_pack_molecules(t_pack_molecule* list_of_pack_molecules);
16731673
/**
16741674
* @brief Free the linked lists to placement locations based on status of primitive inside placement stats data structure.
16751675
*/
1676-
void free_cluster_placement_stats(std::vector<t_cluster_placement_stats>& cluster_placement_stats);
1676+
void free_cluster_placement_stats(t_cluster_placement_stats* cluster_placement_stats);
16771677

16781678
#endif

vpr/src/pack/cluster.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
140140
bool is_cluster_legal;
141141
enum e_block_pack_status block_pack_status;
142142

143+
t_cluster_placement_stats* cur_cluster_placement_stats_ptr;
143144
t_lb_router_data* router_data = nullptr;
144145
t_pack_molecule *istart, *next_molecule, *prev_molecule;
145146

@@ -199,7 +200,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
199200
check_for_duplicate_inputs ();
200201
#endif
201202
alloc_and_init_clustering(max_molecule_stats,
202-
helper_ctx.cluster_placement_stats, helper_ctx.primitives_list, molecule_head,
203+
&(helper_ctx.cluster_placement_stats), &(helper_ctx.primitives_list), molecule_head,
203204
clustering_data, net_output_feeds_driving_block_input,
204205
unclustered_list_head_size, cluster_stats.num_molecules);
205206

@@ -299,7 +300,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
299300
/*it doesn't make sense to do a timing analysis here since there*
300301
*is only one atom block clustered it would not change anything */
301302
}
302-
303+
cur_cluster_placement_stats_ptr = &(helper_ctx.cluster_placement_stats[cluster_ctx.clb_nlist.block_type(clb_index)->index]);
303304
cluster_stats.num_unrelated_clustering_attempts = 0;
304305
next_molecule = get_molecule_for_cluster(cluster_ctx.clb_nlist.block_pb(clb_index),
305306
attraction_groups,
@@ -308,7 +309,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
308309
packer_opts.transitive_fanout_threshold,
309310
packer_opts.feasible_block_array_size,
310311
&cluster_stats.num_unrelated_clustering_attempts,
311-
helper_ctx.cluster_placement_stats[cluster_ctx.clb_nlist.block_type(clb_index)->index],
312+
cur_cluster_placement_stats_ptr,
312313
clb_inter_blk_nets,
313314
clb_index,
314315
verbosity,
@@ -337,7 +338,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
337338
prev_molecule = next_molecule;
338339

339340
try_fill_cluster(packer_opts,
340-
helper_ctx.cluster_placement_stats[cluster_ctx.clb_nlist.block_type(clb_index)->index],
341+
cur_cluster_placement_stats_ptr,
341342
prev_molecule,
342343
next_molecule,
343344
num_repeated_molecules,

0 commit comments

Comments
 (0)