Skip to content

Commit 9d3c3d9

Browse files
committed
Revert "fix #2089 Cluster attraction groups for tight floorplan constraints not working"
This reverts commit f1b2391.
1 parent f1b2391 commit 9d3c3d9

23 files changed

+5093
-3884
lines changed

vpr/src/base/vpr_api.cpp

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

401+
//clean packing-placement data
402+
if (vpr_setup.PackerOpts.doPacking == STAGE_DO) {
403+
auto& helper_ctx = g_vpr_ctx.mutable_cl_helper();
404+
free_cluster_placement_stats(helper_ctx.cluster_placement_stats);
405+
}
406+
401407
//close the graphics
402408
vpr_close_graphics(vpr_setup);
403409

vpr/src/base/vpr_context.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,34 @@ struct AtomContext : public Context {
5858
/********************************************************************
5959
* Atom Netlist
6060
********************************************************************/
61+
/**
62+
* @brief constructor
63+
*
64+
* In the constructor initialize the list of pack molecules to nullptr and defines a custom deletor for it
65+
*/
66+
AtomContext()
67+
: list_of_pack_molecules(nullptr, free_pack_molecules) {}
6168

6269
///@brief Atom netlist
6370
AtomNetlist nlist;
6471

6572
///@brief Mappings to/from the Atom Netlist to physically described .blif models
6673
AtomLookup lookup;
74+
75+
/**
76+
* @brief The molecules associated with each atom block.
77+
*
78+
* This map is loaded in the pre-packing stage and freed at the very end of vpr flow run.
79+
* The pointers in this multimap is shared with list_of_pack_molecules.
80+
*/
81+
std::multimap<AtomBlockId, t_pack_molecule*> atom_molecules;
82+
83+
/**
84+
* @brief A linked list of all the packing molecules that are loaded in pre-packing stage.
85+
*
86+
* Is is useful in freeing the pack molecules at the destructor of the Atom context using free_pack_molecules.
87+
*/
88+
std::unique_ptr<t_pack_molecule, decltype(&free_pack_molecules)> list_of_pack_molecules;
6789
};
6890

6991
/**

vpr/src/base/vpr_types.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,53 @@ BitIndex t_pb::atom_pin_bit_index(const t_pb_graph_pin* gpin) const {
214214
void t_pb::set_atom_pin_bit_index(const t_pb_graph_pin* gpin, BitIndex atom_pin_bit_idx) {
215215
pin_rotations_[gpin] = atom_pin_bit_idx;
216216
}
217+
218+
void free_pack_molecules(t_pack_molecule* list_of_pack_molecules) {
219+
t_pack_molecule* cur_pack_molecule = list_of_pack_molecules;
220+
while (cur_pack_molecule != nullptr) {
221+
cur_pack_molecule = list_of_pack_molecules->next;
222+
delete list_of_pack_molecules;
223+
list_of_pack_molecules = cur_pack_molecule;
224+
}
225+
}
226+
227+
/**
228+
* Free linked lists found in cluster_placement_stats_list
229+
*/
230+
void free_cluster_placement_stats(t_cluster_placement_stats* cluster_placement_stats_list) {
231+
t_cluster_placement_primitive *cur, *next;
232+
auto& device_ctx = g_vpr_ctx.device();
233+
234+
for (const auto& type : device_ctx.logical_block_types) {
235+
int index = type.index;
236+
cur = cluster_placement_stats_list[index].tried;
237+
while (cur != nullptr) {
238+
next = cur->next_primitive;
239+
delete cur;
240+
cur = next;
241+
}
242+
cur = cluster_placement_stats_list[index].in_flight;
243+
while (cur != nullptr) {
244+
next = cur->next_primitive;
245+
delete cur;
246+
cur = next;
247+
}
248+
cur = cluster_placement_stats_list[index].invalid;
249+
while (cur != nullptr) {
250+
next = cur->next_primitive;
251+
delete cur;
252+
cur = next;
253+
}
254+
for (int j = 0; j < cluster_placement_stats_list[index].num_pb_types; j++) {
255+
cur = cluster_placement_stats_list[index].valid_primitives[j]->next_primitive;
256+
while (cur != nullptr) {
257+
next = cur->next_primitive;
258+
delete cur;
259+
cur = next;
260+
}
261+
delete cluster_placement_stats_list[index].valid_primitives[j];
262+
}
263+
delete[] cluster_placement_stats_list[index].valid_primitives;
264+
}
265+
delete[] cluster_placement_stats_list;
266+
}

