Skip to content

NoC-aware packing optimization and NoC-biased centroid move type #2546

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

Merged
merged 43 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
66fa02d
avoid copying Region and PartitionRegion unnecessarily
soheilshahrouz Feb 15, 2024
cbe5665
pass by ref and range based loops
soheilshahrouz Feb 16, 2024
3777e5f
find noc router atoms
soheilshahrouz Feb 16, 2024
71f85c5
add exclusivity index to PartitionRegion
soheilshahrouz Feb 16, 2024
2917fca
add update_noc_reachability_partitions()
soheilshahrouz Feb 16, 2024
ca55771
changed unconstrained region coordinates
soheilshahrouz Feb 16, 2024
d5a98a4
bugfix: check if there is any unfixed Noc routers
soheilshahrouz Feb 16, 2024
5eb7a07
clean modified cluster_constraints elements
soheilshahrouz Feb 16, 2024
be66f83
Merge branch 'master' into noc_pack_part
soheilshahrouz Feb 23, 2024
895e34f
revert noc-aware clustering
soheilshahrouz Feb 23, 2024
f778c87
remove exclusivity_index and fix some typos
soheilshahrouz Feb 23, 2024
f23d7b5
Revert "remove exclusivity_index and fix some typos"
soheilshahrouz Feb 26, 2024
5dd2025
Revert "revert noc-aware clustering"
soheilshahrouz Feb 26, 2024
0d0d311
reduced fanout threshold in update_noc_reachability_partitions()
soheilshahrouz Feb 26, 2024
e4168ee
ignore reset
soheilshahrouz Feb 27, 2024
04e2f2a
lock NoC routers and constrain other blocks
soheilshahrouz Feb 28, 2024
5a54104
replace constant 32 with high fanout threshold for logic blocks
soheilshahrouz Mar 16, 2024
c379041
add NoC groups
soheilshahrouz Mar 16, 2024
d76e92e
add noc group move
soheilshahrouz Mar 17, 2024
eeac6c5
fix repetitive locs in NocGroupMoveGenerator
soheilshahrouz Mar 18, 2024
9dd89eb
centroid moves consider noc routers
soheilshahrouz Mar 18, 2024
a0af47f
Merge branch 'master' into noc_pack_part
soheilshahrouz Mar 18, 2024
09bcc42
add noc_centroid_weight
soheilshahrouz Mar 18, 2024
cfc9aa1
fix noc weight in centroid calculation
soheilshahrouz Mar 18, 2024
d7ad612
const ref
soheilshahrouz Mar 18, 2024
7b1339c
noc attracted centroid move
soheilshahrouz Mar 18, 2024
b0211ab
pass move types to KArmedBanditAgent constructor
soheilshahrouz Mar 18, 2024
c74ed3b
fix segault in SimpleRLMoveGenerator::propose_move() when noc centroi…
soheilshahrouz Mar 18, 2024
71064cb
Merge branch 'noc_turn_model_routing' into noc_pack_part
soheilshahrouz Mar 24, 2024
c69b432
Merge branch 'master' into noc_pack_part
soheilshahrouz Apr 28, 2024
790b652
move NoC-biased member vars from PlacementContext to CentroidMoveGene…
soheilshahrouz Apr 28, 2024
82ffe3f
enum class for e_block_pack_status
soheilshahrouz Apr 28, 2024
922246a
add noc_aware_cluster_util files
soheilshahrouz Apr 28, 2024
6e20704
check NoC group compatibility during packing
soheilshahrouz Apr 29, 2024
0026905
remove exclusivity_index from PartitionRegion
soheilshahrouz Apr 29, 2024
08bad8f
Merge branch 'specify_moves_explicitly' into noc_pack_part
soheilshahrouz Apr 29, 2024
ecb08bf
fix segfault when logic block type can't be inferred
soheilshahrouz Apr 29, 2024
9bfa10f
fix atom_cluster_floorplanning_check returning wrong value
soheilshahrouz Apr 29, 2024
d5aef9a
add log messages for atom_cluster_noc_group_check()
soheilshahrouz Apr 29, 2024
023ba47
add comments
soheilshahrouz May 14, 2024
1f2ac0b
avoid creating std::string every time log_move_abort is called
soheilshahrouz May 14, 2024
8338c90
Merge branch 'master' into noc_pack_part and resolved conflicts
soheilshahrouz May 14, 2024
80dcdeb
add comments and subroutines
soheilshahrouz May 22, 2024
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
5 changes: 3 additions & 2 deletions libs/libvtrutil/src/vtr_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <stdexcept>
#include <string>
#include <utility>

