Skip to content

Commit 433a917

Browse files
Merge pull request #2965 from AlexandreSinger/feature-pack-timing-manager
[Pack][Timing] Abstracted How Timing is Used in the Packer
2 parents 19cdc14 + 150f634 commit 433a917

18 files changed

+476
-320
lines changed

vpr/src/analytical_place/full_legalizer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ std::unique_ptr<FullLegalizer> make_full_legalizer(e_ap_full_legalizer full_lega
5858
const APNetlist& ap_netlist,
5959
const AtomNetlist& atom_netlist,
6060
const Prepacker& prepacker,
61-
t_vpr_setup& vpr_setup,
61+
const t_vpr_setup& vpr_setup,
6262
const t_arch& arch,
6363
const DeviceGrid& device_grid) {
6464
switch (full_legalizer_type) {
@@ -513,8 +513,8 @@ void APPack::legalize(const PartialPlacement& p_placement) {
513513
}
514514

515515
// Run the Packer stage with the flat placement as a hint.
516-
try_pack(&vpr_setup_.PackerOpts,
517-
&vpr_setup_.AnalysisOpts,
516+
try_pack(vpr_setup_.PackerOpts,
517+
vpr_setup_.AnalysisOpts,
518518
arch_,
519519
vpr_setup_.RoutingArch,
520520
vpr_setup_.PackerRRGraph,

vpr/src/analytical_place/full_legalizer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class FullLegalizer {
3737
FullLegalizer(const APNetlist& ap_netlist,
3838
const AtomNetlist& atom_netlist,
3939
const Prepacker& prepacker,
40-
t_vpr_setup& vpr_setup,
40+
const t_vpr_setup& vpr_setup,
4141
const t_arch& arch,
4242
const DeviceGrid& device_grid)
4343
: ap_netlist_(ap_netlist)
@@ -68,7 +68,7 @@ class FullLegalizer {
6868

6969
/// @brief The VPR setup options passed into the VPR flow. This must be
7070
/// mutable since some parts of packing modify the options.
71-
t_vpr_setup& vpr_setup_;
71+
const t_vpr_setup& vpr_setup_;
7272

7373
/// @brief Information on the architecture of the FPGA.
7474
const t_arch& arch_;
@@ -84,7 +84,7 @@ std::unique_ptr<FullLegalizer> make_full_legalizer(e_ap_full_legalizer full_lega
8484
const APNetlist& ap_netlist,
8585
const AtomNetlist& atom_netlist,
8686
const Prepacker& prepacker,
87-
t_vpr_setup& vpr_setup,
87+
const t_vpr_setup& vpr_setup,
8888
const t_arch& arch,
8989
const DeviceGrid& device_grid);
9090

vpr/src/base/SetupVPR.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,10 +591,6 @@ void SetupPackerOpts(const t_options& Options,
591591
PackerOpts->feasible_block_array_size = Options.pack_feasible_block_array_size;
592592
PackerOpts->use_attraction_groups = Options.use_attraction_groups;
593593

594-
//TODO: document?
595-
PackerOpts->inter_cluster_net_delay = 1.0; /* DEFAULT */
596-
PackerOpts->auto_compute_inter_cluster_net_delay = true;
597-
598594
PackerOpts->device_layout = Options.device_layout;
599595

600596
PackerOpts->timing_update_type = Options.timing_update_type;

vpr/src/base/ShowSetup.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,6 @@ static void ShowPackerOpts(const t_packer_opts& PackerOpts) {
757757
}
758758
VTR_LOG("PackerOpts.connection_driven: %s", (PackerOpts.connection_driven ? "true\n" : "false\n"));
759759
VTR_LOG("PackerOpts.global_clocks: %s", (PackerOpts.global_clocks ? "true\n" : "false\n"));
760-
VTR_LOG("PackerOpts.inter_cluster_net_delay: %f\n", PackerOpts.inter_cluster_net_delay);
761760
VTR_LOG("PackerOpts.timing_driven: %s", (PackerOpts.timing_driven ? "true\n" : "false\n"));
762761
VTR_LOG("PackerOpts.target_external_pin_util: %s", vtr::join(PackerOpts.target_external_pin_util, " ").c_str());
763762
VTR_LOG("\n");

vpr/src/base/vpr_api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ bool vpr_pack(t_vpr_setup& vpr_setup, const t_arch& arch) {
620620
const Prepacker prepacker(g_vpr_ctx.atom().netlist(),
621621
g_vpr_ctx.device().logical_block_types);
622622

623-
return try_pack(&vpr_setup.PackerOpts, &vpr_setup.AnalysisOpts,
623+
return try_pack(vpr_setup.PackerOpts, vpr_setup.AnalysisOpts,
624624
arch, vpr_setup.RoutingArch,
625625
vpr_setup.PackerRRGraph,
626626
prepacker,

vpr/src/base/vpr_types.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,9 +717,7 @@ struct t_packer_opts {
717717
enum e_cluster_seed cluster_seed_type;
718718
float alpha;
719719
float beta;
720-
float inter_cluster_net_delay;
721720
float target_device_utilization;
722-
bool auto_compute_inter_cluster_net_delay;
723721
e_unrelated_clustering allow_unrelated_clustering;
724722
bool connection_driven;
725723
int pack_verbosity;

vpr/src/pack/cluster_util.cpp

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22
#include <algorithm>
33
#include <unordered_set>
44

5-
#include "PreClusterTimingGraphResolver.h"
6-
#include "PreClusterDelayCalculator.h"
75
#include "atom_netlist.h"
86
#include "attraction_groups.h"
97
#include "cluster_legalizer.h"
108
#include "clustered_netlist.h"
11-
#include "concrete_timing_info.h"
9+
#include "globals.h"
1210
#include "output_clustering.h"
1311
#include "prepack.h"
14-
#include "tatum/TimingReporter.hpp"
15-
#include "tatum/echo_writer.hpp"
1612
#include "vpr_context.h"
1713

1814
/*Print the contents of each cluster to an echo file*/
@@ -67,58 +63,6 @@ static void echo_clusters(char* filename, const ClusterLegalizer& cluster_legali
6763
fclose(fp);
6864
}
6965

70-
void calc_init_packing_timing(const t_packer_opts& packer_opts,
71-
const t_analysis_opts& analysis_opts,
72-
const Prepacker& prepacker,
73-
std::shared_ptr<PreClusterDelayCalculator>& clustering_delay_calc,
74-
std::shared_ptr<SetupTimingInfo>& timing_info,
75-
vtr::vector<AtomBlockId, float>& atom_criticality) {
76-
const AtomContext& atom_ctx = g_vpr_ctx.atom();
77-
78-
/*
79-
* Initialize the timing analyzer
80-
*/
81-
clustering_delay_calc = std::make_shared<PreClusterDelayCalculator>(atom_ctx.netlist(), atom_ctx.lookup(), packer_opts.inter_cluster_net_delay, prepacker);
82-
timing_info = make_setup_timing_info(clustering_delay_calc, packer_opts.timing_update_type);
83-
84-
//Calculate the initial timing
85-
timing_info->update();
86-
87-
if (isEchoFileEnabled(E_ECHO_PRE_PACKING_TIMING_GRAPH)) {
88-
auto& timing_ctx = g_vpr_ctx.timing();
89-
tatum::write_echo(getEchoFileName(E_ECHO_PRE_PACKING_TIMING_GRAPH),
90-
*timing_ctx.graph, *timing_ctx.constraints, *clustering_delay_calc, timing_info->analyzer());
91-
92-
tatum::NodeId debug_tnode = id_or_pin_name_to_tnode(analysis_opts.echo_dot_timing_graph_node);
93-
write_setup_timing_graph_dot(getEchoFileName(E_ECHO_PRE_PACKING_TIMING_GRAPH) + std::string(".dot"),
94-
*timing_info, debug_tnode);
95-
}
96-
97-
{
98-
auto& timing_ctx = g_vpr_ctx.timing();
99-
PreClusterTimingGraphResolver resolver(atom_ctx.netlist(),
100-
atom_ctx.lookup(), *timing_ctx.graph, *clustering_delay_calc);
101-
resolver.set_detail_level(analysis_opts.timing_report_detail);
102-
103-
tatum::TimingReporter timing_reporter(resolver, *timing_ctx.graph,
104-
*timing_ctx.constraints);
105-
106-
timing_reporter.report_timing_setup(
107-
"pre_pack.report_timing.setup.rpt",
108-
*timing_info->setup_analyzer(),
109-
analysis_opts.timing_report_npaths);
110-
}
111-
112-
//Calculate true criticalities of each block
113-
for (AtomBlockId blk : atom_ctx.netlist().blocks()) {
114-
for (AtomPinId in_pin : atom_ctx.netlist().block_input_pins(blk)) {
115-
//Max criticality over incoming nets
116-
float crit = timing_info->setup_pin_criticality(in_pin);
117-
atom_criticality[blk] = std::max(atom_criticality[blk], crit);
118-
}
119-
}
120-
}
121-
12266
void check_and_output_clustering(ClusterLegalizer& cluster_legalizer,
12367
const t_packer_opts& packer_opts,
12468
const std::unordered_set<AtomNetId>& is_clock,

vpr/src/pack/cluster_util.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ class AttractionInfo;
1111
class ClusterBlockId;
1212
class ClusterLegalizer;
1313
class ClusteredNetlist;
14-
class PreClusterDelayCalculator;
15-
class Prepacker;
16-
class SetupTimingInfo;
17-
class t_pack_molecule;
1814
struct AtomContext;
1915

2016
/**
@@ -26,16 +22,6 @@ struct AtomContext;
2622
/* Clustering helper functions */
2723
/***********************************/
2824

29-
/*
30-
* @brief Calculate the initial timing at the start of packing stage.
31-
*/
32-
void calc_init_packing_timing(const t_packer_opts& packer_opts,
33-
const t_analysis_opts& analysis_opts,
34-
const Prepacker& prepacker,
35-
std::shared_ptr<PreClusterDelayCalculator>& clustering_delay_calc,
36-
std::shared_ptr<SetupTimingInfo>& timing_info,
37-
vtr::vector<AtomBlockId, float>& atom_criticality);
38-
3925
/*
4026
* @brief Check clustering legality and output it.
4127
*/

vpr/src/pack/greedy_candidate_selector.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <cmath>
1111
#include <queue>
1212
#include <vector>
13+
#include "PreClusterTimingManager.h"
1314
#include "appack_context.h"
1415
#include "flat_placement_types.h"
1516
#include "flat_placement_utils.h"
@@ -90,7 +91,7 @@ GreedyCandidateSelector::GreedyCandidateSelector(
9091
const std::unordered_set<AtomNetId>& is_clock,
9192
const std::unordered_set<AtomNetId>& is_global,
9293
const std::unordered_set<AtomNetId>& net_output_feeds_driving_block_input,
93-
const SetupTimingInfo& timing_info,
94+
const PreClusterTimingManager& pre_cluster_timing_manager,
9495
const APPackContext& appack_ctx,
9596
int log_verbosity)
9697
: atom_netlist_(atom_netlist)
@@ -103,7 +104,7 @@ GreedyCandidateSelector::GreedyCandidateSelector(
103104
, is_clock_(is_clock)
104105
, is_global_(is_global)
105106
, net_output_feeds_driving_block_input_(net_output_feeds_driving_block_input)
106-
, timing_info_(timing_info)
107+
, pre_cluster_timing_manager_(pre_cluster_timing_manager)
107108
, appack_ctx_(appack_ctx)
108109
, rng_(0) {
109110

@@ -544,12 +545,15 @@ void GreedyCandidateSelector::update_timing_gain_values(
544545
if (net_output_feeds_driving_block_input_.count(net_id) != 0)
545546
pins = atom_netlist_.net_sinks(net_id);
546547

548+
// Get the setup timing info used to compute timing gain terms.
549+
const SetupTimingInfo& timing_info = pre_cluster_timing_manager_.get_timing_info();
550+
547551
if (net_relation_to_clustered_block == e_net_relation_to_clustered_block::OUTPUT
548552
&& !is_global_.count(net_id)) {
549553
for (AtomPinId pin_id : pins) {
550554
AtomBlockId blk_id = atom_netlist_.pin_block(pin_id);
551555
if (!cluster_legalizer.is_atom_clustered(blk_id)) {
552-
double timing_gain = timing_info_.setup_pin_criticality(pin_id);
556+
double timing_gain = timing_info.setup_pin_criticality(pin_id);
553557

554558
if (cluster_gain_stats.timing_gain.count(blk_id) == 0) {
555559
cluster_gain_stats.timing_gain[blk_id] = 0;
@@ -569,7 +573,7 @@ void GreedyCandidateSelector::update_timing_gain_values(
569573

570574
if (!cluster_legalizer.is_atom_clustered(new_blk_id)) {
571575
for (AtomPinId pin_id : atom_netlist_.net_sinks(net_id)) {
572-
double timing_gain = timing_info_.setup_pin_criticality(pin_id);
576+
double timing_gain = timing_info.setup_pin_criticality(pin_id);
573577

574578
if (cluster_gain_stats.timing_gain.count(new_blk_id) == 0) {
575579
cluster_gain_stats.timing_gain[new_blk_id] = 0;

vpr/src/pack/greedy_candidate_selector.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
class AtomNetlist;
2727
class AttractionInfo;
2828
class FlatPlacementInfo;
29+
class PreClusterTimingManager;
2930
class Prepacker;
30-
class SetupTimingInfo;
3131
class t_pack_high_fanout_thresholds;
3232
struct t_model;
3333
struct t_molecule_stats;
@@ -225,9 +225,10 @@ class GreedyCandidateSelector {
225225
* The set of nets whose output feeds the block that drives
226226
* itself. This may cause double-counting in the gain
227227
* calculations and needs special handling.
228-
* @param timing_info
229-
* Setup timing info for this Atom Netlist. Used to incorporate
230-
* timing / criticality into the gain calculation.
228+
* @param pre_cluster_timing_manager
229+
* Timing manager that holds the information on timing of
230+
* different connections in the circuit. Used for computing
231+
* the timing gain terms.
231232
* @param appack_ctx
232233
* The APPack context which contains options for the flat
233234
* placement guided packing.
@@ -244,7 +245,7 @@ class GreedyCandidateSelector {
244245
const std::unordered_set<AtomNetId>& is_clock,
245246
const std::unordered_set<AtomNetId>& is_global,
246247
const std::unordered_set<AtomNetId>& net_output_feeds_driving_block_input,
247-
const SetupTimingInfo& timing_info,
248+
const PreClusterTimingManager& pre_cluster_timing_manager,
248249
const APPackContext& appack_ctx,
249250
int log_verbosity);
250251

@@ -565,8 +566,9 @@ class GreedyCandidateSelector {
565566
/// drive them.
566567
const std::unordered_set<AtomNetId>& net_output_feeds_driving_block_input_;
567568

568-
/// @brief Setup timing info used to help select critical candidates to pack.
569-
const SetupTimingInfo& timing_info_;
569+
/// @brief The pre-clustering timing manager which holds the timing information
570+
/// of the primitive netlist.
571+
const PreClusterTimingManager& pre_cluster_timing_manager_;
570572

571573
/// @brief Inter-block nets within a finalized cluster. Used for finding
572574
/// transitive candidates.

vpr/src/pack/greedy_clusterer.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ GreedyClusterer::GreedyClusterer(const t_packer_opts& packer_opts,
7979
const t_pack_high_fanout_thresholds& high_fanout_thresholds,
8080
const std::unordered_set<AtomNetId>& is_clock,
8181
const std::unordered_set<AtomNetId>& is_global,
82+
const PreClusterTimingManager& pre_cluster_timing_manager,
8283
const APPackContext& appack_ctx)
8384
: packer_opts_(packer_opts)
8485
, analysis_opts_(analysis_opts)
@@ -87,6 +88,7 @@ GreedyClusterer::GreedyClusterer(const t_packer_opts& packer_opts,
8788
, high_fanout_thresholds_(high_fanout_thresholds)
8889
, is_clock_(is_clock)
8990
, is_global_(is_global)
91+
, pre_cluster_timing_manager_(pre_cluster_timing_manager)
9092
, appack_ctx_(appack_ctx)
9193
, primitive_candidate_block_types_(identify_primitive_candidate_block_types())
9294
, log_verbosity_(packer_opts.pack_verbosity)
@@ -113,18 +115,6 @@ GreedyClusterer::do_clustering(ClusterLegalizer& cluster_legalizer,
113115
t_cluster_progress_stats clustering_stats;
114116
clustering_stats.num_molecules = prepacker.molecules().size();
115117

116-
// TODO: Create a ClusteringTimingManager class.
117-
// This code relies on the prepacker, once the prepacker is moved to
118-
// the constructor, this code can also move to the constructor.
119-
std::shared_ptr<PreClusterDelayCalculator> clustering_delay_calc;
120-
std::shared_ptr<SetupTimingInfo> timing_info;
121-
// Default criticalities set to zero (e.g. if not timing driven)
122-
vtr::vector<AtomBlockId, float> atom_criticality(atom_netlist_.blocks().size(), 0.f);
123-
if (packer_opts_.timing_driven) {
124-
calc_init_packing_timing(packer_opts_, analysis_opts_, prepacker,
125-
clustering_delay_calc, timing_info, atom_criticality);
126-
}
127-
128118
// Calculate the max molecule stats, which is used for gain calculation.
129119
const t_molecule_stats max_molecule_stats = prepacker.calc_max_molecule_stats(atom_netlist_);
130120

@@ -140,7 +130,7 @@ GreedyClusterer::do_clustering(ClusterLegalizer& cluster_legalizer,
140130
is_clock_,
141131
is_global_,
142132
net_output_feeds_driving_block_input_,
143-
*timing_info,
133+
pre_cluster_timing_manager_,
144134
appack_ctx_,
145135
log_verbosity_);
146136

@@ -149,7 +139,7 @@ GreedyClusterer::do_clustering(ClusterLegalizer& cluster_legalizer,
149139
prepacker,
150140
packer_opts_.cluster_seed_type,
151141
max_molecule_stats,
152-
atom_criticality);
142+
pre_cluster_timing_manager_);
153143

154144
// Pick the first seed molecule.
155145
PackMoleculeId seed_mol_id = seed_selector.get_next_seed(prepacker,

vpr/src/pack/greedy_clusterer.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class AtomNetlist;
2222
class AttractionInfo;
2323
class DeviceContext;
2424
class GreedyCandidateSelector;
25-
class SetupTimingInfo;
25+
class PreClusterTimingManager;
2626
class t_pack_high_fanout_thresholds;
2727
struct t_analysis_opts;
2828
struct t_clustering_data;
@@ -76,6 +76,11 @@ class GreedyClusterer {
7676
* The set of global nets in the Atom Netlist. These will be
7777
* routed on special dedicated networks, and hence are less
7878
* relavent to locality / attraction.
79+
* @param pre_cluster_timing_manager
80+
* Timing manager class which holds the timing information of
81+
* the primitive netlist. Used by the seed selector to select
82+
* critical seeds and the candidate selector to select
83+
* timing critical candidates.
7984
* @param appack_ctx
8085
* The APPack state. This contains the options used to
8186
* configure APPack and the flat placement.
@@ -87,6 +92,7 @@ class GreedyClusterer {
8792
const t_pack_high_fanout_thresholds& high_fanout_thresholds,
8893
const std::unordered_set<AtomNetId>& is_clock,
8994
const std::unordered_set<AtomNetId>& is_global,
95+
const PreClusterTimingManager& pre_cluster_timing_manager,
9096
const APPackContext& appack_ctx);
9197

9298
/**
@@ -233,6 +239,9 @@ class GreedyClusterer {
233239
/// @brief A set of atom nets which are considered as global nets.
234240
const std::unordered_set<AtomNetId>& is_global_;
235241

242+
/// @brief Timing manager class which holds the primitive-level timing information.
243+
const PreClusterTimingManager& pre_cluster_timing_manager_;
244+
236245
/// @brief The APPack state. This is used by the candidate selector to try
237246
/// and propose better candidates based on a flat placement.
238247
const APPackContext& appack_ctx_;

0 commit comments

Comments
 (0)