Skip to content

Commit 10135ae

Browse files
committed
fixed bad array new length errors
1 parent 80d639d commit 10135ae

File tree

8 files changed

+65
-26
lines changed

8 files changed

+65
-26
lines changed

libs/libarchfpga/src/physical_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,9 +1235,9 @@ class t_pb_graph_pin {
12351235
public:
12361236
t_port* port = nullptr;
12371237
int pin_number = 0;
1238-
std::vector<t_pb_graph_edge*> input_edges{nullptr}; /* [0..num_input_edges] */
1238+
std::vector<t_pb_graph_edge*> input_edges; /* [0..num_input_edges] */
12391239
int num_input_edges = 0;
1240-
std::vector<t_pb_graph_edge*> output_edges{nullptr}; /* [0..num_output_edges] */
1240+
std::vector<t_pb_graph_edge*> output_edges; /* [0..num_output_edges] */
12411241
int num_output_edges = 0;
12421242

12431243
t_pb_graph_node* parent_node = nullptr;

vpr/src/pack/cluster.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
189189
get_max_cluster_size_and_pb_depth(helper_ctx.max_cluster_size, max_pb_depth);
190190

191191
if (packer_opts.hill_climbing_flag) {
192-
clustering_data.hill_climbing_inputs_avail = new int[helper_ctx.max_cluster_size + 1]{0};
192+
clustering_data.hill_climbing_inputs_avail = new int[helper_ctx.max_cluster_size + 1];
193+
for(int i = 0 ; i < helper_ctx.max_cluster_size + 1; i++)
194+
clustering_data.hill_climbing_inputs_avail[i] = 0;
193195
} else {
194196
clustering_data.hill_climbing_inputs_avail = nullptr; /* if used, die hard */
195197
}

vpr/src/pack/cluster_placement.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ t_cluster_placement_stats* alloc_and_load_cluster_placement_stats() {
6565
for (const auto& type : device_ctx.logical_block_types) {
6666
cluster_placement_stats_list[type.index] = t_cluster_placement_stats();
6767
if (!is_empty_type(&type)) {
68-
cluster_placement_stats_list[type.index].valid_primitives = new t_cluster_placement_primitive* [get_max_primitives_in_pb_type(type.pb_type) + 1] { nullptr };
68+
cluster_placement_stats_list[type.index].valid_primitives = new t_cluster_placement_primitive* [get_max_primitives_in_pb_type(type.pb_type) + 1];
69+
for (int i = 0 ; i < get_max_primitives_in_pb_type(type.pb_type) + 1; i ++)
70+
cluster_placement_stats_list[type.index].valid_primitives[i] = nullptr;
71+
6972
/* too much memory allocated but shouldn't be a problem */
7073
cluster_placement_stats_list[type.index].curr_molecule = nullptr;
7174
load_cluster_placement_stats_for_pb_graph_node(&cluster_placement_stats_list[type.index],

vpr/src/pack/cluster_util.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,9 @@ void alloc_and_init_clustering(const t_molecule_stats& max_molecule_stats,
577577
}
578578
cur_molecule = cur_molecule->next;
579579
}
580-
*primitives_list = new t_pb_graph_node* [max_molecule_size] { nullptr };
580+
*primitives_list = new t_pb_graph_node* [max_molecule_size];
581+
for (int i = 0 ; i < max_molecule_size; i ++)
582+
(*primitives_list)[i] = nullptr;
581583
}
582584

583585
/*****************************************/
@@ -813,6 +815,8 @@ void alloc_and_load_pb_stats(t_pb* pb, const int feasible_block_array_size) {
813815
pb->pb_stats->lookahead_output_pins_used = std::vector<std::vector<AtomNetId>>(pb->pb_graph_node->num_output_pin_class);
814816
pb->pb_stats->num_feasible_blocks = NOT_VALID;
815817
pb->pb_stats->feasible_blocks = new t_pack_molecule*[feasible_block_array_size];
818+
for (int i = 0 ; i < feasible_block_array_size ; i ++)
819+
pb->pb_stats->feasible_blocks[i] = nullptr;
816820

817821
pb->pb_stats->tie_break_high_fanout_net = AtomNetId::INVALID();
818822

vpr/src/pack/lb_type_rr_graph.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,12 @@ static void alloc_and_load_lb_type_rr_graph_for_pb_graph_node(const t_pb_graph_n
351351
/* alloc and load rr node info */
352352
lb_type_rr_node_graph[pin_index].capacity = 1;
353353
lb_type_rr_node_graph[pin_index].num_modes = num_modes;
354-
lb_type_rr_node_graph[pin_index].num_fanout = new short[num_modes]{0};
354+
lb_type_rr_node_graph[pin_index].num_fanout = new short[num_modes];
355355
lb_type_rr_node_graph[pin_index].outedges = new t_lb_type_rr_node_edge*[num_modes];
356-
for (int i = 0; i < num_modes; i++)
356+
for (int i = 0; i < num_modes; i++){
357357
lb_type_rr_node_graph[pin_index].outedges[i] = nullptr;
358+
lb_type_rr_node_graph[pin_index].num_fanout[i] = 0;
359+
}
358360
lb_type_rr_node_graph[pin_index].pb_graph_pin = pb_pin;
359361

360362
/* Count number of mode-dependant fanout */
@@ -448,10 +450,12 @@ static void alloc_and_load_lb_type_rr_graph_for_pb_graph_node(const t_pb_graph_n
448450
/* alloc and load rr node info */
449451
lb_type_rr_node_graph[pin_index].capacity = 1;
450452
lb_type_rr_node_graph[pin_index].num_modes = num_modes;
451-
lb_type_rr_node_graph[pin_index].num_fanout = new short[num_modes]{0};
453+
lb_type_rr_node_graph[pin_index].num_fanout = new short[num_modes];
452454
lb_type_rr_node_graph[pin_index].outedges = new t_lb_type_rr_node_edge*[num_modes];
453-
for (int i = 0; i < num_modes; i++)
455+
for (int i = 0; i < num_modes; i++){
454456
lb_type_rr_node_graph[pin_index].outedges[i] = nullptr;
457+
lb_type_rr_node_graph[pin_index].num_fanout[i] = 0;
458+
}
455459
lb_type_rr_node_graph[pin_index].pb_graph_pin = pb_pin;
456460

457461
/* Count number of mode-dependant out-going edges */
@@ -501,10 +505,12 @@ static void alloc_and_load_lb_type_rr_graph_for_pb_graph_node(const t_pb_graph_n
501505
/* alloc and load rr node info */
502506
lb_type_rr_node_graph[pin_index].capacity = 1;
503507
lb_type_rr_node_graph[pin_index].num_modes = num_modes;
504-
lb_type_rr_node_graph[pin_index].num_fanout = new short[num_modes]{0};
508+
lb_type_rr_node_graph[pin_index].num_fanout = new short[num_modes];
505509
lb_type_rr_node_graph[pin_index].outedges = new t_lb_type_rr_node_edge*[num_modes];
506-
for (int i = 0; i < num_modes; i++)
510+
for (int i = 0; i < num_modes; i++){
507511
lb_type_rr_node_graph[pin_index].outedges[i] = nullptr;
512+
lb_type_rr_node_graph[pin_index].num_fanout[i] = 0;
513+
}
508514
lb_type_rr_node_graph[pin_index].pb_graph_pin = pb_pin;
509515

510516
/* One edge to external sinks */
@@ -532,10 +538,12 @@ static void alloc_and_load_lb_type_rr_graph_for_pb_graph_node(const t_pb_graph_n
532538
/* alloc and load rr node info */
533539
lb_type_rr_node_graph[pin_index].capacity = 1;
534540
lb_type_rr_node_graph[pin_index].num_modes = num_modes;
535-
lb_type_rr_node_graph[pin_index].num_fanout = new short[num_modes]{0};
541+
lb_type_rr_node_graph[pin_index].num_fanout = new short[num_modes];
536542
lb_type_rr_node_graph[pin_index].outedges = new t_lb_type_rr_node_edge*[num_modes];
537-
for (int i = 0; i < num_modes; i++)
543+
for (int i = 0; i < num_modes; i++){
538544
lb_type_rr_node_graph[pin_index].outedges[i] = nullptr;
545+
lb_type_rr_node_graph[pin_index].num_fanout[i] = 0;
546+
}
539547
lb_type_rr_node_graph[pin_index].pb_graph_pin = pb_pin;
540548

541549
/* Count number of mode-dependant out-going edges */
@@ -582,10 +590,12 @@ static void alloc_and_load_lb_type_rr_graph_for_pb_graph_node(const t_pb_graph_n
582590
/* alloc and load rr node info */
583591
lb_type_rr_node_graph[pin_index].capacity = 1;
584592
lb_type_rr_node_graph[pin_index].num_modes = num_modes;
585-
lb_type_rr_node_graph[pin_index].num_fanout = new short[num_modes]{0};
593+
lb_type_rr_node_graph[pin_index].num_fanout = new short[num_modes];
586594
lb_type_rr_node_graph[pin_index].outedges = new t_lb_type_rr_node_edge*[num_modes];
587-
for (int i = 0; i < num_modes; i++)
595+
for (int i = 0; i < num_modes; i++){
588596
lb_type_rr_node_graph[pin_index].outedges[i] = nullptr;
597+
lb_type_rr_node_graph[pin_index].num_fanout[i] = 0;
598+
}
589599
lb_type_rr_node_graph[pin_index].pb_graph_pin = pb_pin;
590600

591601
/* Count number of mode-dependant out-going edges */

vpr/src/pack/output_clustering.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,15 @@ static void print_stats() {
5252

5353
num_clb_types = num_clb_inputs_used = num_clb_outputs_used = nullptr;
5454

55-
num_clb_types = new int[device_ctx.logical_block_types.size()]{0};
56-
num_clb_inputs_used = new int[device_ctx.logical_block_types.size()]{0};
57-
num_clb_outputs_used = new int[device_ctx.logical_block_types.size()]{0};
55+
num_clb_types = new int[device_ctx.logical_block_types.size()];
56+
num_clb_inputs_used = new int[device_ctx.logical_block_types.size()];
57+
num_clb_outputs_used = new int[device_ctx.logical_block_types.size()];
58+
59+
for (int i = 0 ; i < device_ctx.logical_block_types.size(); i ++){
60+
num_clb_types[i] = 0;
61+
num_clb_inputs_used[i] = 0;
62+
num_clb_outputs_used[i] = 0;
63+
}
5864

5965
for (auto net_id : atom_ctx.nlist.nets()) {
6066
nets_absorbed[net_id] = true;

vpr/src/pack/pb_type_graph.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ static void alloc_and_load_mode_interconnect(t_pb_graph_node* pb_graph_parent_no
520520
if (mode->num_interconnect > 0) {
521521
pb_graph_parent_node->interconnect_pins[mode->index] = new t_interconnect_pins[mode->num_interconnect];
522522
}
523-
for (int i = 0; i < mode->num_interconnect; i++)
523+
for (i = 0; i < mode->num_interconnect; i++)
524524
pb_graph_parent_node->interconnect_pins[mode->index][i] = t_interconnect_pins();
525525
}
526526

@@ -645,8 +645,13 @@ t_pb_graph_pin*** alloc_and_load_port_pin_ptrs_from_string(const int line_num,
645645
"No matching '{' for '}' in port %s\n", port_string);
646646
}
647647

648-
pb_graph_pins = new t_pb_graph_pin** [*num_sets] { nullptr };
649-
*num_ptrs = new int[*num_sets]{0};
648+
pb_graph_pins = new t_pb_graph_pin** [*num_sets];
649+
*num_ptrs = new int[*num_sets];
650+
for (int i = 0 ; i < *num_sets; i ++){
651+
pb_graph_pins[i] = nullptr;
652+
(*num_ptrs)[i] = 0;
653+
}
654+
650655

651656
curr_set = 0;
652657
for (i = 0; i < num_tokens; i++) {
@@ -908,8 +913,13 @@ static void alloc_and_load_mux_interc_edges(t_interconnect* interconnect,
908913
vpr_throw(VPR_ERROR_ARCH, get_arch_file_name(), interconnect->line_num,
909914
"# of pins for a particular data line of a mux must equal number of pins at output of mux\n");
910915
}
911-
edges[i_inset].input_pins = new t_pb_graph_pin* [num_output_ptrs[0]] { nullptr };
912-
edges[i_inset].output_pins = new t_pb_graph_pin* [num_output_ptrs[0]] { nullptr };
916+
edges[i_inset].input_pins = new t_pb_graph_pin* [num_output_ptrs[0]];
917+
edges[i_inset].output_pins = new t_pb_graph_pin* [num_output_ptrs[0]];
918+
for (int i = 0 ; i < num_output_ptrs[0] ; i ++){
919+
edges[i_inset].input_pins[i] = nullptr;
920+
edges[i_inset].output_pins[i] = nullptr;
921+
}
922+
913923
edges[i_inset].num_input_pins = num_output_ptrs[0];
914924
edges[i_inset].num_output_pins = num_output_ptrs[0];
915925
for (i_inpin = 0; i_inpin < num_input_ptrs[i_inset]; i_inpin++) {

vpr/src/pack/prepack.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,10 @@ void free_list_of_pack_patterns(std::vector<t_pack_patterns>& list_of_pack_patte
352352
void free_pack_pattern(t_pack_patterns* pack_pattern) {
353353
if (pack_pattern) {
354354
int num_pack_pattern_blocks = pack_pattern->num_blocks;
355-
t_pack_pattern_block** pattern_block_list = new t_pack_pattern_block* [num_pack_pattern_blocks] { nullptr };
355+
t_pack_pattern_block** pattern_block_list = new t_pack_pattern_block* [num_pack_pattern_blocks];
356+
for (int i = 0 ; i < num_pack_pattern_blocks ; i++)
357+
pattern_block_list[i] = nullptr;
358+
356359
free(pack_pattern->name);
357360
delete[](pack_pattern->is_block_optional);
358361
free_pack_pattern_block(pack_pattern->root_block, pattern_block_list);
@@ -783,8 +786,9 @@ t_pack_molecule* alloc_and_load_pack_molecules(t_pack_patterns* list_of_pack_pat
783786
auto& atom_ctx = g_vpr_ctx.atom();
784787
auto& atom_mutable_ctx = g_vpr_ctx.mutable_atom();
785788

786-
if (num_packing_patterns > 0)
787-
is_used = new bool[num_packing_patterns]{false};
789+
is_used = new bool[num_packing_patterns];
790+
for (int i = 0; i < num_packing_patterns; i++)
791+
is_used[i] = false;
788792

789793
cur_molecule = list_of_molecules_head = nullptr;
790794

0 commit comments

Comments
 (0)