Skip to content

Commit 4219024

Browse files
litghostkmurray
authored andcommitted
Add a pre-pack timing report.
This timing report provides insight into how the packer criticality values were computed. Signed-off-by: Keith Rothman <[email protected]>
1 parent 849ceb1 commit 4219024

File tree

7 files changed

+193
-11
lines changed

7 files changed

+193
-11
lines changed

vpr/src/base/vpr_api.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,10 @@ bool vpr_pack(t_vpr_setup& vpr_setup, const t_arch& arch) {
498498
+ wtoi_switch_del); /* multiply by 4 to get a more conservative estimate */
499499
}
500500

501-
return try_pack(&vpr_setup.PackerOpts, &arch, vpr_setup.user_models,
502-
vpr_setup.library_models, inter_cluster_delay, vpr_setup.PackerRRGraph);
501+
return try_pack(&vpr_setup.PackerOpts, &vpr_setup.AnalysisOpts,
502+
&arch, vpr_setup.user_models,
503+
vpr_setup.library_models, inter_cluster_delay,
504+
vpr_setup.PackerRRGraph);
503505
}
504506

505507
void vpr_load_packing(t_vpr_setup& vpr_setup, const t_arch& arch) {

vpr/src/pack/cluster.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ using namespace std;
6464
#include "lb_type_rr_graph.h"
6565

6666
#include "timing_info.h"
67+
#include "timing_reports.h"
6768
#include "PreClusterDelayCalculator.h"
69+
#include "PreClusterTimingGraphResolver.h"
6870
#include "tatum/echo_writer.hpp"
6971
#include "tatum/report/graphviz_dot_writer.hpp"
72+
#include "tatum/TimingReporter.hpp"
7073

7174
#define AAPACK_MAX_FEASIBLE_BLOCK_ARRAY_SIZE 30 /* This value is used to determine the max size of the priority queue for candidates that pass the early filter legality test but not the more detailed routing test */
7275
#define AAPACK_MAX_HIGH_FANOUT_EXPLORE 10 /* For high-fanout nets that are ignored, consider a maximum of this many sinks, must be less than AAPACK_MAX_FEASIBLE_BLOCK_ARRAY_SIZE */
@@ -339,6 +342,7 @@ static t_pb_graph_pin* get_driver_pb_graph_pin(const t_pb* driver_pb, const Atom
339342
/*****************************************/
340343
/*globally accessible function*/
341344
std::map<t_type_ptr, size_t> do_clustering(const t_packer_opts& packer_opts,
345+
const t_analysis_opts& analysis_opts,
342346
const t_arch* arch,
343347
t_pack_molecule* molecule_head,
344348
int num_models,
@@ -467,6 +471,21 @@ std::map<t_type_ptr, size_t> do_clustering(const t_packer_opts& packer_opts,
467471
*timing_ctx.graph, *timing_ctx.constraints, *clustering_delay_calc, timing_info->analyzer());
468472
}
469473

474+
{
475+
auto& timing_ctx = g_vpr_ctx.timing();
476+
PreClusterTimingGraphResolver resolver(atom_ctx.nlist,
477+
atom_ctx.lookup, *timing_ctx.graph, *clustering_delay_calc);
478+
resolver.set_detail_level(analysis_opts.timing_report_detail);
479+
480+
tatum::TimingReporter timing_reporter(resolver, *timing_ctx.graph,
481+
*timing_ctx.constraints);
482+
483+
timing_reporter.report_timing_setup(
484+
"pre_pack.report_timing.setup.rpt",
485+
*timing_info->setup_analyzer(),
486+
analysis_opts.timing_report_npaths);
487+
}
488+
470489
//Calculate true criticalities of each block
471490
for (AtomBlockId blk : atom_ctx.nlist.blocks()) {
472491
for (AtomPinId in_pin : atom_ctx.nlist.block_input_pins(blk)) {

vpr/src/pack/cluster.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "atom_netlist_fwd.h"
1111

1212
std::map<t_type_ptr, size_t> do_clustering(const t_packer_opts& packer_opts,
13+
const t_analysis_opts& analysis_opts,
1314
const t_arch* arch,
1415
t_pack_molecule* molecule_head,
1516
int num_models,

vpr/src/pack/pack.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static t_pack_high_fanout_thresholds parse_high_fanout_thresholds(std::vector<st
3636
static std::string high_fanout_thresholds_to_string(const t_pack_high_fanout_thresholds& hf_thresholds);
3737

3838
bool try_pack(t_packer_opts* packer_opts,
39+
const t_analysis_opts* analysis_opts,
3940
const t_arch* arch,
4041
const t_model* user_models,
4142
const t_model* library_models,
@@ -121,15 +122,18 @@ bool try_pack(t_packer_opts* packer_opts,
121122

122123
while (true) {
123124
//Cluster the netlist
124-
auto num_type_instances = do_clustering(*packer_opts, arch, list_of_pack_molecules, num_models,
125-
is_clock,
126-
atom_molecules,
127-
expected_lowest_cost_pb_gnode,
128-
allow_unrelated_clustering,
129-
balance_block_type_util,
130-
lb_type_rr_graphs,
131-
target_external_pin_util,
132-
high_fanout_thresholds);
125+
auto num_type_instances = do_clustering(
126+
*packer_opts,
127+
*analysis_opts,
128+
arch, list_of_pack_molecules, num_models,
129+
is_clock,
130+
atom_molecules,
131+
expected_lowest_cost_pb_gnode,
132+
allow_unrelated_clustering,
133+
balance_block_type_util,
134+
lb_type_rr_graphs,
135+
target_external_pin_util,
136+
high_fanout_thresholds);
133137

134138
//Try to size/find a device
135139
bool fits_on_device = try_size_device_grid(*arch, num_type_instances, packer_opts->target_device_utilization, packer_opts->device_layout);

vpr/src/pack/pack.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define PACK_H
33

44
bool try_pack(t_packer_opts* packer_opts,
5+
const t_analysis_opts* analysis_opts,
56
const t_arch* arch,
67
const t_model* user_models,
78
const t_model* library_models,
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#include "PreClusterTimingGraphResolver.h"
2+
#include "atom_netlist.h"
3+
#include "atom_lookup.h"
4+
5+
PreClusterTimingGraphResolver::PreClusterTimingGraphResolver(
6+
const AtomNetlist& netlist,
7+
const AtomLookup& netlist_lookup,
8+
const tatum::TimingGraph& timing_graph,
9+
const tatum::DelayCalculator& delay_calc)
10+
: netlist_(netlist)
11+
, netlist_lookup_(netlist_lookup)
12+
, timing_graph_(timing_graph)
13+
, delay_calc_(delay_calc) {}
14+
15+
std::string PreClusterTimingGraphResolver::node_name(tatum::NodeId node) const {
16+
AtomPinId pin = netlist_lookup_.tnode_atom_pin(node);
17+
18+
return netlist_.pin_name(pin);
19+
}
20+
21+
std::string PreClusterTimingGraphResolver::node_type_name(tatum::NodeId node) const {
22+
AtomPinId pin = netlist_lookup_.tnode_atom_pin(node);
23+
AtomBlockId blk = netlist_.pin_block(pin);
24+
25+
std::string name = netlist_.block_model(blk)->name;
26+
27+
if (detail_level() == e_timing_report_detail::AGGREGATED) {
28+
//Annotate primitive grid location, if known
29+
auto& atom_ctx = g_vpr_ctx.atom();
30+
auto& place_ctx = g_vpr_ctx.placement();
31+
ClusterBlockId cb = atom_ctx.lookup.atom_clb(blk);
32+
if (cb && place_ctx.block_locs.count(cb)) {
33+
int x = place_ctx.block_locs[cb].loc.x;
34+
int y = place_ctx.block_locs[cb].loc.y;
35+
name += " at (" + std::to_string(x) + "," + std::to_string(y) + ")";
36+
}
37+
}
38+
39+
return name;
40+
}
41+
42+
tatum::EdgeDelayBreakdown PreClusterTimingGraphResolver::edge_delay_breakdown(tatum::EdgeId edge, tatum::DelayType tatum_delay_type) const {
43+
tatum::EdgeDelayBreakdown delay_breakdown;
44+
45+
if (edge && detail_level() == e_timing_report_detail::AGGREGATED) {
46+
auto edge_type = timing_graph_.edge_type(edge);
47+
48+
DelayType delay_type; //TODO: should unify vpr/tatum DelayType
49+
if (tatum_delay_type == tatum::DelayType::MAX) {
50+
delay_type = DelayType::MAX;
51+
} else {
52+
VTR_ASSERT(tatum_delay_type == tatum::DelayType::MIN);
53+
delay_type = DelayType::MIN;
54+
}
55+
56+
if (edge_type == tatum::EdgeType::INTERCONNECT) {
57+
tatum::DelayComponent inter_cluster;
58+
inter_cluster.type_name = "inter-cluster net delay estimate";
59+
inter_cluster.delay = delay_calc_.max_edge_delay(timing_graph_, edge);
60+
delay_breakdown.components.push_back(inter_cluster);
61+
} else {
62+
//Primtiive edge
63+
//
64+
tatum::DelayComponent component;
65+
66+
tatum::NodeId node = timing_graph_.edge_sink_node(edge);
67+
68+
AtomPinId atom_pin = netlist_lookup_.tnode_atom_pin(node);
69+
AtomBlockId atom_blk = netlist_.pin_block(atom_pin);
70+
71+
//component.inst_name = netlist_.block_name(atom_blk);
72+
73+
component.type_name = "primitive '";
74+
component.type_name += netlist_.block_model(atom_blk)->name;
75+
component.type_name += "'";
76+
77+
if (edge_type == tatum::EdgeType::PRIMITIVE_COMBINATIONAL) {
78+
component.type_name += " combinational delay";
79+
80+
if (delay_type == DelayType::MAX) {
81+
component.delay = delay_calc_.max_edge_delay(timing_graph_, edge);
82+
} else {
83+
VTR_ASSERT(delay_type == DelayType::MIN);
84+
component.delay = delay_calc_.min_edge_delay(timing_graph_, edge);
85+
}
86+
} else if (edge_type == tatum::EdgeType::PRIMITIVE_CLOCK_LAUNCH) {
87+
if (delay_type == DelayType::MAX) {
88+
component.type_name += " Tcq_max";
89+
component.delay = delay_calc_.max_edge_delay(timing_graph_, edge);
90+
} else {
91+
VTR_ASSERT(delay_type == DelayType::MIN);
92+
component.type_name += " Tcq_min";
93+
component.delay = delay_calc_.min_edge_delay(timing_graph_, edge);
94+
}
95+
96+
} else {
97+
VTR_ASSERT(edge_type == tatum::EdgeType::PRIMITIVE_CLOCK_CAPTURE);
98+
99+
if (delay_type == DelayType::MAX) {
100+
component.type_name += " Tsu";
101+
component.delay = delay_calc_.setup_time(timing_graph_, edge);
102+
} else {
103+
component.type_name += " Thld";
104+
component.delay = delay_calc_.hold_time(timing_graph_, edge);
105+
}
106+
}
107+
108+
delay_breakdown.components.push_back(component);
109+
}
110+
}
111+
112+
return delay_breakdown;
113+
}
114+
115+
e_timing_report_detail PreClusterTimingGraphResolver::detail_level() const {
116+
return detail_level_;
117+
}
118+
119+
void PreClusterTimingGraphResolver::set_detail_level(e_timing_report_detail report_detail) {
120+
detail_level_ = report_detail;
121+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#ifndef VPR_PRE_CLUSTER_TIMING_GRAPH_RESOLVER_H_
2+
#define VPR_PRE_CLUSTER_TIMING_GRAPH_RESOLVER_H_
3+
4+
#include "tatum/TimingGraphNameResolver.hpp"
5+
#include "atom_netlist_fwd.h"
6+
#include "atom_lookup.h"
7+
#include "AnalysisDelayCalculator.h"
8+
9+
class PreClusterTimingGraphResolver : public tatum::TimingGraphNameResolver {
10+
public:
11+
PreClusterTimingGraphResolver(
12+
const AtomNetlist& netlist,
13+
const AtomLookup& netlist_lookup,
14+
const tatum::TimingGraph& timing_graph,
15+
const tatum::DelayCalculator& delay_calc);
16+
17+
std::string node_name(tatum::NodeId node) const override;
18+
std::string node_type_name(tatum::NodeId node) const override;
19+
20+
tatum::EdgeDelayBreakdown edge_delay_breakdown(tatum::EdgeId edge, tatum::DelayType delay_type) const override;
21+
22+
void set_detail_level(e_timing_report_detail report_detail);
23+
24+
private:
25+
e_timing_report_detail detail_level() const;
26+
27+
const AtomNetlist& netlist_;
28+
const AtomLookup& netlist_lookup_;
29+
const tatum::TimingGraph& timing_graph_;
30+
const tatum::DelayCalculator& delay_calc_;
31+
e_timing_report_detail detail_level_ = e_timing_report_detail::NETLIST;
32+
};
33+
34+
#endif /* VPR_PRE_CLUSTER_TIMING_GRAPH_RESOLVER_H_ */

0 commit comments

Comments
 (0)