Skip to content

Commit b25f941

Browse files
authored
Merge pull request #2178 from verilog-to-routing/tight_floor_plan_bugs
tight floor plan memory leak bugs
2 parents 7cd983f + 11053b8 commit b25f941

File tree

18 files changed

+303
-42
lines changed

18 files changed

+303
-42
lines changed

libs/libarchfpga/src/cad_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ 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+
}
123127
t_pb_graph_node* pb_graph_node;
124128
t_cluster_placement_primitive* next_primitive;
125129
bool valid;

libs/librrgraph/src/io/gen/rr_graph_uxsdcxx.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,6 +2072,7 @@ inline enum_loc_side lex_enum_loc_side(const char *in, bool throw_on_invalid, co
20722072
/* Internal loading functions, which validate and load a PugiXML DOM tree into memory. */
20732073
inline int load_int(const char *in, const std::function<void(const char *)> * report_error){
20742074
int out;
2075+
errno = 0;
20752076
out = std::strtol(in, NULL, 10);
20762077
if(errno != 0)
20772078
noreturn_report(report_error, ("Invalid value `" + std::string(in) + "` when loading into a int.").c_str());
@@ -2080,6 +2081,7 @@ inline int load_int(const char *in, const std::function<void(const char *)> * re
20802081

20812082
inline unsigned int load_unsigned_int(const char *in, const std::function<void(const char *)> * report_error){
20822083
unsigned int out;
2084+
errno = 0;
20832085
out = std::strtoul(in, NULL, 10);
20842086
if(errno != 0)
20852087
noreturn_report(report_error, ("Invalid value `" + std::string(in) + "` when loading into a unsigned int.").c_str());
@@ -2088,6 +2090,7 @@ inline unsigned int load_unsigned_int(const char *in, const std::function<void(c
20882090

20892091
inline float load_float(const char *in, const std::function<void(const char *)> * report_error){
20902092
float out;
2093+
errno = 0;
20912094
out = std::strtof(in, NULL);
20922095
if(errno != 0)
20932096
noreturn_report(report_error, ("Invalid value `" + std::string(in) + "` when loading into a float.").c_str());

vpr/src/base/gen/vpr_constraints_uxsdcxx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ template<std::size_t N>
427427
/* Internal loading functions, which validate and load a PugiXML DOM tree into memory. */
428428
inline int load_int(const char* in, const std::function<void(const char*)>* report_error) {
429429
int out;
430+
errno = 0;
430431
out = std::strtol(in, NULL, 10);
431432
if (errno != 0)
432433
noreturn_report(report_error, ("Invalid value `" + std::string(in) + "` when loading into a int.").c_str());

vpr/src/base/vpr_api.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,12 +395,6 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
395395
vpr_analysis_flow(vpr_setup, arch, route_status, is_flat);
396396
}
397397

398-
//clean packing-placement data
399-
if (vpr_setup.PackerOpts.doPacking == STAGE_DO) {
400-
auto& helper_ctx = g_vpr_ctx.mutable_cl_helper();
401-
free_cluster_placement_stats(helper_ctx.cluster_placement_stats);
402-
}
403-
404398
//close the graphics
405399
vpr_close_graphics(vpr_setup);
406400

vpr/src/base/vpr_context.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,6 @@ struct ClusteringHelperContext : public Context {
325325

326326
// the utilization of external input/output pins during packing (between 0 and 1)
327327
t_ext_pin_util_targets target_external_pin_util;
328-
329-
~ClusteringHelperContext() {
330-
delete[] primitives_list;
331-
}
332328
};
333329

334330
/**

vpr/src/pack/cluster_placement.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ static void load_cluster_placement_stats_for_pb_graph_node(t_cluster_placement_s
261261
const t_pb_type* pb_type = pb_graph_node->pb_type;
262262
bool success;
263263
if (pb_type->modes == nullptr) {
264-
placement_primitive = new t_cluster_placement_primitive;
265-
*placement_primitive = t_cluster_placement_primitive();
264+
placement_primitive = new t_cluster_placement_primitive();
266265
placement_primitive->pb_graph_node = pb_graph_node;
267266
placement_primitive->valid = true;
268267
pb_graph_node->cluster_placement_primitive = placement_primitive;
@@ -274,8 +273,7 @@ static void load_cluster_placement_stats_for_pb_graph_node(t_cluster_placement_s
274273
|| cluster_placement_stats->valid_primitives[i]->next_primitive->pb_graph_node->pb_type
275274
== pb_graph_node->pb_type) {
276275
if (cluster_placement_stats->valid_primitives[i] == nullptr) {
277-
cluster_placement_stats->valid_primitives[i] = new t_cluster_placement_primitive; /* head of linked list is empty, makes it easier to remove nodes later */
278-
*cluster_placement_stats->valid_primitives[i] = t_cluster_placement_primitive();
276+
cluster_placement_stats->valid_primitives[i] = new t_cluster_placement_primitive(); /* head of linked list is empty, makes it easier to remove nodes later */
279277
cluster_placement_stats->num_pb_types++;
280278
}
281279
success = true;

vpr/src/pack/pack.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ bool try_pack(t_packer_opts* packer_opts,
246246
}
247247

248248
//Reset clustering for re-packing
249-
g_vpr_ctx.mutable_clustering().clb_nlist = ClusteredNetlist();
250249
for (auto blk : g_vpr_ctx.atom().nlist.blocks()) {
251250
g_vpr_ctx.mutable_atom().lookup.set_atom_clb(blk, ClusterBlockId::INVALID());
252251
g_vpr_ctx.mutable_atom().lookup.set_atom_pb(blk, nullptr);
@@ -257,6 +256,9 @@ bool try_pack(t_packer_opts* packer_opts,
257256
g_vpr_ctx.mutable_floorplanning().cluster_constraints.clear();
258257
//attraction_groups.reset_attraction_groups();
259258

259+
free_cluster_placement_stats(helper_ctx.cluster_placement_stats);
260+
delete[] helper_ctx.primitives_list;
261+
260262
++pack_iteration;
261263
}
262264

vpr/src/pack/pb_type_graph.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ void alloc_and_load_all_pb_graphs(bool load_power_structures, bool is_flat) {
141141

142142
for (auto& type : device_ctx.logical_block_types) {
143143
if (type.pb_type) {
144-
type.pb_graph_head = new t_pb_graph_node;
145-
*type.pb_graph_head = t_pb_graph_node();
144+
type.pb_graph_head = new t_pb_graph_node();
146145
int pin_count_in_cluster = 0;
147146
alloc_and_load_pb_graph(type.pb_graph_head, nullptr,
148147
type.pb_type, 0, load_power_structures, pin_count_in_cluster);
@@ -324,8 +323,7 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
324323

325324
/* Power */
326325
if (load_power_structures) {
327-
pb_graph_node->pb_node_power = new t_pb_graph_node_power;
328-
*pb_graph_node->pb_node_power = t_pb_graph_node_power();
326+
pb_graph_node->pb_node_power = new t_pb_graph_node_power();
329327
pb_graph_node->pb_node_power->transistor_cnt_buffers = 0.;
330328
pb_graph_node->pb_node_power->transistor_cnt_interc = 0.;
331329
pb_graph_node->pb_node_power->transistor_cnt_pb_children = 0.;

vpr/src/pack/prepack.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,7 @@ static void forward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expansi
493493
// a primitive that belongs to this pack pattern is found: 1) create a new pattern block,
494494
// 2) assign an id to this pattern block, 3) increment the number of found blocks belonging to this
495495
// pattern and 4) expand all its edges to find the other primitives that belong to this pattern
496-
destination_block = new t_pack_pattern_block;
497-
*destination_block = t_pack_pattern_block();
496+
destination_block = new t_pack_pattern_block();
498497
list_of_packing_patterns[curr_pattern_index].base_cost += compute_primitive_base_cost(destination_pb_graph_node);
499498
destination_block->block_id = *L_num_blocks;
500499
(*L_num_blocks)++;
@@ -635,8 +634,7 @@ static void backward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expans
635634
/* If this pb_graph_node is part not of the current pattern index, put it in and expand all its edges */
636635
source_block = (t_pack_pattern_block*)source_pb_graph_node->temp_scratch_pad;
637636
if (source_block == nullptr || source_block->pattern_index != curr_pattern_index) {
638-
source_block = new t_pack_pattern_block;
639-
*source_block = t_pack_pattern_block();
637+
source_block = new t_pack_pattern_block();
640638
source_block->block_id = *L_num_blocks;
641639
(*L_num_blocks)++;
642640
list_of_packing_patterns[curr_pattern_index].base_cost += compute_primitive_base_cost(source_pb_graph_node);
@@ -693,17 +691,15 @@ static void backward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expans
693691
if (destination_pin != nullptr) {
694692
VTR_ASSERT(((t_pack_pattern_block*)source_pb_graph_node->temp_scratch_pad)->pattern_index == curr_pattern_index);
695693
source_block = (t_pack_pattern_block*)source_pb_graph_node->temp_scratch_pad;
696-
pack_pattern_connection = new t_pack_pattern_connections;
697-
*pack_pattern_connection = t_pack_pattern_connections();
694+
pack_pattern_connection = new t_pack_pattern_connections();
698695
pack_pattern_connection->from_block = source_block;
699696
pack_pattern_connection->from_pin = expansion_edge->input_pins[i];
700697
pack_pattern_connection->to_block = destination_block;
701698
pack_pattern_connection->to_pin = destination_pin;
702699
pack_pattern_connection->next = source_block->connections;
703700
source_block->connections = pack_pattern_connection;
704701

705-
pack_pattern_connection = new t_pack_pattern_connections;
706-
*pack_pattern_connection = t_pack_pattern_connections();
702+
pack_pattern_connection = new t_pack_pattern_connections();
707703
pack_pattern_connection->from_block = source_block;
708704
pack_pattern_connection->from_pin = expansion_edge->input_pins[i];
709705
pack_pattern_connection->to_block = destination_block;

vtr_flow/tasks/regression_tests/vtr_reg_nightly_test5/vpr_tight_floorplan/stratixiv_arch_neuron.timing.xml renamed to vtr_flow/arch/titan/stratixiv_arch_neuron.timing.xml

File renamed without changes.

0 commit comments

Comments
 (0)