Skip to content

Commit 9ba0718

Browse files
Clean up prepacker
This commit changes two functions in the prepacker to get the specific element of the array they work with and not the entire array.
1 parent fbb2d1c commit 9ba0718

File tree

1 file changed

+26
-39
lines changed

1 file changed

+26
-39
lines changed

vpr/src/pack/prepack.cpp

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,12 @@ static t_pb_graph_edge* find_expansion_edge_of_pattern(const int pattern_index,
5353
const t_pb_graph_node* pb_graph_node);
5454

5555
static void forward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expansion_edge,
56-
std::vector<t_pack_patterns>& list_of_packing_patterns,
57-
const int curr_pattern_index,
56+
t_pack_patterns& packing_pattern,
5857
int* L_num_blocks,
5958
const bool make_root_of_chain);
6059

6160
static void backward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expansion_edge,
62-
std::vector<t_pack_patterns>& list_of_packing_patterns,
63-
const int curr_pattern_index,
61+
t_pack_patterns& packing_pattern,
6462
t_pb_graph_pin* destination_pin,
6563
t_pack_pattern_block* destination_block,
6664
int* L_num_blocks);
@@ -160,7 +158,7 @@ static std::vector<t_pack_patterns> alloc_and_load_pack_patterns(const std::vect
160158
list_of_packing_patterns[i].base_cost = 0;
161159
// use the found expansion edge to build the pack pattern
162160
backward_expand_pack_pattern_from_edge(expansion_edge,
163-
list_of_packing_patterns, i, nullptr, nullptr, &L_num_blocks);
161+
list_of_packing_patterns[i], nullptr, nullptr, &L_num_blocks);
164162
list_of_packing_patterns[i].num_blocks = L_num_blocks;
165163

