Skip to content

Commit 36ba8da

Browse files
authored
Merge pull request #2962 from AlexandreSinger/feature-ap-prepacker
[Prepacker] Moved the Prepacker Out of Try Pack
2 parents d80ee8b + 8bc630f commit 36ba8da

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

vpr/src/analytical_place/full_legalizer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ void APPack::legalize(const PartialPlacement& p_placement) {
518518
arch_,
519519
vpr_setup_.RoutingArch,
520520
vpr_setup_.PackerRRGraph,
521+
prepacker_,
521522
flat_placement_info);
522523

523524
// The Packer stores the clusters into a .net file. Load the packing file.

vpr/src/base/vpr_api.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,17 @@ bool vpr_pack(t_vpr_setup& vpr_setup, const t_arch& arch) {
614614
g_vpr_ctx.atom().netlist());
615615
}
616616

617+
// Run the prepacker, packing the atoms into molecules.
618+
// The Prepacker object performs prepacking and stores the pack molecules.
619+
// As long as the molecules are used, this object must persist.
620+
const Prepacker prepacker(g_vpr_ctx.atom().netlist(),
621+
g_vpr_ctx.device().logical_block_types);
622+
617623
return try_pack(&vpr_setup.PackerOpts, &vpr_setup.AnalysisOpts,
618624
arch, vpr_setup.RoutingArch,
619-
vpr_setup.PackerRRGraph, g_vpr_ctx.atom().flat_placement_info());
625+
vpr_setup.PackerRRGraph,
626+
prepacker,
627+
g_vpr_ctx.atom().flat_placement_info());
620628
}
621629

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

vpr/src/pack/pack.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ bool try_pack(t_packer_opts* packer_opts,
5656
const t_arch& arch,
5757
const t_det_routing_arch& routing_arch,
5858
std::vector<t_lb_type_rr_node>* lb_type_rr_graphs,
59+
const Prepacker& prepacker,
5960
const FlatPlacementInfo& flat_placement_info) {
6061
const AtomContext& atom_ctx = g_vpr_ctx.atom();
6162
const DeviceContext& device_ctx = g_vpr_ctx.device();
@@ -85,18 +86,10 @@ bool try_pack(t_packer_opts* packer_opts,
8586
VTR_LOG("\ttotal blocks: %zu, total nets: %zu, total inputs: %zu, total outputs: %zu\n",
8687
atom_ctx.netlist().blocks().size(), atom_ctx.netlist().nets().size(), num_p_inputs, num_p_outputs);
8788

88-
// Run the prepacker, packing the atoms into molecules.
89-
// The Prepacker object performs prepacking and stores the pack molecules.
90-
// As long as the molecules are used, this object must persist.
91-
VTR_LOG("Begin prepacking.\n");
92-
const Prepacker prepacker(atom_ctx.netlist(), device_ctx.logical_block_types);
93-
9489
/* We keep attraction groups off in the first iteration, and
9590
* only turn on in later iterations if some floorplan regions turn out to be overfull.
9691
*/
9792
AttractionInfo attraction_groups(false);
98-
VTR_LOG("%d attraction groups were created during prepacking.\n", attraction_groups.num_attraction_groups());
99-
VTR_LOG("Finish prepacking.\n");
10093

10194
// We keep track of the overfilled partition regions from all pack iterations in
10295
// this vector. This is so that if the first iteration fails due to overfilled

vpr/src/pack/pack.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
class AtomNetId;
88
class FlatPlacementInfo;
9+
class Prepacker;
910
struct t_analysis_opts;
1011
struct t_arch;
1112
struct t_det_routing_arch;
@@ -35,6 +36,7 @@ bool try_pack(t_packer_opts* packer_opts,
3536
const t_arch& arch,
3637
const t_det_routing_arch& routing_arch,
3738
std::vector<t_lb_type_rr_node>* lb_type_rr_graphs,
39+
const Prepacker& prepacker,
3840
const FlatPlacementInfo& flat_placement_info);
3941

4042
std::unordered_set<AtomNetId> alloc_and_load_is_clock();

vpr/src/pack/prepack.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "vpr_utils.h"
2828
#include "vtr_assert.h"
2929
#include "vtr_range.h"
30+
#include "vtr_time.h"
3031
#include "vtr_util.h"
3132
#include "vtr_vector.h"
3233

@@ -1668,7 +1669,7 @@ static void print_chain_starting_points(t_pack_patterns* chain_pattern) {
16681669

16691670
Prepacker::Prepacker(const AtomNetlist& atom_nlist,
16701671
const std::vector<t_logical_block_type>& logical_block_types) {
1671-
VTR_ASSERT_MSG(pack_molecules_.empty(), "Prepacker cannot be initialized twice.");
1672+
vtr::ScopedStartFinishTimer prepacker_timer("Prepacker");
16721673

16731674
// Allocate the pack patterns from the logical block types.
16741675
list_of_pack_patterns = alloc_and_load_pack_patterns(logical_block_types);

0 commit comments

Comments
 (0)