From f9b3cd7e9b675bd6a386d674b54d7ec7f8bd96ae Mon Sep 17 00:00:00 2001 From: KA7E Date: Wed, 5 Jun 2024 13:15:10 -0400 Subject: [PATCH 1/3] add flat idx to pb_graph_node and modifed alloc_and_load... to populate it --- libs/libarchfpga/src/physical_types.h | 3 +++ vpr/src/pack/pb_type_graph.cpp | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/libs/libarchfpga/src/physical_types.h b/libs/libarchfpga/src/physical_types.h index f71a942ec60..b0f623d4539 100644 --- a/libs/libarchfpga/src/physical_types.h +++ b/libs/libarchfpga/src/physical_types.h @@ -1225,6 +1225,7 @@ struct t_pin_to_pin_annotation { * parent_pb_graph_node : parent pb graph node * total_primitive_count : Total number of this primitive type in the cluster. If there are 10 ALMs per cluster * and 2 FFs per ALM (given the mode of the parent of this primitive) then the total is 20. + * flat_site_index : index of this primitive within its primitive type in this cluster; in [0,...,total_primitive_count] * illegal_modes : vector containing illegal modes that result in conflicts during routing */ class t_pb_graph_node { @@ -1281,6 +1282,8 @@ class t_pb_graph_node { int num_output_pin_class; /* number of output pin classes that this pb_graph_node has */ int total_primitive_count; /* total number of this primitive type in the cluster */ + int flat_site_index; /* index of this primitive within sites of its type in this cluster */ + /* Interconnect instances for this pb * Only used for power diff --git a/vpr/src/pack/pb_type_graph.cpp b/vpr/src/pack/pb_type_graph.cpp index 72467921f21..20e32c3b025 100644 --- a/vpr/src/pack/pb_type_graph.cpp +++ b/vpr/src/pack/pb_type_graph.cpp @@ -48,6 +48,7 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node, t_pb_graph_node* parent_pb_graph_node, t_pb_type* pb_type, const int index, + const int flat_index, bool load_power_structures, int& pin_count_in_cluster); @@ -151,6 +152,7 @@ void alloc_and_load_all_pb_graphs(bool load_power_structures, bool is_flat) { nullptr, type.pb_type, 0, + 0, load_power_structures, pin_count_in_cluster); type.pb_graph_head->total_pb_pins = pin_count_in_cluster; @@ -224,6 +226,7 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node, t_pb_graph_node* parent_pb_graph_node, t_pb_type* pb_type, const int index, + const int flat_index, bool load_power_structures, int& pin_count_in_cluster) { int i, j, k, i_input, i_output, i_clockport; @@ -237,6 +240,7 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node, pb_graph_node->num_clock_ports = 0; pb_graph_node->total_primitive_count = 0; + pb_graph_node->flat_site_index = flat_index; /* Generate ports for pb graph node */ for (i = 0; i < pb_type->num_ports; i++) { @@ -349,11 +353,14 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node, sizeof(t_pb_graph_node*)); for (j = 0; j < pb_type->modes[i].num_pb_type_children; j++) { pb_graph_node->child_pb_graph_nodes[i][j] = (t_pb_graph_node*)vtr::calloc(pb_type->modes[i].pb_type_children[j].num_pb, sizeof(t_pb_graph_node)); + int base = flat_index*(pb_type->modes[i].pb_type_children[j].num_pb); + for (k = 0; k < pb_type->modes[i].pb_type_children[j].num_pb; k++) { alloc_and_load_pb_graph(&pb_graph_node->child_pb_graph_nodes[i][j][k], pb_graph_node, &pb_type->modes[i].pb_type_children[j], k, + base + k, load_power_structures, pin_count_in_cluster); } From 2918b9dc660ee58f931f554059b6e583d785d6db Mon Sep 17 00:00:00 2001 From: KA7E Date: Sat, 8 Jun 2024 19:16:53 -0400 Subject: [PATCH 2/3] updated comments, added subrouting for flat index computation --- libs/libarchfpga/src/physical_types.h | 7 +++++- vpr/src/pack/pb_type_graph.cpp | 35 ++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/libs/libarchfpga/src/physical_types.h b/libs/libarchfpga/src/physical_types.h index b0f623d4539..4dcf2a4aedf 100644 --- a/libs/libarchfpga/src/physical_types.h +++ b/libs/libarchfpga/src/physical_types.h @@ -1225,7 +1225,12 @@ struct t_pin_to_pin_annotation { * parent_pb_graph_node : parent pb graph node * total_primitive_count : Total number of this primitive type in the cluster. If there are 10 ALMs per cluster * and 2 FFs per ALM (given the mode of the parent of this primitive) then the total is 20. - * flat_site_index : index of this primitive within its primitive type in this cluster; in [0,...,total_primitive_count] + * This member is only used by nodes corresponding to primitive sites. + * flat_site_index : Index of this primitive site within its primitive type within this cluster type. + * Values are in [0...total_primitive_count-1], e.g. if there are 10 ALMs per cluster, 2 FFS + * and 2 LUTs per ALM, then flat site indices for FFs would run from 0 to 19, and flat site + indices for LUTs would run from 0 to 19. This member is only used by nodes corresponding + to primitive sites. It is used when reconstructing clusters from a flat placement file. * illegal_modes : vector containing illegal modes that result in conflicts during routing */ class t_pb_graph_node { diff --git a/vpr/src/pack/pb_type_graph.cpp b/vpr/src/pack/pb_type_graph.cpp index 20e32c3b025..169dc5562eb 100644 --- a/vpr/src/pack/pb_type_graph.cpp +++ b/vpr/src/pack/pb_type_graph.cpp @@ -134,6 +134,9 @@ static bool check_input_pins_equivalence(const t_pb_graph_pin* cur_pin, const int i_pin, std::map& edges_map, int* line_num); +static int compute_flat_index_for_child_node(int num_children_of_type, + int parent_flat_index, + int child_index); /** * Allocate memory into types and load the pb graph with interconnect edges @@ -240,7 +243,7 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node, pb_graph_node->num_clock_ports = 0; pb_graph_node->total_primitive_count = 0; - pb_graph_node->flat_site_index = flat_index; + pb_graph_node->flat_site_index = 0; /* Generate ports for pb graph node */ for (i = 0; i < pb_type->num_ports; i++) { @@ -353,14 +356,15 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node, sizeof(t_pb_graph_node*)); for (j = 0; j < pb_type->modes[i].num_pb_type_children; j++) { pb_graph_node->child_pb_graph_nodes[i][j] = (t_pb_graph_node*)vtr::calloc(pb_type->modes[i].pb_type_children[j].num_pb, sizeof(t_pb_graph_node)); - int base = flat_index*(pb_type->modes[i].pb_type_children[j].num_pb); + int num_children_of_type = pb_type->modes[i].pb_type_children[j].num_pb; - for (k = 0; k < pb_type->modes[i].pb_type_children[j].num_pb; k++) { + for (k = 0; k < num_children_of_type; k++) { + int child_flat_index = compute_flat_index_for_child_node(num_children_of_type, flat_index, k); alloc_and_load_pb_graph(&pb_graph_node->child_pb_graph_nodes[i][j][k], pb_graph_node, &pb_type->modes[i].pb_type_children[j], k, - base + k, + child_flat_index, load_power_structures, pin_count_in_cluster); } @@ -387,6 +391,10 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node, pb_node = pb_node->parent_pb_graph_node; } pb_graph_node->total_primitive_count = total_count; + + // if this is a primitive, then flat_index corresponds + // to its index within all primitives of this type + pb_graph_node->flat_site_index = flat_index; } } @@ -1921,3 +1929,22 @@ const t_pb_graph_edge* get_edge_between_pins(const t_pb_graph_pin* driver_pin, c return nullptr; } + +/* Date:June 8th, 2024 + * Author: Kate Thurmer + * Purpose: This subroutine computes the index of a pb graph node at its + level of the pb hierarchy; it is computed by the parent and + passed to each child of each child pb type. When the child is + a primitive, the computed indes is its flat site index. + For example, if there are 10 ALMs, each with 2 FFs and 2 LUTs, + then the ALM at index N, when calling this function for + its FF child at index M, would compute the child's index as: + N*(FFs per ALM) + M + e.g. for FF[1] in ALM[5], this returns + 5*(2 FFS per ALM) + 1 = 11 + */ +static int compute_flat_index_for_child_node(int num_children_of_type, + int parent_flat_index, + int child_index) { + return parent_flat_index*num_children_of_type + child_index; +} From bf3bdf03610d4e55f40a9fac47a6b8347b80d663 Mon Sep 17 00:00:00 2001 From: KA7E Date: Tue, 11 Jun 2024 13:01:13 -0400 Subject: [PATCH 3/3] added comments --- vpr/src/pack/pb_type_graph.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vpr/src/pack/pb_type_graph.cpp b/vpr/src/pack/pb_type_graph.cpp index 169dc5562eb..c1cbed18430 100644 --- a/vpr/src/pack/pb_type_graph.cpp +++ b/vpr/src/pack/pb_type_graph.cpp @@ -134,6 +134,8 @@ static bool check_input_pins_equivalence(const t_pb_graph_pin* cur_pin, const int i_pin, std::map& edges_map, int* line_num); + +/* computes the index of a pb graph node at its level of the pb hierarchy */ static int compute_flat_index_for_child_node(int num_children_of_type, int parent_flat_index, int child_index);