Skip to content

Commit 6e20704

Browse files
check NoC group compatibility during packing
1 parent 922246a commit 6e20704

File tree

10 files changed

+86
-70
lines changed

10 files changed

+86
-70
lines changed

vpr/src/base/vpr_context.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ struct ClusteringHelperContext : public Context {
352352
// A vector of unordered_sets of AtomBlockIds that are inside each clustered block [0 .. num_clustered_blocks-1]
353353
// unordered_set for faster insertion/deletion during the iterative improvement process of packing
354354
vtr::vector<ClusterBlockId, std::unordered_set<AtomBlockId>> atoms_lookup;
355+
356+
vtr::vector<AtomBlockId, NocGroupId> atom_noc_grp_id;
357+
355358
~ClusteringHelperContext() {
356359
delete[] primitives_list;
357360
}
@@ -512,7 +515,7 @@ struct FloorplanningContext : public Context {
512515
/**
513516
* @brief State of the Network on Chip (NoC)
514517
*
515-
* This should only contain data structures related to descrbing the
518+
* This should only contain data structures related to describing the
516519
* NoC within the device.
517520
*/
518521
struct NocContext : public Context {

vpr/src/base/vpr_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ enum class e_block_pack_status {
175175
BLK_FAILED_FEASIBLE,
176176
BLK_FAILED_ROUTE,
177177
BLK_FAILED_FLOORPLANNING,
178+
BLK_FAILED_NOC_GROUP,
178179
BLK_STATUS_UNDEFINED
179180
};
180181

vpr/src/pack/cluster.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
243243
* Since some of the primitives might fail legality, this structure temporarily
244244
* stores PartitionRegion information while the cluster is packed*/
245245
PartitionRegion temp_cluster_pr;
246+
NocGroupId temp_cluster_noc_grp_id = NocGroupId::INVALID();
246247

247248
start_new_cluster(helper_ctx.cluster_placement_stats, helper_ctx.primitives_list,
248249
clb_index, istart,
@@ -257,7 +258,8 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
257258
packer_opts.enable_pin_feasibility_filter,
258259
balance_block_type_utilization,
259260
packer_opts.feasible_block_array_size,
260-
temp_cluster_pr);
261+
temp_cluster_pr,
262+
temp_cluster_noc_grp_id);
261263

262264
//initial molecule in cluster has been processed
263265
cluster_stats.num_molecules_processed++;
@@ -356,6 +358,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
356358
router_data,
357359
target_ext_pin_util,
358360
temp_cluster_pr,
361+
temp_cluster_noc_grp_id,
359362
block_pack_status,
360363
clustering_data.unclustered_list_head,
361364
unclustered_list_head_size,

vpr/src/pack/cluster_util.cpp

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,8 @@ e_block_pack_status try_pack_molecule(t_cluster_placement_stats* cluster_placeme
931931
bool enable_pin_feasibility_filter,
932932
int feasible_block_array_size,
933933
t_ext_pin_util max_external_pin_util,
934-
PartitionRegion& temp_cluster_pr) {
934+
PartitionRegion& temp_cluster_pr,
935+
NocGroupId& temp_noc_grp_id) {
935936
t_pb* parent;
936937
t_pb* cur_pb;
937938

@@ -989,6 +990,20 @@ e_block_pack_status try_pack_molecule(t_cluster_placement_stats* cluster_placeme
989990
}
990991
}
991992

993+
// check if all atoms in the molecule can be added to the cluster without NoC group conflicts
994+
for (int i_mol = 0; i_mol < molecule_size; i_mol++) {
995+
if (molecule->atom_block_ids[i_mol]) {
996+
bool block_pack_noc_grp_status = atom_cluster_noc_group_check(molecule->atom_block_ids[i_mol],
997+
verbosity, temp_noc_grp_id);
998+
999+
if (!block_pack_noc_grp_status) {
1000+
//Record the failure of this molecule in the current pb stats
1001+
record_molecule_failure(molecule, pb);
1002+
return e_block_pack_status::BLK_FAILED_NOC_GROUP;
1003+
}
1004+
}
1005+
}
1006+
9921007
e_block_pack_status block_pack_status = e_block_pack_status::BLK_STATUS_UNDEFINED;
9931008

9941009
while (block_pack_status != e_block_pack_status::BLK_PASSED) {
@@ -1362,6 +1377,28 @@ bool atom_cluster_floorplanning_check(AtomBlockId blk_id,
13621377
}
13631378
}
13641379

1380+
bool atom_cluster_noc_group_check(AtomBlockId blk_id,
1381+
int verbosity,
1382+
NocGroupId& temp_cluster_noc_grp_id) {
1383+
const NocGroupId atom_noc_grp_id = g_vpr_ctx.cl_helper().atom_noc_grp_id[blk_id];
1384+
1385+
1386+
if (temp_cluster_noc_grp_id == NocGroupId::INVALID()) {
1387+
// the cluster does not have a NoC group
1388+
// assign the atom's NoC group to cluster
1389+
temp_cluster_noc_grp_id = atom_noc_grp_id;
1390+
return true;
1391+
} else if (temp_cluster_noc_grp_id == atom_noc_grp_id) {
1392+
// the cluster has the same NoC group ID as the atom,
1393+
// so they are compatible
1394+
return true;
1395+
} else {
1396+
// the cluster belongs to a different NoC group than the atom's group,
1397+
// so they are incompatible
1398+
return false;
1399+
}
1400+
}
1401+
13651402
/* Revert trial atom block iblock and free up memory space accordingly
13661403
*/
13671404
void revert_place_atom_block(const AtomBlockId blk_id, t_lb_router_data* router_data) {
@@ -1497,6 +1534,7 @@ void try_fill_cluster(const t_packer_opts& packer_opts,
14971534
t_lb_router_data* router_data,
14981535
t_ext_pin_util target_ext_pin_util,
14991536
PartitionRegion& temp_cluster_pr,
1537+
NocGroupId& temp_noc_grp_id,
15001538
e_block_pack_status& block_pack_status,
15011539
t_molecule_link* unclustered_list_head,
15021540
const int& unclustered_list_head_size,
@@ -1519,7 +1557,8 @@ void try_fill_cluster(const t_packer_opts& packer_opts,
15191557
packer_opts.enable_pin_feasibility_filter,
15201558
packer_opts.feasible_block_array_size,
15211559
target_ext_pin_util,
1522-
temp_cluster_pr);
1560+
temp_cluster_pr,
1561+
temp_noc_grp_id);
15231562

15241563
auto blk_id = next_molecule->atom_block_ids[next_molecule->root];
15251564
VTR_ASSERT(blk_id);
@@ -2041,7 +2080,8 @@ void start_new_cluster(t_cluster_placement_stats* cluster_placement_stats,
20412080
bool enable_pin_feasibility_filter,
20422081
bool balance_block_type_utilization,
20432082
const int feasible_block_array_size,
2044-
PartitionRegion& temp_cluster_pr) {
2083+
PartitionRegion& temp_cluster_pr,
2084+
NocGroupId& temp_noc_grp_id) {
20452085
/* Given a starting seed block, start_new_cluster determines the next cluster type to use
20462086
* It expands the FPGA if it cannot find a legal cluster for the atom block
20472087
*/
@@ -2123,7 +2163,8 @@ void start_new_cluster(t_cluster_placement_stats* cluster_placement_stats,
21232163
enable_pin_feasibility_filter,
21242164
feasible_block_array_size,
21252165
FULL_EXTERNAL_PIN_UTIL,
2126-
temp_cluster_pr);
2166+
temp_cluster_pr,
2167+
temp_noc_grp_id);
21272168

21282169
success = (pack_result == e_block_pack_status::BLK_PASSED);
21292170
}

vpr/src/pack/cluster_util.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ e_block_pack_status try_pack_molecule(t_cluster_placement_stats* cluster_placeme
213213
bool enable_pin_feasibility_filter,
214214
int feasible_block_array_size,
215215
t_ext_pin_util max_external_pin_util,
216-
PartitionRegion& temp_cluster_pr);
216+
PartitionRegion& temp_cluster_pr,
217+
NocGroupId& temp_noc_grp_id);
217218

218219
void try_fill_cluster(const t_packer_opts& packer_opts,
219220
t_cluster_placement_stats* cur_cluster_placement_stats_ptr,
@@ -237,6 +238,7 @@ void try_fill_cluster(const t_packer_opts& packer_opts,
237238
t_lb_router_data* router_data,
238239
t_ext_pin_util target_ext_pin_util,
239240
PartitionRegion& temp_cluster_pr,
241+
NocGroupId& temp_noc_grp_id,
240242
e_block_pack_status& block_pack_status,
241243
t_molecule_link* unclustered_list_head,
242244
const int& unclustered_list_head_size,
@@ -284,6 +286,10 @@ bool atom_cluster_floorplanning_check(AtomBlockId blk_id,
284286
PartitionRegion& temp_cluster_pr,
285287
bool& cluster_pr_needs_update);
286288

289+
bool atom_cluster_noc_group_check(AtomBlockId blk_id,
290+
int verbosity,
291+
NocGroupId& temp_cluster_noc_grp_id);
292+
287293
void revert_place_atom_block(const AtomBlockId blk_id, t_lb_router_data* router_data);
288294

289295
void update_connection_gain_values(const AtomNetId net_id, const AtomBlockId clustered_blk_id, t_pb* cur_pb, enum e_net_relation_to_clustered_block net_relation_to_clustered_block);
@@ -341,7 +347,8 @@ void start_new_cluster(t_cluster_placement_stats* cluster_placement_stats,
341347
bool enable_pin_feasibility_filter,
342348
bool balance_block_type_utilization,
343349
const int feasible_block_array_size,
344-
PartitionRegion& temp_cluster_pr);
350+
PartitionRegion& temp_cluster_pr,
351+
NocGroupId& temp_noc_grp_id);
345352

346353
t_pack_molecule* get_highest_gain_molecule(t_pb* cur_pb,
347354
AttractionInfo& attraction_groups,

vpr/src/pack/noc_aware_cluster_util.cpp

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ std::vector<AtomBlockId> find_noc_router_atoms() {
2626

2727
void update_noc_reachability_partitions(const std::vector<AtomBlockId>& noc_atoms) {
2828
const auto& atom_ctx = g_vpr_ctx.atom();
29-
auto& constraints = g_vpr_ctx.mutable_floorplanning().constraints;
29+
auto& cl_helper_ctx = g_vpr_ctx.mutable_cl_helper();
3030
const auto& high_fanout_thresholds = g_vpr_ctx.cl_helper().high_fanout_thresholds;
31-
const auto& device_ctx = g_vpr_ctx.device();
32-
const auto& grid = device_ctx.grid;
31+
const auto& grid = g_vpr_ctx.device().grid;
3332

3433
t_logical_block_type_ptr logic_block_type = infer_logic_block_type(grid);
3534
const size_t high_fanout_threshold = high_fanout_thresholds.get_threshold(logic_block_type->name);
@@ -39,44 +38,19 @@ void update_noc_reachability_partitions(const std::vector<AtomBlockId>& noc_atom
3938

4039
vtr::vector<AtomBlockId, bool> atom_visited(n_atoms, false);
4140

42-
int exclusivity_cnt = 0;
41+
cl_helper_ctx.atom_noc_grp_id.resize(n_atoms, NocGroupId::INVALID());
4342

44-
RegionRectCoord unconstrained_rect{0,
45-
0,
46-
std::numeric_limits<int>::max(),
47-
std::numeric_limits<int>::max(),
48-
0};
49-
Region unconstrained_region;
50-
unconstrained_region.set_region_rect(unconstrained_rect);
43+
int noc_grp_id_cnt = 0;
5144

5245
for (auto noc_atom_id : noc_atoms) {
5346
// check if this NoC router has already been visited
5447
if (atom_visited[noc_atom_id]) {
5548
continue;
5649
}
5750

58-
exclusivity_cnt++;
51+
auto noc_grp_id = (NocGroupId)noc_grp_id_cnt;
52+
noc_grp_id_cnt++;
5953

60-
PartitionRegion associated_noc_partition_region;
61-
associated_noc_partition_region.set_exclusivity_index(exclusivity_cnt);
62-
associated_noc_partition_region.add_to_part_region(unconstrained_region);
63-
64-
Partition associated_noc_partition;
65-
associated_noc_partition.set_name(atom_ctx.nlist.block_name(noc_atom_id));
66-
associated_noc_partition.set_part_region(associated_noc_partition_region);
67-
auto associated_noc_partition_id = (PartitionId)constraints.get_num_partitions();
68-
constraints.add_partition(associated_noc_partition);
69-
70-
const PartitionId noc_partition_id = constraints.get_atom_partition(noc_atom_id);
71-
72-
if (noc_partition_id == PartitionId::INVALID()) {
73-
constraints.add_constrained_atom(noc_atom_id, associated_noc_partition_id);
74-
} else { // noc atom is already in a partition
75-
auto& noc_partition = constraints.get_mutable_partition(noc_partition_id);
76-
auto& noc_partition_region = noc_partition.get_mutable_part_region();
77-
VTR_ASSERT(noc_partition_region.get_exclusivity_index() < 0);
78-
noc_partition_region.set_exclusivity_index(exclusivity_cnt);
79-
}
8054

8155
std::queue<AtomBlockId> q;
8256
q.push(noc_atom_id);
@@ -86,15 +60,7 @@ void update_noc_reachability_partitions(const std::vector<AtomBlockId>& noc_atom
8660
AtomBlockId current_atom = q.front();
8761
q.pop();
8862

89-
PartitionId atom_partition_id = constraints.get_atom_partition(current_atom);
90-
if (atom_partition_id == PartitionId::INVALID()) {
91-
constraints.add_constrained_atom(current_atom, associated_noc_partition_id);
92-
} else {
93-
auto& atom_partition = constraints.get_mutable_partition(atom_partition_id);
94-
auto& atom_partition_region = atom_partition.get_mutable_part_region();
95-
VTR_ASSERT(atom_partition_region.get_exclusivity_index() < 0 || current_atom == noc_atom_id);
96-
atom_partition_region.set_exclusivity_index(exclusivity_cnt);
97-
}
63+
cl_helper_ctx.atom_noc_grp_id[current_atom] = noc_grp_id;
9864

9965
for(auto pin : atom_ctx.nlist.block_pins(current_atom)) {
10066
AtomNetId net_id = atom_ctx.nlist.pin_net(pin);

vpr/src/pack/pack.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -272,21 +272,6 @@ bool try_pack(t_packer_opts* packer_opts,
272272
//check clustering and output it
273273
check_and_output_clustering(*packer_opts, is_clock, arch, helper_ctx.total_clb_num, clustering_data.intra_lb_routing);
274274

275-
276-
g_vpr_ctx.mutable_floorplanning().constraints = constraints_backup;
277-
const int max_y = (int)g_vpr_ctx.device().grid.height();
278-
const int max_x = (int)g_vpr_ctx.device().grid.width();
279-
for (auto& cluster_partition_region : g_vpr_ctx.mutable_floorplanning().cluster_constraints) {
280-
const auto& regions = cluster_partition_region.get_regions();
281-
if (regions.size() == 1) {
282-
const auto rect = regions[0].get_region_rect();
283-
284-
if (rect.xmin <= 0 && rect.ymin <= 0 && rect.xmax >= max_x && rect.ymax >= max_y) {
285-
cluster_partition_region = PartitionRegion();
286-
}
287-
}
288-
}
289-
290275
// Free Data Structures
291276
free_clustering_data(*packer_opts, clustering_data);
292277

vpr/src/pack/re_cluster.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ bool move_mol_to_new_cluster(t_pack_molecule* molecule,
1616
ClusterBlockId old_clb = atom_to_cluster(molecule->atom_block_ids[molecule->root]);
1717
int molecule_size = get_array_size_of_molecule(molecule);
1818

19+
NocGroupId temp_noc_grp_id = NocGroupId::INVALID();
1920
PartitionRegion temp_cluster_pr;
2021
t_lb_router_data* old_router_data = nullptr;
2122
t_lb_router_data* router_data = nullptr;
@@ -66,7 +67,8 @@ bool move_mol_to_new_cluster(t_pack_molecule* molecule,
6667
verbosity,
6768
clustering_data,
6869
&router_data,
69-
temp_cluster_pr);
70+
temp_cluster_pr,
71+
temp_noc_grp_id);
7072

7173
//Commit or revert the move
7274
if (is_created) {

vpr/src/pack/re_cluster_util.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "initial_placement.h"
99
#include "read_netlist.h"
1010

11+
1112
//The name suffix of the new block (if exists)
1213
const char* name_suffix = "_m";
1314

@@ -122,7 +123,8 @@ bool start_new_cluster_for_mol(t_pack_molecule* molecule,
122123
int verbosity,
123124
t_clustering_data& clustering_data,
124125
t_lb_router_data** router_data,
125-
PartitionRegion& temp_cluster_pr) {
126+
PartitionRegion& temp_cluster_pr,
127+
NocGroupId& temp_cluster_noc_grp_id) {
126128
auto& atom_ctx = g_vpr_ctx.atom();
127129
auto& floorplanning_ctx = g_vpr_ctx.mutable_floorplanning();
128130
auto& helper_ctx = g_vpr_ctx.mutable_cl_helper();
@@ -162,7 +164,8 @@ bool start_new_cluster_for_mol(t_pack_molecule* molecule,
162164
enable_pin_feasibility_filter,
163165
0,
164166
FULL_EXTERNAL_PIN_UTIL,
165-
temp_cluster_pr);
167+
temp_cluster_pr,
168+
temp_cluster_noc_grp_id);
166169

167170
// If clustering succeeds, add it to the clb netlist
168171
if (pack_result == e_block_pack_status::BLK_PASSED) {
@@ -206,6 +209,7 @@ bool pack_mol_in_existing_cluster(t_pack_molecule* molecule,
206209
auto& helper_ctx = g_vpr_ctx.mutable_cl_helper();
207210
auto& cluster_ctx = g_vpr_ctx.mutable_clustering();
208211

212+
NocGroupId temp_cluster_noc_grp_id;
209213
PartitionRegion temp_cluster_pr;
210214
e_block_pack_status pack_result = e_block_pack_status::BLK_STATUS_UNDEFINED;
211215
t_ext_pin_util target_ext_pin_util = helper_ctx.target_external_pin_util.get_pin_util(cluster_ctx.clb_nlist.block_type(new_clb)->name);
@@ -235,7 +239,8 @@ bool pack_mol_in_existing_cluster(t_pack_molecule* molecule,
235239
//false,
236240
helper_ctx.feasible_block_array_size,
237241
target_ext_pin_util,
238-
temp_cluster_pr);
242+
temp_cluster_pr,
243+
temp_cluster_noc_grp_id);
239244

240245
// If clustering succeeds, add it to the clb netlist
241246
if (pack_result == e_block_pack_status::BLK_PASSED) {
@@ -282,6 +287,7 @@ void revert_mol_move(const ClusterBlockId& old_clb,
282287
auto& helper_ctx = g_vpr_ctx.mutable_cl_helper();
283288
auto& cluster_ctx = g_vpr_ctx.mutable_clustering();
284289

290+
NocGroupId temp_cluster_noc_grp_id_original;
285291
PartitionRegion temp_cluster_pr_original;
286292
e_block_pack_status pack_result = try_pack_molecule(&(helper_ctx.cluster_placement_stats[cluster_ctx.clb_nlist.block_type(old_clb)->index]),
287293
molecule,
@@ -296,7 +302,8 @@ void revert_mol_move(const ClusterBlockId& old_clb,
296302
helper_ctx.enable_pin_feasibility_filter,
297303
helper_ctx.feasible_block_array_size,
298304
helper_ctx.target_external_pin_util.get_pin_util(cluster_ctx.clb_nlist.block_type(old_clb)->name),
299-
temp_cluster_pr_original);
305+
temp_cluster_pr_original,
306+
temp_cluster_noc_grp_id_original);
300307

301308
VTR_ASSERT(pack_result == e_block_pack_status::BLK_PASSED);
302309
//If you are still in packing, update the clustering data. Otherwise, update the clustered netlist.

vpr/src/pack/re_cluster_util.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ bool start_new_cluster_for_mol(t_pack_molecule* molecule,
8787
int verbosity,
8888
t_clustering_data& clustering_data,
8989
t_lb_router_data** router_data,
90-
PartitionRegion& temp_cluster_pr);
90+
PartitionRegion& temp_cluster_pr,
91+
NocGroupId& temp_cluster_noc_grp_id);
9192

9293
/**
9394
* @brief A function that packs a molecule into an existing cluster

0 commit comments

Comments
 (0)