Skip to content

[Pack][Timing] Abstracted How Timing is Used in the Packer #2965

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions vpr/src/analytical_place/full_legalizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ std::unique_ptr<FullLegalizer> make_full_legalizer(e_ap_full_legalizer full_lega
const APNetlist& ap_netlist,
const AtomNetlist& atom_netlist,
const Prepacker& prepacker,
t_vpr_setup& vpr_setup,
const t_vpr_setup& vpr_setup,
const t_arch& arch,
const DeviceGrid& device_grid) {
switch (full_legalizer_type) {
Expand Down Expand Up @@ -513,8 +513,8 @@ void APPack::legalize(const PartialPlacement& p_placement) {
}

// Run the Packer stage with the flat placement as a hint.
try_pack(&vpr_setup_.PackerOpts,
&vpr_setup_.AnalysisOpts,
try_pack(vpr_setup_.PackerOpts,
vpr_setup_.AnalysisOpts,
arch_,
vpr_setup_.RoutingArch,
vpr_setup_.PackerRRGraph,
Expand Down
6 changes: 3 additions & 3 deletions vpr/src/analytical_place/full_legalizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class FullLegalizer {
FullLegalizer(const APNetlist& ap_netlist,
const AtomNetlist& atom_netlist,
const Prepacker& prepacker,
t_vpr_setup& vpr_setup,
const t_vpr_setup& vpr_setup,
const t_arch& arch,
const DeviceGrid& device_grid)
: ap_netlist_(ap_netlist)
Expand Down Expand Up @@ -68,7 +68,7 @@ class FullLegalizer {

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

/// @brief Information on the architecture of the FPGA.
const t_arch& arch_;
Expand All @@ -84,7 +84,7 @@ std::unique_ptr<FullLegalizer> make_full_legalizer(e_ap_full_legalizer full_lega
const APNetlist& ap_netlist,
const AtomNetlist& atom_netlist,
const Prepacker& prepacker,
t_vpr_setup& vpr_setup,
const t_vpr_setup& vpr_setup,
const t_arch& arch,
const DeviceGrid& device_grid);

Expand Down
4 changes: 0 additions & 4 deletions vpr/src/base/SetupVPR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,6 @@ void SetupPackerOpts(const t_options& Options,
PackerOpts->feasible_block_array_size = Options.pack_feasible_block_array_size;
PackerOpts->use_attraction_groups = Options.use_attraction_groups;

//TODO: document?
PackerOpts->inter_cluster_net_delay = 1.0; /* DEFAULT */
PackerOpts->auto_compute_inter_cluster_net_delay = true;

PackerOpts->device_layout = Options.device_layout;

PackerOpts->timing_update_type = Options.timing_update_type;
Expand Down
1 change: 0 additions & 1 deletion vpr/src/base/ShowSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,6 @@ static void ShowPackerOpts(const t_packer_opts& PackerOpts) {
}
VTR_LOG("PackerOpts.connection_driven: %s", (PackerOpts.connection_driven ? "true\n" : "false\n"));
VTR_LOG("PackerOpts.global_clocks: %s", (PackerOpts.global_clocks ? "true\n" : "false\n"));
VTR_LOG("PackerOpts.inter_cluster_net_delay: %f\n", PackerOpts.inter_cluster_net_delay);
VTR_LOG("PackerOpts.timing_driven: %s", (PackerOpts.timing_driven ? "true\n" : "false\n"));
VTR_LOG("PackerOpts.target_external_pin_util: %s", vtr::join(PackerOpts.target_external_pin_util, " ").c_str());
VTR_LOG("\n");
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/base/vpr_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ bool vpr_pack(t_vpr_setup& vpr_setup, const t_arch& arch) {
const Prepacker prepacker(g_vpr_ctx.atom().netlist(),
g_vpr_ctx.device().logical_block_types);

return try_pack(&vpr_setup.PackerOpts, &vpr_setup.AnalysisOpts,
return try_pack(vpr_setup.PackerOpts, vpr_setup.AnalysisOpts,
arch, vpr_setup.RoutingArch,
vpr_setup.PackerRRGraph,
prepacker,
Expand Down
2 changes: 0 additions & 2 deletions vpr/src/base/vpr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -717,9 +717,7 @@ struct t_packer_opts {
enum e_cluster_seed cluster_seed_type;
float alpha;
float beta;
float inter_cluster_net_delay;
float target_device_utilization;
bool auto_compute_inter_cluster_net_delay;
e_unrelated_clustering allow_unrelated_clustering;
bool connection_driven;
int pack_verbosity;
Expand Down
58 changes: 1 addition & 57 deletions vpr/src/pack/cluster_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
#include <algorithm>
#include <unordered_set>

#include "PreClusterTimingGraphResolver.h"
#include "PreClusterDelayCalculator.h"
#include "atom_netlist.h"
#include "attraction_groups.h"
#include "cluster_legalizer.h"
#include "clustered_netlist.h"
#include "concrete_timing_info.h"
#include "globals.h"
#include "output_clustering.h"
#include "prepack.h"
#include "tatum/TimingReporter.hpp"
#include "tatum/echo_writer.hpp"
#include "vpr_context.h"

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

void calc_init_packing_timing(const t_packer_opts& packer_opts,
const t_analysis_opts& analysis_opts,
const Prepacker& prepacker,
std::shared_ptr<PreClusterDelayCalculator>& clustering_delay_calc,
std::shared_ptr<SetupTimingInfo>& timing_info,
vtr::vector<AtomBlockId, float>& atom_criticality) {
const AtomContext& atom_ctx = g_vpr_ctx.atom();

/*
* Initialize the timing analyzer
*/
clustering_delay_calc = std::make_shared<PreClusterDelayCalculator>(atom_ctx.netlist(), atom_ctx.lookup(), packer_opts.inter_cluster_net_delay, prepacker);
timing_info = make_setup_timing_info(clustering_delay_calc, packer_opts.timing_update_type);

//Calculate the initial timing
timing_info->update();

if (isEchoFileEnabled(E_ECHO_PRE_PACKING_TIMING_GRAPH)) {
auto& timing_ctx = g_vpr_ctx.timing();
tatum::write_echo(getEchoFileName(E_ECHO_PRE_PACKING_TIMING_GRAPH),
*timing_ctx.graph, *timing_ctx.constraints, *clustering_delay_calc, timing_info->analyzer());

tatum::NodeId debug_tnode = id_or_pin_name_to_tnode(analysis_opts.echo_dot_timing_graph_node);
write_setup_timing_graph_dot(getEchoFileName(E_ECHO_PRE_PACKING_TIMING_GRAPH) + std::string(".dot"),
*timing_info, debug_tnode);
}

{
auto& timing_ctx = g_vpr_ctx.timing();
PreClusterTimingGraphResolver resolver(atom_ctx.netlist(),
atom_ctx.lookup(), *timing_ctx.graph, *clustering_delay_calc);
resolver.set_detail_level(analysis_opts.timing_report_detail);

tatum::TimingReporter timing_reporter(resolver, *timing_ctx.graph,
*timing_ctx.constraints);

timing_reporter.report_timing_setup(
"pre_pack.report_timing.setup.rpt",
*timing_info->setup_analyzer(),
analysis_opts.timing_report_npaths);
}

//Calculate true criticalities of each block
for (AtomBlockId blk : atom_ctx.netlist().blocks()) {
for (AtomPinId in_pin : atom_ctx.netlist().block_input_pins(blk)) {
//Max criticality over incoming nets
float crit = timing_info->setup_pin_criticality(in_pin);
atom_criticality[blk] = std::max(atom_criticality[blk], crit);
}
}
}

void check_and_output_clustering(ClusterLegalizer& cluster_legalizer,
const t_packer_opts& packer_opts,
const std::unordered_set<AtomNetId>& is_clock,
Expand Down
14 changes: 0 additions & 14 deletions vpr/src/pack/cluster_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ class AttractionInfo;
class ClusterBlockId;
class ClusterLegalizer;
class ClusteredNetlist;
class PreClusterDelayCalculator;
class Prepacker;
class SetupTimingInfo;
class t_pack_molecule;
struct AtomContext;

/**
Expand All @@ -26,16 +22,6 @@ struct AtomContext;
/* Clustering helper functions */
/***********************************/

/*
* @brief Calculate the initial timing at the start of packing stage.
*/
void calc_init_packing_timing(const t_packer_opts& packer_opts,
const t_analysis_opts& analysis_opts,
const Prepacker& prepacker,
std::shared_ptr<PreClusterDelayCalculator>& clustering_delay_calc,
std::shared_ptr<SetupTimingInfo>& timing_info,
vtr::vector<AtomBlockId, float>& atom_criticality);

/*
* @brief Check clustering legality and output it.
*/
Expand Down
12 changes: 8 additions & 4 deletions vpr/src/pack/greedy_candidate_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <cmath>
#include <queue>
#include <vector>
#include "PreClusterTimingManager.h"
#include "appack_context.h"
#include "flat_placement_types.h"
#include "flat_placement_utils.h"
Expand Down Expand Up @@ -90,7 +91,7 @@ GreedyCandidateSelector::GreedyCandidateSelector(
const std::unordered_set<AtomNetId>& is_clock,
const std::unordered_set<AtomNetId>& is_global,
const std::unordered_set<AtomNetId>& net_output_feeds_driving_block_input,
const SetupTimingInfo& timing_info,
const PreClusterTimingManager& pre_cluster_timing_manager,
const APPackContext& appack_ctx,
int log_verbosity)
: atom_netlist_(atom_netlist)
Expand All @@ -103,7 +104,7 @@ GreedyCandidateSelector::GreedyCandidateSelector(
, is_clock_(is_clock)
, is_global_(is_global)
, net_output_feeds_driving_block_input_(net_output_feeds_driving_block_input)
, timing_info_(timing_info)
, pre_cluster_timing_manager_(pre_cluster_timing_manager)
, appack_ctx_(appack_ctx)
, rng_(0) {

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

// Get the setup timing info used to compute timing gain terms.
const SetupTimingInfo& timing_info = pre_cluster_timing_manager_.get_timing_info();

if (net_relation_to_clustered_block == e_net_relation_to_clustered_block::OUTPUT
&& !is_global_.count(net_id)) {
for (AtomPinId pin_id : pins) {
AtomBlockId blk_id = atom_netlist_.pin_block(pin_id);
if (!cluster_legalizer.is_atom_clustered(blk_id)) {
double timing_gain = timing_info_.setup_pin_criticality(pin_id);
double timing_gain = timing_info.setup_pin_criticality(pin_id);

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

if (!cluster_legalizer.is_atom_clustered(new_blk_id)) {
for (AtomPinId pin_id : atom_netlist_.net_sinks(net_id)) {
double timing_gain = timing_info_.setup_pin_criticality(pin_id);
double timing_gain = timing_info.setup_pin_criticality(pin_id);

if (cluster_gain_stats.timing_gain.count(new_blk_id) == 0) {
cluster_gain_stats.timing_gain[new_blk_id] = 0;
Expand Down
16 changes: 9 additions & 7 deletions vpr/src/pack/greedy_candidate_selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
class AtomNetlist;
class AttractionInfo;
class FlatPlacementInfo;
class PreClusterTimingManager;
class Prepacker;
class SetupTimingInfo;
class t_pack_high_fanout_thresholds;
struct t_model;
struct t_molecule_stats;
Expand Down Expand Up @@ -225,9 +225,10 @@ class GreedyCandidateSelector {
* The set of nets whose output feeds the block that drives
* itself. This may cause double-counting in the gain
* calculations and needs special handling.
* @param timing_info
* Setup timing info for this Atom Netlist. Used to incorporate
* timing / criticality into the gain calculation.
* @param pre_cluster_timing_manager
* Timing manager that holds the information on timing of
* different connections in the circuit. Used for computing
* the timing gain terms.
* @param appack_ctx
* The APPack context which contains options for the flat
* placement guided packing.
Expand All @@ -244,7 +245,7 @@ class GreedyCandidateSelector {
const std::unordered_set<AtomNetId>& is_clock,
const std::unordered_set<AtomNetId>& is_global,
const std::unordered_set<AtomNetId>& net_output_feeds_driving_block_input,
const SetupTimingInfo& timing_info,
const PreClusterTimingManager& pre_cluster_timing_manager,
const APPackContext& appack_ctx,
int log_verbosity);

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

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

/// @brief Inter-block nets within a finalized cluster. Used for finding
/// transitive candidates.
Expand Down
18 changes: 4 additions & 14 deletions vpr/src/pack/greedy_clusterer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ GreedyClusterer::GreedyClusterer(const t_packer_opts& packer_opts,
const t_pack_high_fanout_thresholds& high_fanout_thresholds,
const std::unordered_set<AtomNetId>& is_clock,
const std::unordered_set<AtomNetId>& is_global,
const PreClusterTimingManager& pre_cluster_timing_manager,
const APPackContext& appack_ctx)
: packer_opts_(packer_opts)
, analysis_opts_(analysis_opts)
Expand All @@ -87,6 +88,7 @@ GreedyClusterer::GreedyClusterer(const t_packer_opts& packer_opts,
, high_fanout_thresholds_(high_fanout_thresholds)
, is_clock_(is_clock)
, is_global_(is_global)
, pre_cluster_timing_manager_(pre_cluster_timing_manager)
, appack_ctx_(appack_ctx)
, primitive_candidate_block_types_(identify_primitive_candidate_block_types())
, log_verbosity_(packer_opts.pack_verbosity)
Expand All @@ -113,18 +115,6 @@ GreedyClusterer::do_clustering(ClusterLegalizer& cluster_legalizer,
t_cluster_progress_stats clustering_stats;
clustering_stats.num_molecules = prepacker.molecules().size();

// TODO: Create a ClusteringTimingManager class.
// This code relies on the prepacker, once the prepacker is moved to
// the constructor, this code can also move to the constructor.
std::shared_ptr<PreClusterDelayCalculator> clustering_delay_calc;
std::shared_ptr<SetupTimingInfo> timing_info;
// Default criticalities set to zero (e.g. if not timing driven)
vtr::vector<AtomBlockId, float> atom_criticality(atom_netlist_.blocks().size(), 0.f);
if (packer_opts_.timing_driven) {
calc_init_packing_timing(packer_opts_, analysis_opts_, prepacker,
clustering_delay_calc, timing_info, atom_criticality);
}

// Calculate the max molecule stats, which is used for gain calculation.
const t_molecule_stats max_molecule_stats = prepacker.calc_max_molecule_stats(atom_netlist_);

Expand All @@ -140,7 +130,7 @@ GreedyClusterer::do_clustering(ClusterLegalizer& cluster_legalizer,
is_clock_,
is_global_,
net_output_feeds_driving_block_input_,
*timing_info,
pre_cluster_timing_manager_,
appack_ctx_,
log_verbosity_);

Expand All @@ -149,7 +139,7 @@ GreedyClusterer::do_clustering(ClusterLegalizer& cluster_legalizer,
prepacker,
packer_opts_.cluster_seed_type,
max_molecule_stats,
atom_criticality);
pre_cluster_timing_manager_);

// Pick the first seed molecule.
PackMoleculeId seed_mol_id = seed_selector.get_next_seed(prepacker,
Expand Down
11 changes: 10 additions & 1 deletion vpr/src/pack/greedy_clusterer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AtomNetlist;
class AttractionInfo;
class DeviceContext;
class GreedyCandidateSelector;
class SetupTimingInfo;
class PreClusterTimingManager;
class t_pack_high_fanout_thresholds;
struct t_analysis_opts;
struct t_clustering_data;
Expand Down Expand Up @@ -76,6 +76,11 @@ class GreedyClusterer {
* The set of global nets in the Atom Netlist. These will be
* routed on special dedicated networks, and hence are less
* relavent to locality / attraction.
* @param pre_cluster_timing_manager
* Timing manager class which holds the timing information of
* the primitive netlist. Used by the seed selector to select
* critical seeds and the candidate selector to select
* timing critical candidates.
* @param appack_ctx
* The APPack state. This contains the options used to
* configure APPack and the flat placement.
Expand All @@ -87,6 +92,7 @@ class GreedyClusterer {
const t_pack_high_fanout_thresholds& high_fanout_thresholds,
const std::unordered_set<AtomNetId>& is_clock,
const std::unordered_set<AtomNetId>& is_global,
const PreClusterTimingManager& pre_cluster_timing_manager,
const APPackContext& appack_ctx);

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

/// @brief Timing manager class which holds the primitive-level timing information.
const PreClusterTimingManager& pre_cluster_timing_manager_;

/// @brief The APPack state. This is used by the candidate selector to try
/// and propose better candidates based on a flat placement.
const APPackContext& appack_ctx_;
Expand Down
Loading