Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Partition based packer #2385

Open
wants to merge 2 commits into
base: openfpga
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions vpr/src/base/SetupVPR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,9 @@ void SetupPackerOpts(const t_options& Options,
PackerOpts->timing_update_type = Options.timing_update_type;
PackerOpts->pack_num_moves = Options.pack_num_moves;
PackerOpts->pack_move_type = Options.pack_move_type;
PackerOpts->use_partitioning_in_pack = Options.use_partitioning_in_pack;
PackerOpts->partitioner_path = Options.partitioner_path;
PackerOpts->number_of_molecules_in_partition = Options.number_of_molecules_in_partition;
}

static void SetupNetlistOpts(const t_options& Options, t_netlist_opts& NetlistOpts) {
Expand Down
16 changes: 16 additions & 0 deletions vpr/src/base/read_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1824,6 +1824,22 @@ argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& arg
"The available values are: randomSwap, semiDirectedSwap, semiDirectedSameTypeSwap")
.default_value("semiDirectedSwap")
.show_in(argparse::ShowIn::HELP_ONLY);

pack_grp.add_argument<bool, ParseOnOff>(args.use_partitioning_in_pack, "--use_partitioning_in_pack")
.help("Whether to use hmetis partitioning in pack.")
.help("Whether to use partitioning in pack.")
.default_value("off")
.show_in(argparse::ShowIn::HELP_ONLY);

pack_grp.add_argument<std::string>(args.partitioner_path, "--partitioner_path")
.help("The path to the partitioner (Mt-KaHyPar) executable.")
.default_value("~/bin/MtKaHyPar")
.show_in(argparse::ShowIn::HELP_ONLY);

pack_grp.add_argument<int>(args.number_of_molecules_in_partition, "--number_of_molecules_in_partition")
.help("Average number of molecules in each cluster. It should be used when --use_partitioning_in_pack is on.")
.default_value("64")
.show_in(argparse::ShowIn::HELP_ONLY);

auto& place_grp = parser.add_argument_group("placement options");

Expand Down
4 changes: 4 additions & 0 deletions vpr/src/base/read_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ struct t_options {
argparse::ArgValue<bool> use_attraction_groups;
argparse::ArgValue<int> pack_num_moves;
argparse::ArgValue<std::string> pack_move_type;
argparse::ArgValue<bool> use_partitioning_in_pack;
argparse::ArgValue<std::string> partitioner_path;
argparse::ArgValue<int> number_of_molecules_in_partition;

/* Placement options */
argparse::ArgValue<int> Seed;
argparse::ArgValue<bool> ShowPlaceTiming;
Expand Down
3 changes: 3 additions & 0 deletions vpr/src/base/vpr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,9 @@ struct t_packer_opts {
bool use_attraction_groups;
int pack_num_moves;
std::string pack_move_type;
bool use_partitioning_in_pack;
std::string partitioner_path;
int number_of_molecules_in_partition;
};

/**
Expand Down
841 changes: 707 additions & 134 deletions vpr/src/pack/cluster.cpp

Large diffs are not rendered by default.

36 changes: 34 additions & 2 deletions vpr/src/pack/cluster_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@
#include "vtr_math.h"
#include "SetupGrid.h"

// #include "vtr_assert.h"
// #include "vtr_log.h"
// #include "vtr_digest.h"
// #include "vtr_memory.h"

// #include "vpr_types.h"
// #include "vpr_error.h"

// #include "pugixml.hpp"

#include "globals.h"
#include "atom_netlist.h"
#include "pack_types.h"
#include "pb_type_graph.h"
#include "output_clustering.h"
#include "read_xml_arch_file.h"
#include "vpr_utils.h"
#include "pack.h"


/**********************************/
/* Global variables in clustering */
/**********************************/
Expand Down Expand Up @@ -268,6 +288,16 @@ void check_and_output_clustering(const t_packer_opts& packer_opts,
VTR_ASSERT(cluster_ctx.clb_nlist.blocks().size() == intra_lb_routing.size());
}

bool check_if_xml_mode_conflict(const t_packer_opts& packer_opts,
const t_arch* arch,
const vtr::vector<ClusterBlockId, std::vector<t_intra_lb_net>*>& intra_lb_routing) {

bool legal = check_output_clustering(intra_lb_routing, arch->architecture_id, packer_opts.output_file.c_str());

return legal;
}


void get_max_cluster_size_and_pb_depth(int& max_cluster_size,
int& max_pb_depth) {
auto& device_ctx = g_vpr_ctx.mutable_device();
Expand Down Expand Up @@ -1639,7 +1669,9 @@ t_pack_molecule* save_cluster_routing_and_pick_new_seed(const t_packer_opts& pac
router_data->saved_lb_nets = nullptr;

//Pick a new seed
next_seed = get_highest_gain_seed_molecule(&seedindex, seed_atoms);
if(!packer_opts.use_partitioning_in_pack){
next_seed = get_highest_gain_seed_molecule(&seedindex, seed_atoms);
}

if (packer_opts.timing_driven) {
if (num_blocks_hill_added > 0) {
Expand Down Expand Up @@ -3688,4 +3720,4 @@ void init_clb_atoms_lookup(vtr::vector<ClusterBlockId, std::unordered_set<AtomBl

atoms_lookup[clb_index].insert(atom_blk_id);
}
}
}
10 changes: 8 additions & 2 deletions vpr/src/pack/cluster_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
#include "vpr_utils.h"
#include "constraints_report.h"

#include "concrete_timing_info.h"
#include "timing_info.h"
#include "PreClusterDelayCalculator.h"
#include "PreClusterTimingGraphResolver.h"
#include "tatum/echo_writer.hpp"
#include "tatum/TimingReporter.hpp"
#include "concrete_timing_info.h"

/**
* @file
Expand Down Expand Up @@ -129,6 +130,11 @@ void check_and_output_clustering(const t_packer_opts& packer_opts,
const int& num_clb,
const vtr::vector<ClusterBlockId, std::vector<t_intra_lb_net>*>& intra_lb_routing);

bool check_if_xml_mode_conflict(const t_packer_opts& packer_opts,
const t_arch* arch,
const vtr::vector<ClusterBlockId, std::vector<t_intra_lb_net>*>& intra_lb_routing);


void get_max_cluster_size_and_pb_depth(int& max_cluster_size,
int& max_pb_depth);

Expand Down Expand Up @@ -452,4 +458,4 @@ bool cleanup_pb(t_pb* pb);
void alloc_and_load_pb_stats(t_pb* pb, const int feasible_block_array_size);

void init_clb_atoms_lookup(vtr::vector<ClusterBlockId, std::unordered_set<AtomBlockId>>& atoms_lookup);
#endif
#endif
Loading
Loading