Skip to content

Commit 1a6d3d4

Browse files
committed
fix #2098 Cluster attraction groups for tight floorplan constraints not working
1 parent 33c518f commit 1a6d3d4

23 files changed

+3885
-5094
lines changed

vpr/src/base/vpr_api.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,6 @@ 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-
407401
//close the graphics
408402
vpr_close_graphics(vpr_setup);
409403

vpr/src/base/vpr_context.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,34 +58,12 @@ 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) {}
6861

6962
///@brief Atom netlist
7063
AtomNetlist nlist;
7164

7265
///@brief Mappings to/from the Atom Netlist to physically described .blif models
7366
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;
8967
};
9068

9169
/**

vpr/src/base/vpr_types.cpp

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -214,53 +214,3 @@ 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: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,14 +1665,4 @@ 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-
16781668
#endif

vpr/src/pack/cluster.cpp

Lines changed: 3750 additions & 68 deletions
Large diffs are not rendered by default.

vpr/src/pack/cluster.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,22 @@
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"
1311

1412
std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& packer_opts,
1513
const t_analysis_opts& analysis_opts,
1614
const t_arch* arch,
1715
t_pack_molecule* molecule_head,
1816
int num_models,
1917
const std::unordered_set<AtomNetId>& is_clock,
18+
std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
2019
const std::unordered_map<AtomBlockId, t_pb_graph_node*>& expected_lowest_cost_pb_gnode,
2120
bool allow_unrelated_clustering,
2221
bool balance_block_type_utilization,
2322
std::vector<t_lb_type_rr_node>* lb_type_rr_graphs,
2423
const t_ext_pin_util_targets& ext_pin_util_targets,
2524
const t_pack_high_fanout_thresholds& high_fanout_thresholds,
2625
AttractionInfo& attraction_groups,
27-
bool& floorplan_regions_overfull,
28-
t_clustering_data& clustering_data);
26+
bool& floorplan_regions_overfull);
2927

3028
int get_cluster_of_block(int blkidx);
3129

vpr/src/pack/cluster_placement.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,47 @@ 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+
222263
/**
223264
* Put primitive back on queue of valid primitives
224265
* 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ 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);
2123

2224
int get_array_size_of_molecule(const t_pack_molecule* molecule);
2325
bool exists_free_primitive_for_atom_block(

0 commit comments

Comments
 (0)