166164
/* Default settings: A section of a netlist must match all blocks in a pack
@@ -468,15 +466,15 @@ static t_pb_graph_edge* find_expansion_edge_of_pattern(const int pattern_index,
468466
* future multi-fanout support easier) so this function will not update connections
469467
*/
470468
static void forward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expansion_edge,
471-
std::vector<t_pack_patterns>& list_of_packing_patterns,
472-
const int curr_pattern_index,
469+
t_pack_patterns& packing_pattern,
473470
int* L_num_blocks,
474471
bool make_root_of_chain) {
475472
int i, j, k;
476473
int iport, ipin, iedge;
477474
bool found; /* Error checking, ensure only one fan-out for each pattern net */
478475
t_pack_pattern_block* destination_block = nullptr;
479476
t_pb_graph_node* destination_pb_graph_node = nullptr;
477+
int curr_pattern_index = packing_pattern.index;
480478

481479
found = expansion_edge->infer_pattern;
482480
// if the pack pattern shouldn't be inferred check if the expansion
@@ -511,7 +509,7 @@ static void forward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expansi
511509
// 2) assign an id to this pattern block, 3) increment the number of found blocks belonging to this
512510
// pattern and 4) expand all its edges to find the other primitives that belong to this pattern
513511
destination_block = new t_pack_pattern_block();
514-
list_of_packing_patterns[curr_pattern_index].base_cost += compute_primitive_base_cost(destination_pb_graph_node);
512+
packing_pattern.base_cost += compute_primitive_base_cost(destination_pb_graph_node);
515513
destination_block->block_id = *L_num_blocks;
516514
(*L_num_blocks)++;
517515
destination_pb_graph_node->temp_scratch_pad = (void*)destination_block;
@@ -523,8 +521,7 @@ static void forward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expansi
523521
for (ipin = 0; ipin < destination_pb_graph_node->num_input_pins[iport]; ipin++) {
524522
for (iedge = 0; iedge < destination_pb_graph_node->input_pins[iport][ipin].num_input_edges; iedge++) {
525523
backward_expand_pack_pattern_from_edge(destination_pb_graph_node->input_pins[iport][ipin].input_edges[iedge],
526-
list_of_packing_patterns,
527-
curr_pattern_index,
524+
packing_pattern,
528525
&destination_pb_graph_node->input_pins[iport][ipin],
529526
destination_block, L_num_blocks);
530527
}
@@ -536,8 +533,7 @@ static void forward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expansi
536533
for (ipin = 0; ipin < destination_pb_graph_node->num_output_pins[iport]; ipin++) {
537534
for (iedge = 0; iedge < destination_pb_graph_node->output_pins[iport][ipin].num_output_edges; iedge++) {
538535
forward_expand_pack_pattern_from_edge(destination_pb_graph_node->output_pins[iport][ipin].output_edges[iedge],
539-
list_of_packing_patterns,
540-
curr_pattern_index, L_num_blocks, false);
536+
packing_pattern, L_num_blocks, false);
541537
}
542538
}
543539
}
@@ -547,8 +543,7 @@ static void forward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expansi
547543
for (ipin = 0; ipin < destination_pb_graph_node->num_clock_pins[iport]; ipin++) {
548544
for (iedge = 0; iedge < destination_pb_graph_node->clock_pins[iport][ipin].num_input_edges; iedge++) {
549545
backward_expand_pack_pattern_from_edge(destination_pb_graph_node->clock_pins[iport][ipin].input_edges[iedge],
550-
list_of_packing_patterns,
551-
curr_pattern_index,
546+
packing_pattern,
552547
&destination_pb_graph_node->clock_pins[iport][ipin],
553548
destination_block, L_num_blocks);
554549
}
@@ -560,8 +555,8 @@ static void forward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expansi
560555
if (((t_pack_pattern_block*)destination_pb_graph_node->temp_scratch_pad)->pattern_index == curr_pattern_index) {
561556
// if this pb_graph_node is known to be the root of the chain, update the root block and root pin
562557
if (make_root_of_chain == true) {
563-
list_of_packing_patterns[curr_pattern_index].chain_root_pins = {{expansion_edge->output_pins[i]}};
564-
list_of_packing_patterns[curr_pattern_index].root_block = destination_block;
558+
packing_pattern.chain_root_pins = {{expansion_edge->output_pins[i]}};
559+
packing_pattern.root_block = destination_block;
565560
}
566561
}
567562

@@ -571,8 +566,7 @@ static void forward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expansi
571566
for (j = 0; j < expansion_edge->output_pins[i]->num_output_edges; j++) {
572567
if (expansion_edge->output_pins[i]->output_edges[j]->infer_pattern == true) {
573568
forward_expand_pack_pattern_from_edge(expansion_edge->output_pins[i]->output_edges[j],
574-
list_of_packing_patterns,
575-
curr_pattern_index,
569+
packing_pattern,
576570
L_num_blocks,
577571
make_root_of_chain);
578572
} else {
@@ -587,12 +581,11 @@ static void forward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expansi
587581
expansion_edge->output_pins[i]->parent_node->placement_index,
588582
expansion_edge->output_pins[i]->port->name,
589583
expansion_edge->output_pins[i]->pin_number,
590-
list_of_packing_patterns[curr_pattern_index].name);
584+
packing_pattern.name);
591585
}
592586
found = true;
593587
forward_expand_pack_pattern_from_edge(expansion_edge->output_pins[i]->output_edges[j],
594-
list_of_packing_patterns,
595-
curr_pattern_index,
588+
packing_pattern,
596589
L_num_blocks,
597590
make_root_of_chain);
598591
}
@@ -610,8 +603,7 @@ static void forward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expansi
610603
* destination blocks
611604
*/
612605
static void backward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expansion_edge,
613-
std::vector<t_pack_patterns>& list_of_packing_patterns,
614-
const int curr_pattern_index,
606+
t_pack_patterns& packing_pattern,
615607
t_pb_graph_pin* destination_pin,
616608
t_pack_pattern_block* destination_block,
617609
int* L_num_blocks) {
@@ -621,6 +613,7 @@ static void backward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expans
621613
t_pack_pattern_block* source_block = nullptr;
622614
t_pb_graph_node* source_pb_graph_node = nullptr;
623615
t_pack_pattern_connections* pack_pattern_connection = nullptr;
616+
int curr_pattern_index = packing_pattern.index;
624617

625618
found = expansion_edge->infer_pattern;
626619
// if the pack pattern shouldn't be inferred check if the expansion
@@ -654,22 +647,21 @@ static void backward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expans
654647
source_block = new t_pack_pattern_block();
655648
source_block->block_id = *L_num_blocks;
656649
(*L_num_blocks)++;
657-
list_of_packing_patterns[curr_pattern_index].base_cost += compute_primitive_base_cost(source_pb_graph_node);
650+
packing_pattern.base_cost += compute_primitive_base_cost(source_pb_graph_node);
658651
source_pb_graph_node->temp_scratch_pad = (void*)source_block;
659652
source_block->pattern_index = curr_pattern_index;
660653
source_block->pb_type = source_pb_graph_node->pb_type;
661654

662-
if (list_of_packing_patterns[curr_pattern_index].root_block == nullptr) {
663-
list_of_packing_patterns[curr_pattern_index].root_block = source_block;
655+
if (packing_pattern.root_block == nullptr) {
656+
packing_pattern.root_block = source_block;
664657
}
665658

666659
// explore the inputs of this primitive
667660
for (iport = 0; iport < source_pb_graph_node->num_input_ports; iport++) {
668661
for (ipin = 0; ipin < source_pb_graph_node->num_input_pins[iport]; ipin++) {
669662
for (iedge = 0; iedge < source_pb_graph_node->input_pins[iport][ipin].num_input_edges; iedge++) {
670663
backward_expand_pack_pattern_from_edge(source_pb_graph_node->input_pins[iport][ipin].input_edges[iedge],
671-
list_of_packing_patterns,
672-
curr_pattern_index,
664+
packing_pattern,
673665
&source_pb_graph_node->input_pins[iport][ipin],
674666
source_block,
675667
L_num_blocks);
@@ -682,8 +674,7 @@ static void backward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expans
682674
for (ipin = 0; ipin < source_pb_graph_node->num_output_pins[iport]; ipin++) {
683675
for (iedge = 0; iedge < source_pb_graph_node->output_pins[iport][ipin].num_output_edges; iedge++) {
684676
forward_expand_pack_pattern_from_edge(source_pb_graph_node->output_pins[iport][ipin].output_edges[iedge],
685-
list_of_packing_patterns,
686-
curr_pattern_index,
677+
packing_pattern,
687678
L_num_blocks,
688679
false);
689680
}
@@ -695,8 +686,7 @@ static void backward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expans
695686
for (ipin = 0; ipin < source_pb_graph_node->num_clock_pins[iport]; ipin++) {
696687
for (iedge = 0; iedge < source_pb_graph_node->clock_pins[iport][ipin].num_input_edges; iedge++) {
697688
backward_expand_pack_pattern_from_edge(source_pb_graph_node->clock_pins[iport][ipin].input_edges[iedge],
698-
list_of_packing_patterns,
699-
curr_pattern_index,
689+
packing_pattern,
700690
&source_pb_graph_node->clock_pins[iport][ipin],
701691
source_block,
702692
L_num_blocks);
@@ -739,11 +729,10 @@ static void backward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expans
739729
if (expansion_edge->input_pins[i]->parent_node->pb_type->parent_mode == nullptr) {
740730
// This pack pattern extends to CLB (root pb block) input pin,
741731
// thus it extends across multiple logic blocks, treat as a chain
742-
list_of_packing_patterns[curr_pattern_index].is_chain = true;
732+
packing_pattern.is_chain = true;
743733
// since this input pin has not driving nets, expand in the forward direction instead
744734
forward_expand_pack_pattern_from_edge(expansion_edge,
745-
list_of_packing_patterns,
746-
curr_pattern_index,
735+
packing_pattern,
747736
L_num_blocks,
748737
true);
749738
}
@@ -754,8 +743,7 @@ static void backward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expans
754743
// if pattern should be inferred for this edge continue the expansion backwards
755744
if (expansion_edge->input_pins[i]->input_edges[j]->infer_pattern == true) {
756745
backward_expand_pack_pattern_from_edge(expansion_edge->input_pins[i]->input_edges[j],
757-
list_of_packing_patterns,
758-
curr_pattern_index,
746+
packing_pattern,
759747
destination_pin,
760748
destination_block,
761749
L_num_blocks);
@@ -768,8 +756,7 @@ static void backward_expand_pack_pattern_from_edge(const t_pb_graph_edge* expans
768756
/* Check assumption that each forced net has only one fan-out */
769757
found = true;
770758
backward_expand_pack_pattern_from_edge(expansion_edge->input_pins[i]->input_edges[j],
771-
list_of_packing_patterns,
772-
curr_pattern_index,
759+
packing_pattern,
773760
destination_pin,
774761
destination_block,
775762
L_num_blocks);

0 commit comments

Comments
 (0)