vpr/src/base/vpr_types.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,4 +1665,14 @@ typedef vtr::vector<ClusterBlockId, std::vector<std::vector<int>>> t_clb_opins_u
16651665

16661666
typedef std::vector<std::map<int, int>> t_arch_switch_fanin;
16671667

1668+
/**
1669+
* @brief Free the linked list that saves all the packing molecules.
1670+
*/
1671+
void free_pack_molecules(t_pack_molecule* list_of_pack_molecules);
1672+
1673+
/**
1674+
* @brief Free the linked lists to placement locations based on status of primitive inside placement stats data structure.
1675+
*/
1676+
void free_cluster_placement_stats(t_cluster_placement_stats* cluster_placement_stats);
1677+
16681678
#endif

vpr/src/pack/cluster.cpp

Lines changed: 67 additions & 3749 deletions
Large diffs are not rendered by default.

vpr/src/pack/cluster.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,24 @@
88
#include "physical_types.h"
99
#include "vpr_types.h"
1010
#include "atom_netlist_fwd.h"
11+
#include "attraction_groups.h"
12+
#include "cluster_util.h"
1113

1214
std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& packer_opts,
1315
const t_analysis_opts& analysis_opts,
1416
const t_arch* arch,
1517
t_pack_molecule* molecule_head,
1618
int num_models,
1719
const std::unordered_set<AtomNetId>& is_clock,
18-
std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
1920
const std::unordered_map<AtomBlockId, t_pb_graph_node*>& expected_lowest_cost_pb_gnode,
2021
bool allow_unrelated_clustering,
2122
bool balance_block_type_utilization,
2223
std::vector<t_lb_type_rr_node>* lb_type_rr_graphs,
2324
const t_ext_pin_util_targets& ext_pin_util_targets,
2425
const t_pack_high_fanout_thresholds& high_fanout_thresholds,
2526
AttractionInfo& attraction_groups,
26-
bool& floorplan_regions_overfull);
27+
bool& floorplan_regions_overfull,
28+
t_clustering_data& clustering_data);
2729

2830
int get_cluster_of_block(int blkidx);
2931

vpr/src/pack/cluster_placement.cpp

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -219,47 +219,6 @@ void reset_cluster_placement_stats(t_cluster_placement_stats* cluster_placement_
219219
cluster_placement_stats->has_long_chain = false;
220220
}
221221

222-
/**
223-
* Free linked lists found in cluster_placement_stats_list
224-
*/
225-
void free_cluster_placement_stats(t_cluster_placement_stats* cluster_placement_stats_list) {
226-
t_cluster_placement_primitive *cur, *next;
227-
auto& device_ctx = g_vpr_ctx.device();
228-
229-
for (const auto& type : device_ctx.logical_block_types) {
230-
int index = type.index;
231-
cur = cluster_placement_stats_list[index].tried;
232-
while (cur != nullptr) {
233-
next = cur->next_primitive;
234-
free(cur);
235-
cur = next;
236-
}
237-
cur = cluster_placement_stats_list[index].in_flight;
238-
while (cur != nullptr) {
239-
next = cur->next_primitive;
240-
free(cur);
241-
cur = next;
242-
}
243-
cur = cluster_placement_stats_list[index].invalid;
244-
while (cur != nullptr) {
245-
next = cur->next_primitive;
246-
free(cur);
247-
cur = next;
248-
}
249-
for (int j = 0; j < cluster_placement_stats_list[index].num_pb_types; j++) {
250-
cur = cluster_placement_stats_list[index].valid_primitives[j]->next_primitive;
251-
while (cur != nullptr) {
252-
next = cur->next_primitive;
253-
free(cur);
254-
cur = next;
255-
}
256-
free(cluster_placement_stats_list[index].valid_primitives[j]);
257-
}
258-
free(cluster_placement_stats_list[index].valid_primitives);
259-
}
260-
free(cluster_placement_stats_list);
261-
}
262-
263222
/**
264223
* Put primitive back on queue of valid primitives
265224
* Note that valid status is not changed because if the primitive is not valid, it will get properly collected later

vpr/src/pack/cluster_placement.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ void set_mode_cluster_placement_stats(const t_pb_graph_node* complex_block,
1818
int mode);
1919
void reset_cluster_placement_stats(
2020
t_cluster_placement_stats* cluster_placement_stats);
21-
void free_cluster_placement_stats(
22-
t_cluster_placement_stats* cluster_placement_stats);
2321

2422
int get_array_size_of_molecule(const t_pack_molecule* molecule);
2523
bool exists_free_primitive_for_atom_block(

0 commit comments

Comments
 (0)