/**
* @file
Expand Down Expand Up @@ -34,9 +35,9 @@ namespace vtr {
class VtrError : public std::runtime_error {
public:
///@brief VtrError constructor
VtrError(std::string msg = "", std::string new_filename = "", size_t new_linenumber = -1)
VtrError(const std::string& msg = "", std::string new_filename = "", size_t new_linenumber = -1)
: std::runtime_error(msg)
, filename_(new_filename)
, filename_(std::move(new_filename))
, linenumber_(new_linenumber) {}

/**
Expand Down
29 changes: 12 additions & 17 deletions libs/libvtrutil/src/vtr_expr_eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ static bool is_char_number(const char ch);
static bool is_operator(const char ch);

// returns true if the specified name is a known function operator
static bool is_function(std::string name);
static bool is_function(const std::string& name);

// returns true if the specified name is a known compound operator
t_compound_operator is_compound_op(const char* ch);

// returns true if the specified name is a known variable
static bool is_variable(std::string var);
static bool is_variable(const std::string& var);

// returns the length of any identifier (e.g. name, function) starting at the beginning of str
static int identifier_length(const char* str);
Expand All @@ -76,14 +76,14 @@ static bool goto_next_char(int* str_ind, const string& pw_formula, char ch);
bool same_string(std::string str1, std::string str2);

//checks if the block indicated by the user was one of the moved blocks in the last perturbation
int in_blocks_affected(std::string expression_left);
int in_blocks_affected(const std::string& expression_left);

//the function of += operator
bool additional_assignment_op(int arg1, int arg2);

/**** Function Implementations ****/
/* returns integer result according to specified non-piece-wise formula and data */
int FormulaParser::parse_formula(std::string formula, const t_formula_data& mydata, bool is_breakpoint) {
int FormulaParser::parse_formula(const std::string& formula, const t_formula_data& mydata, bool is_breakpoint) {
int result = -1;

/* output in reverse-polish notation */
Expand Down Expand Up @@ -150,7 +150,7 @@ int FormulaParser::parse_piecewise_formula(const char* formula, const t_formula_
}
tmp_ind_count = str_ind - tmp_ind_start; /* range start is between { and : */
substr = pw_formula.substr(tmp_ind_start, tmp_ind_count);
range_start = parse_formula(substr.c_str(), mydata);
range_start = parse_formula(substr, mydata);

/* get the end of the range */
tmp_ind_start = str_ind + 1;
Expand All @@ -160,7 +160,7 @@ int FormulaParser::parse_piecewise_formula(const char* formula, const t_formula_
}
tmp_ind_count = str_ind - tmp_ind_start; /* range end is between : and } */
substr = pw_formula.substr(tmp_ind_start, tmp_ind_count);
range_end = parse_formula(substr.c_str(), mydata);
range_end = parse_formula(substr, mydata);

if (range_start > range_end) {
throw vtr::VtrError(vtr::string_fmt("parse_piecewise_formula: range_start, %d, is bigger than range end, %d\n", range_start, range_end), __FILE__, __LINE__);
Expand Down Expand Up @@ -287,8 +287,6 @@ static void formula_to_rpn(const char* formula, const t_formula_data& mydata, ve
rpn_output.push_back(fobj_dummy);
op_stack.pop();
}

return;
}

/* Fills the formula object fobj according to specified character and mydata,
Expand Down Expand Up @@ -352,7 +350,7 @@ static void get_formula_object(const char* ch, int& ichar, const t_formula_data&
}
ichar--;
fobj->type = E_FML_NUMBER;
fobj->data.num = vtr::atoi(ss.str().c_str());
fobj->data.num = vtr::atoi(ss.str());
} else if (is_compound_op(ch) != E_COM_OP_UNDEFINED) {
fobj->type = E_FML_OPERATOR;
t_compound_operator comp_op_code = is_compound_op(ch);
Expand Down Expand Up @@ -415,8 +413,6 @@ static void get_formula_object(const char* ch, int& ichar, const t_formula_data&
break;
}
}

return;
}

/* returns integer specifying precedence of passed-in operator. higher integer
Expand Down Expand Up @@ -562,7 +558,6 @@ static void handle_bracket(const Formula_Object& fobj, vector<Formula_Object>& r
}
} while (keep_going);
}
return;
}

/* used by the shunting-yard formula parser to deal with commas, ie ','. These occur in function calls*/
Expand Down Expand Up @@ -770,7 +765,7 @@ static bool is_operator(const char ch) {
}

//returns true if string signifies a function e.g max, min
static bool is_function(std::string name) {
static bool is_function(const std::string& name) {
if (name == "min"
|| name == "max"
|| name == "gcd"
Expand Down Expand Up @@ -801,7 +796,7 @@ t_compound_operator is_compound_op(const char* ch) {
}

//checks if the entered string is a known variable name
static bool is_variable(std::string var_name) {
static bool is_variable(const std::string& var_name) {
if (same_string(var_name, "from_block") || same_string(var_name, "temp_count") || same_string(var_name, "move_num") || same_string(var_name, "route_net_id") || same_string(var_name, "in_blocks_affected") || same_string(var_name, "router_iter")) {
return true;
}
Expand Down Expand Up @@ -849,11 +844,11 @@ bool same_string(std::string str1, std::string str2) {
str1.erase(remove(str1.begin(), str1.end(), ' '), str1.end());
str2.erase(remove(str2.begin(), str2.end(), ' '), str2.end());

//converting both strings to lower case to eliminate case sensivity
//converting both strings to lower case to eliminate case sensitivity
std::transform(str1.begin(), str1.end(), str1.begin(), ::tolower);
std::transform(str2.begin(), str2.end(), str2.begin(), ::tolower);

return (str1.compare(str2) == 0);
return (str1 == str2);
}

//the += operator
Expand All @@ -870,7 +865,7 @@ bool additional_assignment_op(int arg1, int arg2) {
//recognizes the block_id to look for (entered by the user)
//then looks for that block_id in all the blocks moved in the last perturbation.
//returns the block id if found, else just -1
int in_blocks_affected(std::string expression_left) {
int in_blocks_affected(const std::string& expression_left) {
int wanted_block = -1;
int found_block;
std::stringstream ss;
Expand Down
2 changes: 1 addition & 1 deletion libs/libvtrutil/src/vtr_expr_eval.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class FormulaParser {
FormulaParser& operator=(const FormulaParser&) = delete;

///@brief returns integer result according to specified formula and data
int parse_formula(std::string formula, const t_formula_data& mydata, bool is_breakpoint = false);
int parse_formula(const std::string& formula, const t_formula_data& mydata, bool is_breakpoint = false);

///@brief returns integer result according to specified piece-wise formula and data
int parse_piecewise_formula(const char* formula, const t_formula_data& mydata);
Expand Down
6 changes: 3 additions & 3 deletions vpr/src/base/CheckSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void CheckSetup(const t_packer_opts& PackerOpts,
const t_router_opts& RouterOpts,
const t_det_routing_arch& RoutingArch,
const std::vector<t_segment_inf>& Segments,
const t_timing_inf Timing,
const t_timing_inf& Timing,
const t_chan_width_dist Chans) {
int i;
int Tmp;
Expand All @@ -31,7 +31,7 @@ void CheckSetup(const t_packer_opts& PackerOpts,
"This is allowed, but strange, and circuit speed will suffer.\n");
}

if ((false == Timing.timing_analysis_enabled)
if (!Timing.timing_analysis_enabled
&& (PlacerOpts.place_algorithm.is_timing_driven())) {
/* May work, not tested */
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
Expand Down Expand Up @@ -72,7 +72,7 @@ void CheckSetup(const t_packer_opts& PackerOpts,
for (i = 0; i < (int)Segments.size(); ++i) {
Tmp = Segments[i].arch_opin_switch;
auto& device_ctx = g_vpr_ctx.device();
if (false == device_ctx.arch_switch_inf[Tmp].buffered()) {
if (!device_ctx.arch_switch_inf[Tmp].buffered()) {
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
"arch_opin_switch (#%d) of segment type #%d is not buffered.\n", Tmp, i);
}
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/base/CheckSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void CheckSetup(const t_packer_opts& PackerOpts,
const t_router_opts& RouterOpts,
const t_det_routing_arch& RoutingArch,
const std::vector<t_segment_inf>& Segments,
const t_timing_inf Timing,
const t_timing_inf& Timing,
const t_chan_width_dist Chans);

#endif
9 changes: 5 additions & 4 deletions vpr/src/base/SetupGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static void set_grid_block_type(int priority,
const t_metadata_dict* meta);

///@brief Create the device grid based on resource requirements
DeviceGrid create_device_grid(std::string layout_name, const std::vector<t_grid_def>& grid_layouts, const std::map<t_logical_block_type_ptr, size_t>& minimum_instance_counts, float target_device_utilization) {
DeviceGrid create_device_grid(const std::string& layout_name, const std::vector<t_grid_def>& grid_layouts, const std::map<t_logical_block_type_ptr, size_t>& minimum_instance_counts, float target_device_utilization) {
if (layout_name == "auto") {
//Auto-size the device
//
Expand Down Expand Up @@ -78,9 +78,9 @@ DeviceGrid create_device_grid(std::string layout_name, const std::vector<t_grid_
}

///@brief Create the device grid based on dimensions
DeviceGrid create_device_grid(std::string layout_name, const std::vector<t_grid_def>& grid_layouts, size_t width, size_t height) {
DeviceGrid create_device_grid(const std::string& layout_name, const std::vector<t_grid_def>& grid_layouts, size_t width, size_t height) {
if (layout_name == "auto") {
VTR_ASSERT(grid_layouts.size() > 0);
VTR_ASSERT(!grid_layouts.empty());
//Auto-size
if (grid_layouts[0].grid_type == GridDefType::AUTO) {
//Auto layout of the specified dimensions
Expand Down Expand Up @@ -145,7 +145,7 @@ DeviceGrid create_device_grid(std::string layout_name, const std::vector<t_grid_
* If an auto grid layouts are specified, the smallest dynamicly sized grid is picked
*/
static DeviceGrid auto_size_device_grid(const std::vector<t_grid_def>& grid_layouts, const std::map<t_logical_block_type_ptr, size_t>& minimum_instance_counts, float maximum_device_utilization) {
VTR_ASSERT(grid_layouts.size() > 0);
VTR_ASSERT(!grid_layouts.empty());

DeviceGrid grid;

Expand Down Expand Up @@ -281,6 +281,7 @@ static std::vector<t_logical_block_type_ptr> grid_overused_resources(const Devic

//Sort so we allocate logical blocks with the fewest equivalent sites first (least flexible)
std::vector<const t_logical_block_type*> logical_block_types;
logical_block_types.reserve(device_ctx.logical_block_types.size());
for (auto& block_type : device_ctx.logical_block_types) {
logical_block_types.push_back(&block_type);
}
Expand Down
7 changes: 5 additions & 2 deletions vpr/src/base/SetupGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
#include "physical_types.h"

///@brief Find the device satisfying the specified minimum resources
DeviceGrid create_device_grid(std::string layout_name,
DeviceGrid create_device_grid(const std::string& layout_name,
const std::vector<t_grid_def>& grid_layouts,
const std::map<t_logical_block_type_ptr, size_t>& minimum_instance_counts,
float target_device_utilization);

///@brief Find the device close in size to the specified dimensions
DeviceGrid create_device_grid(std::string layout_name, const std::vector<t_grid_def>& grid_layouts, size_t min_width, size_t min_height);
DeviceGrid create_device_grid(const std::string& layout_name,
const std::vector<t_grid_def>& grid_layouts,
size_t min_width,
size_t min_height);

/**
* @brief Calculate the device utilization
Expand Down
3 changes: 2 additions & 1 deletion vpr/src/base/SetupVPR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ static void SetupRoutingArch(const t_arch& Arch,
RoutingArch->R_minW_pmos = Arch.R_minW_pmos;
RoutingArch->Fs = Arch.Fs;
RoutingArch->directionality = BI_DIRECTIONAL;
if (Arch.Segments.size()) {
if (!Arch.Segments.empty()) {
RoutingArch->directionality = Arch.Segments[0].directionality;
}

Expand Down Expand Up @@ -740,6 +740,7 @@ static void SetupNocOpts(const t_options& Options, t_noc_opts* NocOpts) {
NocOpts->noc_latency_weighting = Options.noc_latency_weighting;
NocOpts->noc_congestion_weighting = Options.noc_congestion_weighting;
NocOpts->noc_swap_percentage = Options.noc_swap_percentage;
NocOpts->noc_centroid_weight = Options.noc_centroid_weight;
NocOpts->noc_placement_file_name = Options.noc_placement_file_name;
}

Expand Down
10 changes: 5 additions & 5 deletions vpr/src/base/atom_netlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ AtomBlockId AtomNetlist::find_atom_pin_driver(const AtomBlockId blk_id, const t_
return AtomBlockId::INVALID();
}

std::unordered_set<std::string> AtomNetlist::net_aliases(const std::string net_name) const {
std::unordered_set<std::string> AtomNetlist::net_aliases(const std::string& net_name) const {
auto net_id = find_net(net_name);
VTR_ASSERT(net_id != AtomNetId::INVALID());

Expand All @@ -137,7 +137,7 @@ std::unordered_set<std::string> AtomNetlist::net_aliases(const std::string net_n
* Mutators
*
*/
AtomBlockId AtomNetlist::create_block(const std::string name, const t_model* model, const TruthTable truth_table) {
AtomBlockId AtomNetlist::create_block(const std::string& name, const t_model* model, const TruthTable& truth_table) {
AtomBlockId blk_id = Netlist::create_block(name);

//Initialize the data
Expand Down Expand Up @@ -205,7 +205,7 @@ AtomPinId AtomNetlist::create_pin(const AtomPortId port_id, BitIndex port_bit, c
return pin_id;
}

AtomNetId AtomNetlist::create_net(const std::string name) {
AtomNetId AtomNetlist::create_net(const std::string& name) {
AtomNetId net_id = Netlist::create_net(name);

//Check post-conditions: size
Expand All @@ -214,11 +214,11 @@ AtomNetId AtomNetlist::create_net(const std::string name) {
return net_id;
}

AtomNetId AtomNetlist::add_net(const std::string name, AtomPinId driver, std::vector<AtomPinId> sinks) {
AtomNetId AtomNetlist::add_net(const std::string& name, AtomPinId driver, std::vector<AtomPinId> sinks) {
return Netlist::add_net(name, driver, sinks);
}

void AtomNetlist::add_net_alias(const std::string net_name, const std::string alias_net_name) {
void AtomNetlist::add_net_alias(const std::string& net_name, const std::string& alias_net_name) {
auto net_id = find_net(net_name);
VTR_ASSERT(net_id != AtomNetId::INVALID());

Expand Down
10 changes: 5 additions & 5 deletions vpr/src/base/atom_netlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class AtomNetlist : public Netlist<AtomBlockId, AtomPortId, AtomPinId, AtomNetId
*
* @param net_name name of the net from which the aliases are extracted
*/
std::unordered_set<std::string> net_aliases(const std::string net_name) const;
std::unordered_set<std::string> net_aliases(const std::string& net_name) const;

public: //Public Mutators
/*
Expand All @@ -173,7 +173,7 @@ class AtomNetlist : public Netlist<AtomBlockId, AtomPortId, AtomPinId, AtomNetId
* The truth_table is optional and only relevant for LUTs (where it describes the logic function)
* and Flip-Flops/latches (where it consists of a single entry defining the initial state).
*/
AtomBlockId create_block(const std::string name, const t_model* model, const TruthTable truth_table = TruthTable());
AtomBlockId create_block(const std::string& name, const t_model* model, const TruthTable& truth_table = TruthTable());

/**
* @brief Create or return an existing port in the netlist
Expand All @@ -199,7 +199,7 @@ class AtomNetlist : public Netlist<AtomBlockId, AtomPortId, AtomPinId, AtomNetId
*
* @param name The unique name of the net
*/
AtomNetId create_net(const std::string name); //An empty or existing net
AtomNetId create_net(const std::string& name); //An empty or existing net

/**
* @brief Create a completely specified net from specified driver and sinks
Expand All @@ -208,7 +208,7 @@ class AtomNetlist : public Netlist<AtomBlockId, AtomPortId, AtomPinId, AtomNetId
* @param driver The net's driver pin
* @param sinks The net's sink pins
*/
AtomNetId add_net(const std::string name, AtomPinId driver, std::vector<AtomPinId> sinks);
AtomNetId add_net(const std::string& name, AtomPinId driver, std::vector<AtomPinId> sinks);

/**
* @brief Adds a value to the net aliases set for a given net name in the net_aliases_map.
Expand All @@ -218,7 +218,7 @@ class AtomNetlist : public Netlist<AtomBlockId, AtomPortId, AtomPinId, AtomNetId
* @param net_name The net to be added to the map
* @param alias_net_name The alias of the assigned clock net id
*/
void add_net_alias(const std::string net_name, std::string alias_net_name);
void add_net_alias(const std::string& net_name, const std::string& alias_net_name);

private: //Private members
/*
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/base/constraints_load.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "constraints_load.h"

void echo_constraints(char* filename, VprConstraints constraints) {
void echo_constraints(char* filename, const VprConstraints& constraints) {
FILE* fp;
fp = vtr::fopen(filename, "w");

Expand Down
2 changes: 1 addition & 1 deletion vpr/src/base/constraints_load.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
#include "vtr_vector.h"

///@brief Used to print vpr's floorplanning constraints to an echo file "vpr_constraints.echo"
void echo_constraints(char* filename, VprConstraints constraints);
void echo_constraints(char* filename, const VprConstraints& constraints);

#endif
Loading
Loading