From f5c94ecf41502ac631e324e978fea7155a5d4b32 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Thu, 13 Mar 2025 12:52:20 -0400 Subject: [PATCH 1/9] commit changes that do not add super long lines and assignemnt in next line --- .../src/read_fpga_interchange_arch.cpp | 46 ++++----- .../src/read_fpga_interchange_arch.h | 12 +-- libs/libarchfpga/src/read_xml_arch_file.cpp | 80 +++++++-------- .../test/test_read_xml_arch_file.cpp | 3 +- libs/libvtrutil/src/vtr_prefix_sum.h | 10 +- libs/libvtrutil/src/vtr_vector.h | 11 ++- odin_ii/src/core/odin_memory.h | 4 +- odin_ii/src/utils/odin_types.h | 4 +- odin_ii/src/utils/odin_util.cpp | 8 +- vpr/src/analytical_place/partial_legalizer.h | 27 +++-- .../analytical_place/partial_placement.cpp | 9 +- vpr/src/analytical_place/partial_placement.h | 11 +-- vpr/src/base/load_flat_place.cpp | 4 +- vpr/src/base/partition_region.cpp | 2 +- vpr/src/base/partition_region.h | 1 - vpr/src/base/read_options.cpp | 1 - vpr/src/base/read_place.cpp | 6 +- vpr/src/base/region.cpp | 5 +- vpr/src/base/region.h | 6 +- vpr/src/base/vpr_context.cpp | 11 +-- vpr/src/base/vpr_context.h | 72 +++++++++----- vpr/src/draw/draw_floorplanning.cpp | 22 +++-- vpr/src/noc/negative_first_routing.cpp | 9 +- vpr/src/noc/noc_storage.cpp | 5 +- vpr/src/noc/noc_storage.h | 11 +-- vpr/src/noc/north_last_routing.cpp | 5 +- vpr/src/noc/odd_even_routing.cpp | 10 +- vpr/src/noc/sat_routing.cpp | 50 +++++----- vpr/src/noc/turn_model_routing.h | 16 ++- vpr/src/pack/constraints_report.cpp | 16 ++- vpr/src/pack/constraints_report.h | 8 +- vpr/src/pack/greedy_candidate_selector.cpp | 6 +- vpr/src/pack/greedy_candidate_selector.h | 99 +++++++++---------- vpr/src/pack/pb_type_graph.cpp | 21 ++-- vpr/src/pack/verify_clustering.cpp | 9 +- vpr/src/place/annealer.h | 4 +- .../move_generators/median_move_generator.h | 4 +- .../place/move_generators/move_generator.h | 11 +-- vpr/src/place/move_utils.cpp | 9 +- vpr/src/place/move_utils.h | 1 - vpr/src/place/noc_place_utils.cpp | 1 - vpr/src/place/placer_breakpoint.cpp | 8 +- vpr/src/place/placer_breakpoint.h | 15 ++- vpr/src/route/ParallelNetlistRouter.tpp | 2 +- vpr/src/route/router_lookahead_map.cpp | 28 +++--- vpr/src/route/router_lookahead_map_utils.cpp | 2 - vpr/src/route/router_lookahead_sampling.cpp | 12 +-- vpr/src/route/rr_graph.cpp | 98 +++++++++--------- vpr/src/route/rr_graph2.cpp | 25 +++-- 49 files changed, 405 insertions(+), 435 deletions(-) diff --git a/libs/libarchfpga/src/read_fpga_interchange_arch.cpp b/libs/libarchfpga/src/read_fpga_interchange_arch.cpp index 8737503da3b..50840cbb948 100644 --- a/libs/libarchfpga/src/read_fpga_interchange_arch.cpp +++ b/libs/libarchfpga/src/read_fpga_interchange_arch.cpp @@ -5,28 +5,28 @@ #ifdef VTR_ENABLE_CAPNPROTO -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include - -# include "vtr_assert.h" -# include "vtr_digest.h" -# include "vtr_log.h" -# include "vtr_memory.h" -# include "vtr_util.h" - -# include "arch_check.h" -# include "arch_error.h" -# include "arch_util.h" -# include "arch_types.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "vtr_assert.h" +#include "vtr_digest.h" +#include "vtr_log.h" +#include "vtr_memory.h" +#include "vtr_util.h" + +#include "arch_check.h" +#include "arch_error.h" +#include "arch_util.h" +#include "arch_types.h" /* * FPGA Interchange Device frontend @@ -1076,7 +1076,7 @@ struct ArchReader { continue; // Check for duplicates - auto is_duplicate = [name](const t_logical_block_type& l)-> bool { return l.name == name; }; + auto is_duplicate = [name](const t_logical_block_type& l) -> bool { return l.name == name; }; VTR_ASSERT(std::find_if(ltypes_.begin(), ltypes_.end(), is_duplicate) == ltypes_.end()); ltype.name = name; diff --git a/libs/libarchfpga/src/read_fpga_interchange_arch.h b/libs/libarchfpga/src/read_fpga_interchange_arch.h index c859f97a002..753b44d3010 100644 --- a/libs/libarchfpga/src/read_fpga_interchange_arch.h +++ b/libs/libarchfpga/src/read_fpga_interchange_arch.h @@ -5,12 +5,12 @@ #ifdef VTR_ENABLE_CAPNPROTO -# include "DeviceResources.capnp.h" -# include "LogicalNetlist.capnp.h" -# include "capnp/serialize.h" -# include "capnp/serialize-packed.h" -# include -# include +#include "DeviceResources.capnp.h" +#include "LogicalNetlist.capnp.h" +#include "capnp/serialize.h" +#include "capnp/serialize-packed.h" +#include +#include #endif // VTR_ENABLE_CAPNPROTO diff --git a/libs/libarchfpga/src/read_xml_arch_file.cpp b/libs/libarchfpga/src/read_xml_arch_file.cpp index 46cde415630..b198ebec8ba 100644 --- a/libs/libarchfpga/src/read_xml_arch_file.cpp +++ b/libs/libarchfpga/src/read_xml_arch_file.cpp @@ -194,7 +194,7 @@ static void ProcessSubTiles(pugi::xml_node Node, * string interment storage. * @param loc_data Points to the location in the architecture file where the parser is reading. * @param pb_idx Used to assign unique values to index_in_logical_block field in -* t_pb_type for all pb_types under a logical block type. + * t_pb_type for all pb_types under a logical block type. */ static void ProcessPb_Type(pugi::xml_node Parent, t_pb_type* pb_type, @@ -253,7 +253,7 @@ static void ProcessMode(pugi::xml_node Parent, * @brief Processes tags. * * @param strings String internment storage used to store strings used -* as keys and values in tags. + * as keys and values in tags. * @param Parent An XML node pointing to the parent tag whose children * are to be parsed. * @param loc_data Points to the location in the architecture file where the parser is reading. @@ -358,7 +358,6 @@ static void ProcessPower(pugi::xml_node parent, static void ProcessClocks(pugi::xml_node Parent, t_clock_arch* clocks, const pugiutil::loc_data& loc_data); - static void ProcessPb_TypePowerEstMethod(pugi::xml_node Parent, t_pb_type* pb_type, const pugiutil::loc_data& loc_data); static void ProcessPb_TypePort_Power(pugi::xml_node Parent, t_port* port, e_power_estimation_method power_method, const pugiutil::loc_data& loc_data); @@ -1749,10 +1748,9 @@ static void ProcessInterconnect(vtr::string_internment& strings, } mode->interconnect[interconnect_idx].annotations = (t_pin_to_pin_annotation*)vtr::calloc(num_annotations, - sizeof(t_pin_to_pin_annotation)); + sizeof(t_pin_to_pin_annotation)); mode->interconnect[interconnect_idx].num_annotations = num_annotations; - int annotation_idx = 0; for (auto annot_child_name : {"delay_constant", "delay_matrix", "C_constant", "C_matrix", "pack_pattern"}) { pugi::xml_node Cur2 = get_first_child(Cur, annot_child_name, loc_data, ReqOpt::OPTIONAL); @@ -1770,7 +1768,7 @@ static void ProcessInterconnect(vtr::string_internment& strings, /* Power */ mode->interconnect[interconnect_idx].interconnect_power = (t_interconnect_power*)vtr::calloc(1, - sizeof(t_interconnect_power)); + sizeof(t_interconnect_power)); mode->interconnect[interconnect_idx].interconnect_power->port_info_initialized = false; /* get next iteration */ @@ -3805,63 +3803,61 @@ static std::vector ProcessSegments(pugi::xml_node Parent, tmp = get_attribute(SubElem, "name", loc_data, ReqOpt::OPTIONAL).as_string(nullptr); //check if tag is defined in the architecture, otherwise we should look for and - if(tmp){ + if (tmp) { /* Match names */ int switch_idx = find_switch_by_name(switches, tmp); if (switch_idx < 0) { archfpga_throw(loc_data.filename_c_str(), loc_data.line(SubElem), - "'%s' is not a valid mux name.\n", tmp); + "'%s' is not a valid mux name.\n", tmp); } /* Unidir muxes must have the same switch - * for wire and opin fanin since there is - * really only the mux in unidir. */ + * for wire and opin fanin since there is + * really only the mux in unidir. */ Segs[i].arch_wire_switch = switch_idx; Segs[i].arch_opin_switch = switch_idx; - } - else { //if a general mux is not defined, we should look for specific mux for each direction in the architecture file + } else { //if a general mux is not defined, we should look for specific mux for each direction in the architecture file SubElem = get_single_child(Node, "mux_inc", loc_data, ReqOpt::OPTIONAL); tmp = get_attribute(SubElem, "name", loc_data, ReqOpt::OPTIONAL).as_string(nullptr); - if(!tmp){ + if (!tmp) { archfpga_throw(loc_data.filename_c_str(), loc_data.line(SubElem), - "if mux is not specified in a wire segment, both mux_inc and mux_dec should be specified"); - } else{ + "if mux is not specified in a wire segment, both mux_inc and mux_dec should be specified"); + } else { /* Match names */ int switch_idx = find_switch_by_name(switches, tmp); if (switch_idx < 0) { archfpga_throw(loc_data.filename_c_str(), loc_data.line(SubElem), - "'%s' is not a valid mux name.\n", tmp); + "'%s' is not a valid mux name.\n", tmp); } /* Unidir muxes must have the same switch - * for wire and opin fanin since there is - * really only the mux in unidir. */ + * for wire and opin fanin since there is + * really only the mux in unidir. */ Segs[i].arch_wire_switch = switch_idx; Segs[i].arch_opin_switch = switch_idx; } SubElem = get_single_child(Node, "mux_dec", loc_data, ReqOpt::OPTIONAL); tmp = get_attribute(SubElem, "name", loc_data, ReqOpt::OPTIONAL).as_string(nullptr); - if(!tmp){ + if (!tmp) { archfpga_throw(loc_data.filename_c_str(), loc_data.line(SubElem), - "if mux is not specified in a wire segment, both mux_inc and mux_dec should be specified"); - } else{ + "if mux is not specified in a wire segment, both mux_inc and mux_dec should be specified"); + } else { /* Match names */ int switch_idx = find_switch_by_name(switches, tmp); if (switch_idx < 0) { archfpga_throw(loc_data.filename_c_str(), loc_data.line(SubElem), - "'%s' is not a valid mux name.\n", tmp); + "'%s' is not a valid mux name.\n", tmp); } /* Unidir muxes must have the same switch - * for wire and opin fanin since there is - * really only the mux in unidir. */ + * for wire and opin fanin since there is + * really only the mux in unidir. */ Segs[i].arch_wire_switch_dec = switch_idx; Segs[i].arch_opin_switch_dec = switch_idx; } } - } - else { + } else { VTR_ASSERT(BI_DIRECTIONAL == Segs[i].directionality); SubElem = get_single_child(Node, "wire_switch", loc_data); tmp = get_attribute(SubElem, "name", loc_data).value(); @@ -3920,13 +3916,12 @@ static std::vector ProcessSegments(pugi::xml_node Parent, return Segs; } - -static void calculate_custom_SB_locations(const pugiutil::loc_data& loc_data, const pugi::xml_node& SubElem, const int grid_width, const int grid_height, t_switchblock_inf& sb){ +static void calculate_custom_SB_locations(const pugiutil::loc_data& loc_data, const pugi::xml_node& SubElem, const int grid_width, const int grid_height, t_switchblock_inf& sb) { auto startx_attr = get_attribute(SubElem, "startx", loc_data, ReqOpt::OPTIONAL); - auto endx_attr = get_attribute(SubElem, "endx", loc_data, ReqOpt::OPTIONAL); + auto endx_attr = get_attribute(SubElem, "endx", loc_data, ReqOpt::OPTIONAL); auto starty_attr = get_attribute(SubElem, "starty", loc_data, ReqOpt::OPTIONAL); - auto endy_attr = get_attribute(SubElem, "endy", loc_data, ReqOpt::OPTIONAL); + auto endy_attr = get_attribute(SubElem, "endy", loc_data, ReqOpt::OPTIONAL); auto repeatx_attr = get_attribute(SubElem, "repeatx", loc_data, ReqOpt::OPTIONAL); auto repeaty_attr = get_attribute(SubElem, "repeaty", loc_data, ReqOpt::OPTIONAL); @@ -3941,19 +3936,17 @@ static void calculate_custom_SB_locations(const pugiutil::loc_data& loc_data, co vars.set_var_value("W", grid_width); vars.set_var_value("H", grid_height); - sb.reg_x.start = startx_attr.empty() ? 0 : p.parse_formula(startx_attr.value(), vars); sb.reg_y.start = starty_attr.empty() ? 0 : p.parse_formula(starty_attr.value(), vars); sb.reg_x.end = endx_attr.empty() ? (grid_width - 1) : p.parse_formula(endx_attr.value(), vars); - sb.reg_y.end = endy_attr.empty() ? (grid_height -1) : p.parse_formula(endy_attr.value(), vars); + sb.reg_y.end = endy_attr.empty() ? (grid_height - 1) : p.parse_formula(endy_attr.value(), vars); sb.reg_x.repeat = repeatx_attr.empty() ? 0 : p.parse_formula(repeatx_attr.value(), vars); sb.reg_y.repeat = repeaty_attr.empty() ? 0 : p.parse_formula(repeaty_attr.value(), vars); sb.reg_x.incr = incrx_attr.empty() ? 1 : p.parse_formula(incrx_attr.value(), vars); sb.reg_y.incr = incry_attr.empty() ? 1 : p.parse_formula(incry_attr.value(), vars); - } /* Processes the switchblocklist section from the xml architecture file. @@ -3967,10 +3960,10 @@ static void ProcessSwitchblocks(pugi::xml_node Parent, t_arch* arch, const pugiu /* get the number of switchblocks */ int num_switchblocks = count_children(Parent, "switchblock", loc_data); arch->switchblocks.reserve(num_switchblocks); - + int layout_index = -1; - for(layout_index = 0; layout_index < (int) arch->grid_layouts.size(); layout_index++){ - if(arch->grid_layouts.at(layout_index).name == arch->device_layout){ + for (layout_index = 0; layout_index < (int)arch->grid_layouts.size(); layout_index++) { + if (arch->grid_layouts.at(layout_index).name == arch->device_layout) { //found the used layout break; } @@ -4022,8 +4015,8 @@ static void ProcessSwitchblocks(pugi::xml_node Parent, t_arch* arch, const pugiu } /* get the switchblock coordinate only if sb.location is set to E_XY_SPECIFIED*/ - if(sb.location == e_sb_location::E_XY_SPECIFIED){ - if (arch->device_layout == "auto"){ + if (sb.location == e_sb_location::E_XY_SPECIFIED) { + if (arch->device_layout == "auto") { archfpga_throw(loc_data.filename_c_str(), loc_data.line(SubElem), "Specifying SB locations for auto layout devices are not supported yet!\n"); } expect_only_attributes(SubElem, @@ -4034,17 +4027,17 @@ static void ProcessSwitchblocks(pugi::xml_node Parent, t_arch* arch, const pugiu int grid_width = arch->grid_layouts.at(layout_index).width; int grid_height = arch->grid_layouts.at(layout_index).height; - + /* Absolute location that this SB must be applied to, -1 if not specified*/ sb.x = get_attribute(SubElem, "x", loc_data, ReqOpt::OPTIONAL).as_int(-1); sb.y = get_attribute(SubElem, "y", loc_data, ReqOpt::OPTIONAL).as_int(-1); //check if the absolute value is within the device grid width and height - if(sb.x >= grid_width || sb.y >= grid_height) { - archfpga_throw(loc_data.filename_c_str(), loc_data.line(SubElem), \ - "Location (%d,%d) is not valid within the grid! grid dimensions are: (%d,%d)\n", sb.x, sb.y, grid_width, grid_height); + if (sb.x >= grid_width || sb.y >= grid_height) { + archfpga_throw(loc_data.filename_c_str(), loc_data.line(SubElem), + "Location (%d,%d) is not valid within the grid! grid dimensions are: (%d,%d)\n", sb.x, sb.y, grid_width, grid_height); } - + /* if the the switchblock exact location is not specified and a region is specified within the architecture file, * we have to parse the region specification and apply the SB pattern to all the locations fall into the specified * region based on device width and height. @@ -4052,7 +4045,6 @@ static void ProcessSwitchblocks(pugi::xml_node Parent, t_arch* arch, const pugiu if (sb.x == -1 && sb.y == -1) { calculate_custom_SB_locations(loc_data, SubElem, grid_width, grid_height, sb); } - } /* get switchblock permutation functions */ diff --git a/libs/libarchfpga/test/test_read_xml_arch_file.cpp b/libs/libarchfpga/test/test_read_xml_arch_file.cpp index 9e32268cb6e..24a17af9ea2 100644 --- a/libs/libarchfpga/test/test_read_xml_arch_file.cpp +++ b/libs/libarchfpga/test/test_read_xml_arch_file.cpp @@ -155,8 +155,7 @@ TEST_CASE("Verifying mesh topology creation", "[NoC Arch Tests]") { .end_y = 56.0f, .start_layer = 0, .end_layer = 0, - .mesh_size = 0 - }; + .mesh_size = 0}; SECTION("Check the error where a mesh size was illegal.") { REQUIRE_THROWS_WITH(generate_noc_mesh(test, test_location, &test_noc, mesh_region), "The NoC mesh size cannot be 0."); diff --git a/libs/libvtrutil/src/vtr_prefix_sum.h b/libs/libvtrutil/src/vtr_prefix_sum.h index 030cce9d3d3..dce04feecf4 100644 --- a/libs/libvtrutil/src/vtr_prefix_sum.h +++ b/libs/libvtrutil/src/vtr_prefix_sum.h @@ -55,7 +55,7 @@ namespace vtr { */ template class PrefixSum1D { -public: + public: PrefixSum1D() = default; /** @@ -80,7 +80,7 @@ class PrefixSum1D { * to be passed in. */ PrefixSum1D(size_t length, std::function lookup, T zero = T()) - : prefix_sum_(length + 1, zero) { + : prefix_sum_(length + 1, zero) { // The first value in the prefix sum is already initialized to 0. // Initialize the prefix sum. The prefix sum at position x is the sum @@ -178,7 +178,7 @@ class PrefixSum1D { */ template class PrefixSum2D { -public: + public: PrefixSum2D() = default; /** @@ -205,7 +205,7 @@ class PrefixSum2D { * to be passed in. */ PrefixSum2D(size_t w, size_t h, std::function lookup, T zero = T()) - : prefix_sum_({w + 1, h + 1}, zero) { + : prefix_sum_({w + 1, h + 1}, zero) { // The first row and first column should already be initialized to zero. // Initialize the prefix sum. The prefix sum at position (x, y) is the @@ -266,7 +266,7 @@ class PrefixSum2D { + prefix_sum_[lower_x][lower_y]; } -private: + private: /** * @brief The 2D prefix sum of the original grid of values. * diff --git a/libs/libvtrutil/src/vtr_vector.h b/libs/libvtrutil/src/vtr_vector.h index be4e5874e98..921238a77d7 100644 --- a/libs/libvtrutil/src/vtr_vector.h +++ b/libs/libvtrutil/src/vtr_vector.h @@ -180,17 +180,20 @@ class vector : private std::vector { vector::const_iterator iter; bool operator!=(const enumerated_iterator& other) const { return iter != other.iter; } - void operator++() { i = key_type(size_t(i) + 1); iter++; } + void operator++() { + i = key_type(size_t(i) + 1); + iter++; + } std::tuple operator*() { return std::tie(i, *iter); } }; struct enumerated_wrapper { const vector& vec; - auto begin() { return enumerated_iterator{ key_type(0), vec.begin() }; } - auto end() { return enumerated_iterator{ key_type(vec.size()), vec.end() }; } + auto begin() { return enumerated_iterator{key_type(0), vec.begin()}; } + auto end() { return enumerated_iterator{key_type(vec.size()), vec.end()}; } }; - return enumerated_wrapper{ *this }; + return enumerated_wrapper{*this}; } public: diff --git a/odin_ii/src/core/odin_memory.h b/odin_ii/src/core/odin_memory.h index f681ba5e50a..ee1388ab200 100644 --- a/odin_ii/src/core/odin_memory.h +++ b/odin_ii/src/core/odin_memory.h @@ -35,9 +35,9 @@ #include "odin_error.h" #ifndef __GLIBC__ -# include +#include #else -# include +#include #endif namespace odin { diff --git a/odin_ii/src/utils/odin_types.h b/odin_ii/src/utils/odin_types.h index 2fa18d01f11..8ff837d1114 100644 --- a/odin_ii/src/utils/odin_types.h +++ b/odin_ii/src/utils/odin_types.h @@ -48,9 +48,9 @@ #define ODIN_SHORT_STRING 1 #ifndef DEBUG_ODIN -# define ODIN_STRING_TYPE ODIN_SHORT_STRING +#define ODIN_STRING_TYPE ODIN_SHORT_STRING #else -# define ODIN_STRING_TYPE ODIN_LONG_STRING +#define ODIN_STRING_TYPE ODIN_LONG_STRING #endif #define ODIN_STD_BITWIDTH (sizeof(long) * 8) diff --git a/odin_ii/src/utils/odin_util.cpp b/odin_ii/src/utils/odin_util.cpp index 2597fcfdb9e..4b605607f4e 100644 --- a/odin_ii/src/utils/odin_util.cpp +++ b/odin_ii/src/utils/odin_util.cpp @@ -43,11 +43,11 @@ // for mkdir #ifdef WIN32 -# include -# define getcwd _getcwd +#include +#define getcwd _getcwd #else -# include -# include +#include +#include #endif long shift_left_value_with_overflow_check(long input_value, long shift_by, loc_t loc) { diff --git a/vpr/src/analytical_place/partial_legalizer.h b/vpr/src/analytical_place/partial_legalizer.h index 11311312ae5..2921465fae3 100644 --- a/vpr/src/analytical_place/partial_legalizer.h +++ b/vpr/src/analytical_place/partial_legalizer.h @@ -31,8 +31,8 @@ struct PartialPlacement; * VPR. */ enum class e_partial_legalizer { - FLOW_BASED, // Multi-commodity flow-based partial legalizer. - BI_PARTITIONING // Bi-partitioning partial legalizer. + FLOW_BASED, // Multi-commodity flow-based partial legalizer. + BI_PARTITIONING // Bi-partitioning partial legalizer. }; /** @@ -45,7 +45,7 @@ enum class e_partial_legalizer { * compare different solvers. */ class PartialLegalizer { -public: + public: virtual ~PartialLegalizer() {} /** @@ -54,8 +54,8 @@ class PartialLegalizer { * Currently just copies the parameters into the class as member varaibles. */ PartialLegalizer(const APNetlist& netlist, int log_verbosity) - : netlist_(netlist), - log_verbosity_(log_verbosity) {} + : netlist_(netlist) + , log_verbosity_(log_verbosity) {} /** * @brief Partially legalize the given partial placement. @@ -70,10 +70,9 @@ class PartialLegalizer { * @param p_placement The placement to legalize. Will be filled with the * legalized placement. */ - virtual void legalize(PartialPlacement &p_placement) = 0; - -protected: + virtual void legalize(PartialPlacement& p_placement) = 0; + protected: /// @brief The APNetlist the legalizer will be legalizing the placement of. /// It is implied that the netlist is not being modified during /// global placement. @@ -109,7 +108,7 @@ std::unique_ptr make_partial_legalizer(e_partial_legalizer leg * https://doi.org/10.1145/3289602.3293896 */ class FlowBasedLegalizer : public PartialLegalizer { -private: + private: /// @brief The maximum number of iterations the legalizer can take. This /// prevents the legalizer from never converging if there is not /// enough space to flow blocks. @@ -220,8 +219,7 @@ class FlowBasedLegalizer : public PartialLegalizer { const PartialPlacement& p_placement, float psi); -public: - + public: /** * @brief Constructor for the flow-based legalizer. * @@ -239,7 +237,7 @@ class FlowBasedLegalizer : public PartialLegalizer { * @param p_placement The placmeent to legalize. The result of the partial * legalizer will be stored in this object. */ - void legalize(PartialPlacement &p_placement) final; + void legalize(PartialPlacement& p_placement) final; }; /** @@ -260,7 +258,7 @@ class FlowBasedLegalizer : public PartialLegalizer { * GPlace3.0: https://doi.org/10.1145/3233244 */ class BiPartitioningPartialLegalizer : public PartialLegalizer { -public: + public: /** * @brief Constructor for the bi-partitioning partial legalizer. * @@ -280,9 +278,8 @@ class BiPartitioningPartialLegalizer : public PartialLegalizer { */ void legalize(PartialPlacement& p_placement) final; -private: + private: /// @brief The density manager which manages the capacity and utilization /// of regions of the device. std::shared_ptr density_manager_; }; - diff --git a/vpr/src/analytical_place/partial_placement.cpp b/vpr/src/analytical_place/partial_placement.cpp index fc80f43b4a7..4e52faecef0 100644 --- a/vpr/src/analytical_place/partial_placement.cpp +++ b/vpr/src/analytical_place/partial_placement.cpp @@ -43,13 +43,9 @@ bool PartialPlacement::verify_locs(const APNetlist& netlist, for (APBlockId blk_id : netlist.blocks()) { double x_pos = block_x_locs[blk_id]; double y_pos = block_y_locs[blk_id]; - if (std::isnan(x_pos) || - x_pos < 0.0 || - x_pos >= grid_width) + if (std::isnan(x_pos) || x_pos < 0.0 || x_pos >= grid_width) return false; - if (std::isnan(y_pos) || - y_pos < 0.0 || - y_pos >= grid_height) + if (std::isnan(y_pos) || y_pos < 0.0 || y_pos >= grid_height) return false; if (netlist.block_mobility(blk_id) == APBlockMobility::FIXED) { const APFixedBlockLoc& fixed_loc = netlist.block_loc(blk_id); @@ -120,4 +116,3 @@ bool PartialPlacement::verify(const APNetlist& netlist, // If all other verify methods passed, then the placement is valid. return true; } - diff --git a/vpr/src/analytical_place/partial_placement.h b/vpr/src/analytical_place/partial_placement.h index e111dd7bd79..bb7406fcd34 100644 --- a/vpr/src/analytical_place/partial_placement.h +++ b/vpr/src/analytical_place/partial_placement.h @@ -71,10 +71,10 @@ struct PartialPlacement { * @param netlist The APNetlist which contains the blocks to be placed. */ PartialPlacement(const APNetlist& netlist) - : block_x_locs(netlist.blocks().size(), -1.0), - block_y_locs(netlist.blocks().size(), -1.0), - block_layer_nums(netlist.blocks().size(), 0.0), - block_sub_tiles(netlist.blocks().size(), 0) { + : block_x_locs(netlist.blocks().size(), -1.0) + , block_y_locs(netlist.blocks().size(), -1.0) + , block_layer_nums(netlist.blocks().size(), 0.0) + , block_sub_tiles(netlist.blocks().size(), 0) { // Note: All blocks are initialized to: // x_loc = -1.0 // y_loc = -1.0 @@ -84,7 +84,7 @@ struct PartialPlacement { for (APBlockId blk_id : netlist.blocks()) { if (netlist.block_mobility(blk_id) != APBlockMobility::FIXED) continue; - const APFixedBlockLoc &loc = netlist.block_loc(blk_id); + const APFixedBlockLoc& loc = netlist.block_loc(blk_id); if (loc.x != -1) block_x_locs[blk_id] = loc.x; if (loc.y != -1) @@ -201,4 +201,3 @@ struct PartialPlacement { size_t grid_height, size_t grid_num_layers) const; }; - diff --git a/vpr/src/base/load_flat_place.cpp b/vpr/src/base/load_flat_place.cpp index 05841e6e014..0e77c9b9192 100644 --- a/vpr/src/base/load_flat_place.cpp +++ b/vpr/src/base/load_flat_place.cpp @@ -59,7 +59,7 @@ static void print_flat_placement_file_header(FILE* fp) { */ static void print_flat_cluster(FILE* fp, ClusterBlockId blk_id, - const vtr::vector_map &block_locs, + const vtr::vector_map& block_locs, const vtr::vector>& atoms_lookup) { // Atom context used to get the atom_pb for each atom in the cluster. // NOTE: This is only used for getting the flat site index. @@ -86,7 +86,7 @@ static void print_flat_cluster(FILE* fp, void write_flat_placement(const char* flat_place_file_path, const ClusteredNetlist& cluster_netlist, - const vtr::vector_map &block_locs, + const vtr::vector_map& block_locs, const vtr::vector>& atoms_lookup) { // Writes the flat placement to the given flat_place_file_path. diff --git a/vpr/src/base/partition_region.cpp b/vpr/src/base/partition_region.cpp index 5014976eec4..e95b512dea1 100644 --- a/vpr/src/base/partition_region.cpp +++ b/vpr/src/base/partition_region.cpp @@ -106,7 +106,7 @@ const PartitionRegion& get_device_partition_region() { VTR_ASSERT_SAFE(device_pr.get_regions().size() == 1); const auto [xmin, ymin, xmax, ymax] = device_pr.get_regions()[0].get_rect().coordinates(); - VTR_ASSERT_SAFE(xmin == 0 && ymin == 0 && xmax == width -1 && ymax == height - 1); + VTR_ASSERT_SAFE(xmin == 0 && ymin == 0 && xmax == width - 1 && ymax == height - 1); const auto [layer_low, layer_high] = device_pr.get_regions()[0].get_layer_range(); VTR_ASSERT_SAFE(layer_low == 0 && layer_high == n_layers - 1); diff --git a/vpr/src/base/partition_region.h b/vpr/src/base/partition_region.h index 9e46a1a849b..2e9949fceea 100644 --- a/vpr/src/base/partition_region.h +++ b/vpr/src/base/partition_region.h @@ -108,5 +108,4 @@ struct hash { }; } // namespace std - #endif /* PARTITION_REGIONS_H */ diff --git a/vpr/src/base/read_options.cpp b/vpr/src/base/read_options.cpp index 433e0b8f641..77f9c5dab47 100644 --- a/vpr/src/base/read_options.cpp +++ b/vpr/src/base/read_options.cpp @@ -2194,7 +2194,6 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio .default_value({"100"}) .show_in(argparse::ShowIn::HELP_ONLY); - place_grp.add_argument(args.place_high_fanout_net, "--place_high_fanout_net") .help( "Sets the assumed high fanout net during placement. " diff --git a/vpr/src/base/read_place.cpp b/vpr/src/base/read_place.cpp index 60f99a68f09..bc751c5ab29 100644 --- a/vpr/src/base/read_place.cpp +++ b/vpr/src/base/read_place.cpp @@ -97,7 +97,7 @@ static void read_place_header(std::ifstream& placement_file, std::streampos file_pos = placement_file.tellg(); while (std::getline(placement_file, line) && (!seen_netlist_id || !seen_grid_dimensions)) { //Parse line-by-line - ++lineno; + ++lineno; std::vector tokens = vtr::split(line); @@ -107,9 +107,7 @@ static void read_place_header(std::ifstream& placement_file, } else if (tokens[0][0] == '#') { continue; //Skip commented lines - } else if (tokens.size() == 4 && - tokens[0] == "Netlist_File:" && - tokens[2] == "Netlist_ID:") { + } else if (tokens.size() == 4 && tokens[0] == "Netlist_File:" && tokens[2] == "Netlist_ID:") { //Check that the netlist used to generate this placement matches the one loaded // //NOTE: this is an optional check which causes no errors if this line is missing. diff --git a/vpr/src/base/region.cpp b/vpr/src/base/region.cpp index 7cc6280626b..ff4040e8ff7 100644 --- a/vpr/src/base/region.cpp +++ b/vpr/src/base/region.cpp @@ -44,8 +44,7 @@ void Region::set_sub_tile(int sub_tile) { bool Region::empty() const { const auto [layer_low, layer_high] = layer_range_; - return (rect_.xmax() < rect_.xmin() || rect_.ymax() < rect_.ymin() || - layer_high < layer_low); + return (rect_.xmax() < rect_.xmin() || rect_.ymax() < rect_.ymin() || layer_high < layer_low); } bool Region::is_loc_in_reg(t_pl_loc loc) const { @@ -83,7 +82,7 @@ Region intersection(const Region& r1, const Region& r2) { auto [r2_layer_low, r2_layer_high] = r2.get_layer_range(); auto [intersect_layer_begin, intersect_layer_end] = std::make_pair(std::max(r1_layer_low, r2_layer_low), - std::min(r1_layer_high, r2_layer_high)); + std::min(r1_layer_high, r2_layer_high)); // check that the give layer range start from a lower layer and end at a higher or the same layer // negative layer means that the given Region object is an empty region diff --git a/vpr/src/base/region.h b/vpr/src/base/region.h index 18a179af19a..08959f1bdc6 100644 --- a/vpr/src/base/region.h +++ b/vpr/src/base/region.h @@ -77,9 +77,7 @@ class Region { bool is_loc_in_reg(t_pl_loc loc) const; bool operator==(const Region& reg) const { - return (reg.rect_ == rect_ && - reg.layer_range_ == layer_range_ && - reg.get_sub_tile() == sub_tile_); + return (reg.rect_ == rect_ && reg.layer_range_ == layer_range_ && reg.get_sub_tile() == sub_tile_); } private: @@ -99,7 +97,7 @@ class Region { */ std::pair layer_range_; - int sub_tile_; ///< users will optionally select a subtile + int sub_tile_; ///< users will optionally select a subtile }; /** diff --git a/vpr/src/base/vpr_context.cpp b/vpr/src/base/vpr_context.cpp index 8bc354fb47f..2b7744a5107 100644 --- a/vpr/src/base/vpr_context.cpp +++ b/vpr/src/base/vpr_context.cpp @@ -32,8 +32,7 @@ void FloorplanningContext::update_floorplanning_context_post_pack() { load_cluster_constraints(); } -void FloorplanningContext::update_floorplanning_context_pre_place( - const PlaceMacros& place_macros) { +void FloorplanningContext::update_floorplanning_context_pre_place(const PlaceMacros& place_macros) { // Go through cluster blocks to calculate the tightest placement // floorplan constraint for each constrained block. propagate_place_constraints(place_macros); @@ -47,14 +46,13 @@ void FloorplanningContext::clean_floorplanning_context_post_place() { // not used outside of placement. vtr::release_memory(cluster_constraints); - // The compressed cluster constraints are loaded in alloc_and_laod_compressed + // The compressed cluster constraints are loaded in alloc_and_load_compressed // cluster_constraints and are not used outside of placement. vtr::release_memory(compressed_cluster_constraints); } -void PlacementContext::init_placement_context( - const t_placer_opts& placer_opts, - const std::vector& directs) { +void PlacementContext::init_placement_context(const t_placer_opts& placer_opts, + const std::vector& directs) { const AtomContext& atom_ctx = g_vpr_ctx.atom(); const ClusteringContext& cluster_ctx = g_vpr_ctx.clustering(); const DeviceContext& device_ctx = g_vpr_ctx.device(); @@ -100,4 +98,3 @@ void PlacementContext::clean_placement_context_post_place() { // The compressed block grids are currently only used during placement. vtr::release_memory(compressed_block_grids); } - diff --git a/vpr/src/base/vpr_context.h b/vpr/src/base/vpr_context.h index 699f64230f1..e4238a63bf7 100644 --- a/vpr/src/base/vpr_context.h +++ b/vpr/src/base/vpr_context.h @@ -77,8 +77,8 @@ struct AtomContext : public Context { /******************************************************************** * Atom Netlist ********************************************************************/ -private: - /// @brief Atom netlist + private: + /// @brief Atom netlist AtomNetlist nlist_; /// @brief Mappings to/from the Atom Netlist to physically described .blif models AtomLookup lookup_; @@ -86,33 +86,31 @@ struct AtomContext : public Context { /// algorithm) before packing and the cluster-level placement. FlatPlacementInfo flat_placement_info_; -public: - + public: /** * @brief Immutable reference to the AtomNetlist */ - inline const AtomNetlist& netlist() const {return nlist_;} + inline const AtomNetlist& netlist() const { return nlist_; } /** * @brief Mutable reference to the AtomNetlist */ - inline AtomNetlist& mutable_netlist() {return nlist_;} + inline AtomNetlist& mutable_netlist() { return nlist_; } /** * @brief Immutable reference to the AtomLookup */ - inline const AtomLookup& lookup() const {return lookup_;} + inline const AtomLookup& lookup() const { return lookup_; } /** * @brief Mutable reference to the AtomLookup */ - inline AtomLookup& mutable_lookup() {return lookup_;} + inline AtomLookup& mutable_lookup() { return lookup_; } /** * @brief Immutable reference to the FlatPlacementInfo */ - inline const FlatPlacementInfo& flat_placement_info() const {return flat_placement_info_;} + inline const FlatPlacementInfo& flat_placement_info() const { return flat_placement_info_; } /** * @brief Mutable reference to the FlatPlacementInfo */ - inline FlatPlacementInfo& mutable_flat_placement_info() {return flat_placement_info_;} - + inline FlatPlacementInfo& mutable_flat_placement_info() { return flat_placement_info_; } }; /** @@ -369,7 +367,6 @@ struct PlacementContext : public Context { BlkLocRegistry blk_loc_registry_; public: - /** * @brief Initialize the variables stored within the placement context. This * must be called before performing placement, but must be called @@ -394,14 +391,38 @@ struct PlacementContext : public Context { */ void clean_placement_context_post_place(); - const vtr::vector_map& block_locs() const { VTR_ASSERT_SAFE(loc_vars_are_accessible_); return blk_loc_registry_.block_locs(); } - vtr::vector_map& mutable_block_locs() { VTR_ASSERT_SAFE(loc_vars_are_accessible_); return blk_loc_registry_.mutable_block_locs(); } - const GridBlock& grid_blocks() const { VTR_ASSERT_SAFE(loc_vars_are_accessible_); return blk_loc_registry_.grid_blocks(); } - GridBlock& mutable_grid_blocks() { VTR_ASSERT_SAFE(loc_vars_are_accessible_); return blk_loc_registry_.mutable_grid_blocks(); } - vtr::vector_map& mutable_physical_pins() { VTR_ASSERT_SAFE(loc_vars_are_accessible_); return blk_loc_registry_.mutable_physical_pins(); } - const vtr::vector_map& physical_pins() const { VTR_ASSERT_SAFE(loc_vars_are_accessible_); return blk_loc_registry_.physical_pins(); } - BlkLocRegistry& mutable_blk_loc_registry() { VTR_ASSERT_SAFE(loc_vars_are_accessible_); return blk_loc_registry_; } - const BlkLocRegistry& blk_loc_registry() const { VTR_ASSERT_SAFE(loc_vars_are_accessible_); return blk_loc_registry_; } + const vtr::vector_map& block_locs() const { + VTR_ASSERT_SAFE(loc_vars_are_accessible_); + return blk_loc_registry_.block_locs(); + } + vtr::vector_map& mutable_block_locs() { + VTR_ASSERT_SAFE(loc_vars_are_accessible_); + return blk_loc_registry_.mutable_block_locs(); + } + const GridBlock& grid_blocks() const { + VTR_ASSERT_SAFE(loc_vars_are_accessible_); + return blk_loc_registry_.grid_blocks(); + } + GridBlock& mutable_grid_blocks() { + VTR_ASSERT_SAFE(loc_vars_are_accessible_); + return blk_loc_registry_.mutable_grid_blocks(); + } + vtr::vector_map& mutable_physical_pins() { + VTR_ASSERT_SAFE(loc_vars_are_accessible_); + return blk_loc_registry_.mutable_physical_pins(); + } + const vtr::vector_map& physical_pins() const { + VTR_ASSERT_SAFE(loc_vars_are_accessible_); + return blk_loc_registry_.physical_pins(); + } + BlkLocRegistry& mutable_blk_loc_registry() { + VTR_ASSERT_SAFE(loc_vars_are_accessible_); + return blk_loc_registry_; + } + const BlkLocRegistry& blk_loc_registry() const { + VTR_ASSERT_SAFE(loc_vars_are_accessible_); + return blk_loc_registry_; + } /** * @brief Makes blk_loc_registry_ inaccessible through the getter methods. @@ -410,7 +431,10 @@ struct PlacementContext : public Context { * guarantee that the placement stage code does not access block location variables * stored in the global state. */ - void lock_loc_vars() { VTR_ASSERT_SAFE(loc_vars_are_accessible_); loc_vars_are_accessible_ = false; } + void lock_loc_vars() { + VTR_ASSERT_SAFE(loc_vars_are_accessible_); + loc_vars_are_accessible_ = false; + } /** * @brief Makes blk_loc_registry_ accessible through the getter methods. @@ -418,7 +442,10 @@ struct PlacementContext : public Context { * This method should be called at the end of the placement stage to * make the block location information accessible for subsequent stages. */ - void unlock_loc_vars() { VTR_ASSERT_SAFE(!loc_vars_are_accessible_); loc_vars_are_accessible_ = true; } + void unlock_loc_vars() { + VTR_ASSERT_SAFE(!loc_vars_are_accessible_); + loc_vars_are_accessible_ = true; + } /** * @brief Collection of all the placement macros in the netlist. A placement @@ -818,4 +845,3 @@ class VprContext : public Context { }; #endif - diff --git a/vpr/src/draw/draw_floorplanning.cpp b/vpr/src/draw/draw_floorplanning.cpp index 5c07317dbaf..088cc191a10 100644 --- a/vpr/src/draw/draw_floorplanning.cpp +++ b/vpr/src/draw/draw_floorplanning.cpp @@ -18,13 +18,16 @@ //To process key presses we need the X11 keysym definitions, //which are unavailable when building with MINGW -# if defined(X11) && !defined(__MINGW32__) -# include -# endif +#if defined(X11) && !defined(__MINGW32__) +#include +#endif -static void draw_internal_pb(const ClusterBlockId clb_index, t_pb* current_pb, - const t_pb* pb_to_draw, const ezgl::rectangle& parent_bbox, - const t_logical_block_type_ptr type, ezgl::color color, +static void draw_internal_pb(const ClusterBlockId clb_index, + t_pb* current_pb, + const t_pb* pb_to_draw, + const ezgl::rectangle& parent_bbox, + const t_logical_block_type_ptr type, + ezgl::color color, ezgl::renderer* g); const std::vector kelly_max_contrast_colors_no_black = { @@ -52,8 +55,8 @@ const std::vector kelly_max_contrast_colors_no_black = { ezgl::color(43, 61, 38) //olive green }; -# define DEFAULT_HIGHLIGHT_ALPHA 30 -# define CLICKED_HIGHLIGHT_ALPHA 100 +#define DEFAULT_HIGHLIGHT_ALPHA 30 +#define CLICKED_HIGHLIGHT_ALPHA 100 //Keeps track of how translucent each partition should be drawn on screen. static std::vector highlight_alpha; @@ -167,7 +170,8 @@ static void draw_internal_pb(const ClusterBlockId clb_index, const t_pb* pb_to_draw, const ezgl::rectangle& parent_bbox, const t_logical_block_type_ptr type, - ezgl::color color, ezgl::renderer* g) { + ezgl::color color, + ezgl::renderer* g) { t_draw_coords* draw_coords = get_draw_coords_vars(); t_draw_state* draw_state = get_draw_state_vars(); diff --git a/vpr/src/noc/negative_first_routing.cpp b/vpr/src/noc/negative_first_routing.cpp index e45df009122..30098587dff 100644 --- a/vpr/src/noc/negative_first_routing.cpp +++ b/vpr/src/noc/negative_first_routing.cpp @@ -74,9 +74,9 @@ const std::vector& NegativeFirstRouting::get_legal_ bool NegativeFirstRouting::is_turn_legal(const std::array, 3>& noc_routers, const NocStorage& noc_model) const { - const auto[x1, y1, z1] = noc_routers[0].get().get_router_physical_location(); - const auto[x2, y2, z2] = noc_routers[1].get().get_router_physical_location(); - const auto[x3, y3, z3] = noc_routers[2].get().get_router_physical_location(); + const auto [x1, y1, z1] = noc_routers[0].get().get_router_physical_location(); + const auto [x2, y2, z2] = noc_routers[1].get().get_router_physical_location(); + const auto [x3, y3, z3] = noc_routers[2].get().get_router_physical_location(); // check if the given routers can be traversed one after another VTR_ASSERT(vtr::exactly_k_conditions(2, x1 == x2, y1 == y2, z1 == z2)); @@ -89,8 +89,7 @@ bool NegativeFirstRouting::is_turn_legal(const std::array x1 && y3 < y2) || (y2 > y1 && x3 < x2) || (z2 > z1 && x3 < x2) || - (x2 > x1 && z3 < z2) || (z2 > z1 && y3 < y2) || (y2 > y1 && z3 < z2)) { + if ((x2 > x1 && y3 < y2) || (y2 > y1 && x3 < x2) || (z2 > z1 && x3 < x2) || (x2 > x1 && z3 < z2) || (z2 > z1 && y3 < y2) || (y2 > y1 && z3 < z2)) { return false; } } else { diff --git a/vpr/src/noc/noc_storage.cpp b/vpr/src/noc/noc_storage.cpp index aa21fa5e8d3..fec0ebec200 100644 --- a/vpr/src/noc/noc_storage.cpp +++ b/vpr/src/noc/noc_storage.cpp @@ -3,7 +3,6 @@ #include "vtr_assert.h" #include "vpr_error.h" - #include NocStorage::NocStorage() { @@ -106,7 +105,9 @@ bool NocStorage::is_noc_3d() const { // setters for the NoC void NocStorage::add_router(int id, - int grid_position_x, int grid_position_y, int layer_position, + int grid_position_x, + int grid_position_y, + int layer_position, double latency) { VTR_ASSERT_MSG(!built_noc, "NoC already built, cannot modify further."); diff --git a/vpr/src/noc/noc_storage.h b/vpr/src/noc/noc_storage.h index 89dcf87bbac..deabfd27853 100644 --- a/vpr/src/noc/noc_storage.h +++ b/vpr/src/noc/noc_storage.h @@ -317,10 +317,9 @@ class NocStorage { * requested NoC links * @return A const */ - template class Container, typename... Ts> + template class Container, typename... Ts> const std::vector>& get_noc_links(const Container& noc_link_ids) const; - /** * @brief Given source and sink router identifiers, this function * finds a link connecting these routers and returns its identifier. @@ -385,7 +384,9 @@ class NocStorage { * when it is routed through this router. */ void add_router(int id, - int grid_position_x, int grid_position_y, int layer_position, + int grid_position_x, + int grid_position_y, + int layer_position, double latency); /** @@ -560,8 +561,7 @@ class NocStorage { void echo_noc(char* file_name) const; }; - -template class Container, typename... Ts> +template class Container, typename... Ts> const std::vector>& NocStorage::get_noc_links(const Container& noc_link_ids) const { returnable_noc_link_const_refs_.clear(); @@ -574,4 +574,3 @@ const std::vector>& NocStorage::get_noc_li } #endif - diff --git a/vpr/src/noc/north_last_routing.cpp b/vpr/src/noc/north_last_routing.cpp index fd3c1183201..82b1bd4b7f5 100644 --- a/vpr/src/noc/north_last_routing.cpp +++ b/vpr/src/noc/north_last_routing.cpp @@ -72,7 +72,6 @@ bool NorthLastRouting::is_turn_legal(const std::array z1 && x3 < x2) || (z2 > z1 && x3 > x2) || (z2 > z1 && y3 < y2) || - (y2 > y1 && z3 < z2) || (y2 > y1 && x3 < x2) || (y2 > y1 && x3 > x2)) { + if ((z2 > z1 && x3 < x2) || (z2 > z1 && x3 > x2) || (z2 > z1 && y3 < y2) || (y2 > y1 && z3 < z2) || (y2 > y1 && x3 < x2) || (y2 > y1 && x3 > x2)) { return false; } } else { @@ -90,6 +88,5 @@ bool NorthLastRouting::is_turn_legal(const std::array& OddEvenRouting::get_legal_direct if (noc_model.is_noc_3d()) { determine_legal_directions_3d(compressed_src_loc, compressed_curr_loc, compressed_dst_loc, prev_dir); - } else { // 2D NoC + } else { // 2D NoC determine_legal_directions_2d(compressed_src_loc, compressed_curr_loc, compressed_dst_loc, prev_dir); } @@ -120,7 +120,6 @@ bool OddEvenRouting::is_turn_legal(const std::array z1 && y3 < y2) || (z2 < z1 && y3 < y2)) { @@ -131,7 +130,7 @@ bool OddEvenRouting::is_turn_legal(const std::array 0) { diff --git a/vpr/src/noc/sat_routing.cpp b/vpr/src/noc/sat_routing.cpp index 354620c6cfa..b9e6799d739 100644 --- a/vpr/src/noc/sat_routing.cpp +++ b/vpr/src/noc/sat_routing.cpp @@ -1,6 +1,5 @@ #ifdef ENABLE_NOC_SAT_ROUTING - #include "sat_routing.h" #include "turn_model_routing.h" @@ -22,7 +21,6 @@ namespace orsat = operations_research::sat; */ typedef std::unordered_map, orsat::BoolVar> t_flow_link_var_map; - /** * @brief Creates a boolean variable for each (traffic flow, link) pair. * It also create integer variables for latency-constrained traffic flows. @@ -38,7 +36,7 @@ typedef std::unordered_map, orsat::BoolVa */ static void create_flow_link_vars(orsat::CpModelBuilder& cp_model, t_flow_link_var_map& flow_link_vars, - std::map& latency_overrun_vars); + std::map& latency_overrun_vars); /** * @brief Translates a latency constraint for a traffic flow to the maximum number @@ -84,7 +82,7 @@ static std::vector get_flow_link_vars(const t_flow_link_var_map& */ static void constrain_latency_overrun_vars(orsat::CpModelBuilder& cp_model, t_flow_link_var_map& flow_link_vars, - std::map& latency_overrun_vars); + std::map& latency_overrun_vars); /** * @brief Forbids specific turns that traffic flows can take. @@ -118,7 +116,7 @@ static void forbid_illegal_turns(t_flow_link_var_map& flow_link_vars, * @param bandwidth_resolution Specifies the resolution by which bandwidth * values are quantized. */ -static void create_congested_link_vars(vtr::vector& congested_link_vars, +static void create_congested_link_vars(vtr::vector& congested_link_vars, t_flow_link_var_map& flow_link_vars, orsat::CpModelBuilder& cp_model, int bandwidth_resolution); @@ -172,8 +170,8 @@ static void add_continuity_constraints(t_flow_link_var_map& flow_link_vars, */ static orsat::LinearExpr create_objective(orsat::CpModelBuilder& cp_model, t_flow_link_var_map& flow_link_vars, - std::map& latency_overrun_vars, - vtr::vector& congested_link_vars, + std::map& latency_overrun_vars, + vtr::vector& congested_link_vars, int bandwidth_resolution, int latency_overrun_weight, int congestion_weight, @@ -211,7 +209,6 @@ static vtr::vector> convert_vars_to_rou */ static std::vector sort_noc_links_in_chain_order(const std::vector& links); - static std::vector get_flow_link_vars(const t_flow_link_var_map& map, const std::vector& traffic_flow_ids, const std::vector& noc_link_ids) { @@ -233,7 +230,7 @@ static void forbid_illegal_turns(t_flow_link_var_map& flow_link_vars, const auto& noc_ctx = g_vpr_ctx.noc(); const auto& traffic_flow_storage = noc_ctx.noc_traffic_flows_storage; - auto noc_routing_alg = dynamic_cast (noc_ctx.noc_flows_router.get()); + auto noc_routing_alg = dynamic_cast(noc_ctx.noc_flows_router.get()); // ensure that the routing algorithm is a turn model algorithm VTR_ASSERT(noc_routing_alg != nullptr); @@ -256,7 +253,7 @@ static vtr::vector quantize_traffic_flow_bandwidths(int b //TODO: support heterogeneous bandwidth const auto& noc_links = noc_ctx.noc_model.get_noc_links(); const double link_bandwidth = noc_links.front().get_bandwidth(); - auto it = std::adjacent_find(noc_links.begin(), noc_links.end(), [](const NocLink& a, const NocLink& b){ + auto it = std::adjacent_find(noc_links.begin(), noc_links.end(), [](const NocLink& a, const NocLink& b) { return a.get_bandwidth() != b.get_bandwidth(); }); @@ -281,10 +278,10 @@ static vtr::vector quantize_traffic_flow_bandwidths(int b rescaled_traffic_flow_bandwidths[traffic_flow_id] = rescaled_bandwidth; } - return rescaled_traffic_flow_bandwidths; + return rescaled_traffic_flow_bandwidths; } -static void create_congested_link_vars(vtr::vector& congested_link_vars, +static void create_congested_link_vars(vtr::vector& congested_link_vars, t_flow_link_var_map& flow_link_vars, orsat::CpModelBuilder& cp_model, int bandwidth_resolution) { @@ -351,7 +348,6 @@ static void add_continuity_constraints(t_flow_link_var_map& flow_link_vars, continue; } - // for each intermediate router, at most one incoming link can be activated to route this traffic flow const auto& incoming_links = noc_ctx.noc_model.get_noc_router_incoming_links(noc_router_id); auto incoming_vars = get_flow_link_vars(flow_link_vars, {traffic_flow_id}, incoming_links); @@ -386,8 +382,8 @@ static std::vector sort_noc_links_in_chain_order(const std::vector src_map; - std::unordered_map is_dst; + std::unordered_map src_map; + std::unordered_map is_dst; for (const auto l : links) { NocRouterId src_router_id = noc_model.get_single_noc_link(l).get_source_router(); NocRouterId dst_router_id = noc_model.get_single_noc_link(l).get_sink_router(); @@ -426,8 +422,7 @@ static vtr::vector> convert_vars_to_rou const auto& noc_ctx = g_vpr_ctx.noc(); const auto& traffic_flow_storage = noc_ctx.noc_traffic_flows_storage; - VTR_ASSERT(response.status() == orsat::CpSolverStatus::FEASIBLE || - response.status() == orsat::CpSolverStatus::OPTIMAL); + VTR_ASSERT(response.status() == orsat::CpSolverStatus::FEASIBLE || response.status() == orsat::CpSolverStatus::OPTIMAL); vtr::vector> routes; routes.resize(traffic_flow_storage.get_number_of_traffic_flows()); @@ -449,7 +444,7 @@ static vtr::vector> convert_vars_to_rou static void create_flow_link_vars(orsat::CpModelBuilder& cp_model, t_flow_link_var_map& flow_link_vars, - std::map& latency_overrun_vars) { + std::map& latency_overrun_vars) { const auto& noc_ctx = g_vpr_ctx.noc(); const auto& noc_model = noc_ctx.noc_model; const auto& traffic_flow_storage = noc_ctx.noc_traffic_flows_storage; @@ -467,12 +462,14 @@ static void create_flow_link_vars(orsat::CpModelBuilder& cp_model, size_t max_n_cols = std::max_element(compressed_noc_grid.compressed_to_grid_x.begin(), compressed_noc_grid.compressed_to_grid_x.end(), [](const std::vector& a, const std::vector& b) { return a.size() < b.size(); - })->size(); + }) + ->size(); size_t max_n_rows = std::max_element(compressed_noc_grid.compressed_to_grid_y.begin(), compressed_noc_grid.compressed_to_grid_y.end(), [](const std::vector& a, const std::vector& b) { return a.size() < b.size(); - })->size(); + }) + ->size(); /* For specifying the domain, assume that the longest traffic flow route starts from * one corner and terminates at the opposite corner. Assuming minimal routing, such a @@ -523,7 +520,7 @@ static int comp_max_number_of_traversed_links(NocTrafficFlowId traffic_flow_id) } auto link_it = std::find_if(noc_links.begin(), noc_links.end(), [noc_link_latency](const NocLink& l) { - return (noc_link_latency != l.get_latency()); + return (noc_link_latency != l.get_latency()); }); if (link_it != noc_links.end()) { @@ -544,7 +541,7 @@ static int comp_max_number_of_traversed_links(NocTrafficFlowId traffic_flow_id) static void constrain_latency_overrun_vars(orsat::CpModelBuilder& cp_model, t_flow_link_var_map& flow_link_vars, - std::map& latency_overrun_vars) { + std::map& latency_overrun_vars) { const auto& noc_ctx = g_vpr_ctx.noc(); const auto& noc_model = noc_ctx.noc_model; @@ -569,8 +566,8 @@ static void constrain_latency_overrun_vars(orsat::CpModelBuilder& cp_model, static orsat::LinearExpr create_objective(orsat::CpModelBuilder& cp_model, t_flow_link_var_map& flow_link_vars, - std::map& latency_overrun_vars, - vtr::vector& congested_link_vars, + std::map& latency_overrun_vars, + vtr::vector& congested_link_vars, int bandwidth_resolution, int latency_overrun_weight, int congestion_weight, @@ -603,7 +600,6 @@ static orsat::LinearExpr create_objective(orsat::CpModelBuilder& cp_model, agg_bw_expr = 0; } - orsat::LinearExpr congested_link_sum = orsat::LinearExpr::Sum(congested_link_vars); congested_link_sum *= congestion_weight; @@ -611,7 +607,6 @@ static orsat::LinearExpr create_objective(orsat::CpModelBuilder& cp_model, return objective; } - vtr::vector> noc_sat_route(bool minimize_aggregate_bandwidth, const t_noc_opts& noc_opts, int seed) { @@ -666,8 +661,7 @@ vtr::vector> noc_sat_route(bool minimiz orsat::CpSolverResponse response = orsat::SolveCpModel(cp_model.Build(), &model); - if (response.status() == orsat::CpSolverStatus::FEASIBLE || - response.status() == orsat::CpSolverStatus::OPTIMAL) { + if (response.status() == orsat::CpSolverStatus::FEASIBLE || response.status() == orsat::CpSolverStatus::OPTIMAL) { auto routes = convert_vars_to_routes(flow_link_vars, response); return routes; } diff --git a/vpr/src/noc/turn_model_routing.h b/vpr/src/noc/turn_model_routing.h index ce061a56eed..7263c3d813d 100644 --- a/vpr/src/noc/turn_model_routing.h +++ b/vpr/src/noc/turn_model_routing.h @@ -122,14 +122,14 @@ class TurnModelRouting : public NocRouting { * choose to travel. */ enum class Direction { - WEST, /*!< Moving towards the negative X-axis*/ - EAST, /*!< Moving towards the positive X-axis*/ - NORTH, /*!< Moving towards the positive Y-axis*/ - SOUTH, /*!< Moving towards the negative Y-axis*/ - UP, /*!< Moving towards the positive Z-axis*/ - DOWN, /*!< Moving towards the negative Z-axis*/ + WEST, /*!< Moving towards the negative X-axis*/ + EAST, /*!< Moving towards the positive X-axis*/ + NORTH, /*!< Moving towards the positive Y-axis*/ + SOUTH, /*!< Moving towards the negative Y-axis*/ + UP, /*!< Moving towards the positive Z-axis*/ + DOWN, /*!< Moving towards the negative Z-axis*/ N_DIRECTIONS, - INVALID /*!< Invalid direction*/ + INVALID /*!< Invalid direction*/ }; /** @@ -209,7 +209,6 @@ class TurnModelRouting : public NocRouting { std::unordered_set& visited_routers, const NocStorage& noc_model); - /** * @brief Computes MurmurHash3 for an array of 32-bit words initialized * with seed. As discussed in the comment at the top of this file, @@ -274,7 +273,6 @@ class TurnModelRouting : public NocRouting { private: std::vector inputs_to_murmur3_hasher{4}; - }; #endif //VTR_TURN_MODEL_ROUTING_H diff --git a/vpr/src/pack/constraints_report.cpp b/vpr/src/pack/constraints_report.cpp index 619169cc0ba..2c25cb5f8af 100644 --- a/vpr/src/pack/constraints_report.cpp +++ b/vpr/src/pack/constraints_report.cpp @@ -2,10 +2,9 @@ #include "cluster_legalizer.h" #include "grid_tile_lookup.h" -bool floorplan_constraints_regions_overfull( - std::vector& overfull_partition_regions, - const ClusterLegalizer& cluster_legalizer, - const std::vector& logical_block_types) { +bool floorplan_constraints_regions_overfull(std::vector& overfull_partition_regions, + const ClusterLegalizer& cluster_legalizer, + const std::vector& logical_block_types) { GridTileLookup grid_tiles; // keep record of how many blocks of each type are assigned to each PartitionRegion @@ -41,9 +40,10 @@ bool floorplan_constraints_regions_overfull( if (num_assigned_blocks > num_tiles) { floorplan_regions_overfull = true; overfull_partition_regions.push_back(pr); - VTR_LOG("\n\nA partition including the following regions has been assigned %d blocks of type %s, " - "but only has %d tiles of that type\n", - num_assigned_blocks, block_type.name.c_str(), num_tiles); + VTR_LOG( + "\n\nA partition including the following regions has been assigned %d blocks of type %s, " + "but only has %d tiles of that type\n", + num_assigned_blocks, block_type.name.c_str(), num_tiles); for (const Region& reg : regions) { const vtr::Rect& rect = reg.get_rect(); const auto [layer_low, layer_high] = reg.get_layer_range(); @@ -52,11 +52,9 @@ bool floorplan_constraints_regions_overfull( rect.xmax(), rect.ymax(), layer_high, reg.get_sub_tile()); } - } } } return floorplan_regions_overfull; } - diff --git a/vpr/src/pack/constraints_report.h b/vpr/src/pack/constraints_report.h index db39281d7dd..779f629ba69 100644 --- a/vpr/src/pack/constraints_report.h +++ b/vpr/src/pack/constraints_report.h @@ -30,8 +30,6 @@ struct t_logical_block_type; * * @return True if there is at least one overfull partition. */ -bool floorplan_constraints_regions_overfull( - std::vector &overfull_partition_regions, - const ClusterLegalizer& cluster_legalizer, - const std::vector& logical_block_types); - +bool floorplan_constraints_regions_overfull(std::vector& overfull_partition_regions, + const ClusterLegalizer& cluster_legalizer, + const std::vector& logical_block_types); diff --git a/vpr/src/pack/greedy_candidate_selector.cpp b/vpr/src/pack/greedy_candidate_selector.cpp index 46bada6237d..f5c9235af2b 100644 --- a/vpr/src/pack/greedy_candidate_selector.cpp +++ b/vpr/src/pack/greedy_candidate_selector.cpp @@ -102,10 +102,10 @@ GreedyCandidateSelector::GreedyCandidateSelector( std::stable_sort(molecules_vector.begin(), molecules_vector.end(), [&](PackMoleculeId a_id, PackMoleculeId b_id) { - const t_pack_molecule& a = prepacker.get_molecule(a_id); - const t_pack_molecule& b = prepacker.get_molecule(b_id); + const t_pack_molecule& a = prepacker.get_molecule(a_id); + const t_pack_molecule& b = prepacker.get_molecule(b_id); - return a.base_gain > b.base_gain; + return a.base_gain > b.base_gain; }); // Push back the each molecule into the unrelated clustering data vector diff --git a/vpr/src/pack/greedy_candidate_selector.h b/vpr/src/pack/greedy_candidate_selector.h index 9b70ec803ea..298497b0dc7 100644 --- a/vpr/src/pack/greedy_candidate_selector.h +++ b/vpr/src/pack/greedy_candidate_selector.h @@ -140,7 +140,7 @@ struct ClusterGainStats { * candidate_selector.update_candidate_selector_finalize_cluster(cluster_gain_stats, ...); */ class GreedyCandidateSelector { -private: + private: /// @brief How many unrelated candidates can be proposed and not clustered /// in a row. So if an unrelated candidate is successfully clustered, /// the counter is reset. @@ -161,7 +161,7 @@ class GreedyCandidateSelector { /// atoms in the group, or a randomly selected number of them. static constexpr int attraction_group_num_atoms_threshold_ = 500; -public: + public: ~GreedyCandidateSelector(); /** @@ -245,10 +245,10 @@ class GreedyCandidateSelector { * other. */ ClusterGainStats create_cluster_gain_stats( - PackMoleculeId cluster_seed_mol_id, - LegalizationClusterId cluster_id, - const ClusterLegalizer& cluster_legalizer, - AttractionInfo& attraction_groups); + PackMoleculeId cluster_seed_mol_id, + LegalizationClusterId cluster_id, + const ClusterLegalizer& cluster_legalizer, + AttractionInfo& attraction_groups); /** * @brief Update the cluster gain stats given that the successful_mol was @@ -270,11 +270,11 @@ class GreedyCandidateSelector { * other. */ void update_cluster_gain_stats_candidate_success( - ClusterGainStats& cluster_gain_stats, - PackMoleculeId successful_mol_id, - LegalizationClusterId cluster_id, - const ClusterLegalizer& cluster_legalizer, - AttractionInfo& attraction_groups); + ClusterGainStats& cluster_gain_stats, + PackMoleculeId successful_mol_id, + LegalizationClusterId cluster_id, + const ClusterLegalizer& cluster_legalizer, + AttractionInfo& attraction_groups); /** * @brief Update the cluster gain stats given that the failed_mol was not @@ -289,8 +289,8 @@ class GreedyCandidateSelector { * The molecule that failed to pack into the cluster. */ void update_cluster_gain_stats_candidate_failed( - ClusterGainStats& cluster_gain_stats, - PackMoleculeId failed_mol_id); + ClusterGainStats& cluster_gain_stats, + PackMoleculeId failed_mol_id); /** * @brief Given the cluster_gain_stats, select the next candidate molecule @@ -310,10 +310,10 @@ class GreedyCandidateSelector { * other. */ PackMoleculeId get_next_candidate_for_cluster( - ClusterGainStats& cluster_gain_stats, - LegalizationClusterId cluster_id, - const ClusterLegalizer& cluster_legalizer, - AttractionInfo& attraction_groups); + ClusterGainStats& cluster_gain_stats, + LegalizationClusterId cluster_id, + const ClusterLegalizer& cluster_legalizer, + AttractionInfo& attraction_groups); /** * @brief Finalize the creation of a cluster. @@ -331,10 +331,10 @@ class GreedyCandidateSelector { * The legalization cluster id of the cluster to finalize. */ void update_candidate_selector_finalize_cluster( - ClusterGainStats& cluster_gain_stats, - LegalizationClusterId cluster_id); + ClusterGainStats& cluster_gain_stats, + LegalizationClusterId cluster_id); -private: + private: // ===================================================================== // // Cluster Gain Stats Updating // ===================================================================== // @@ -344,8 +344,8 @@ class GreedyCandidateSelector { * updated when a block is marked. */ enum class e_gain_update : bool { - GAIN, // Update the gains of affected blocks. - NO_GAIN // Do not update the gains of affected blocks. + GAIN, // Update the gains of affected blocks. + NO_GAIN // Do not update the gains of affected blocks. }; /** @@ -353,8 +353,8 @@ class GreedyCandidateSelector { * updating the connection gain values. */ enum class e_net_relation_to_clustered_block : bool { - INPUT, // This is an input net. - OUTPUT // This is an output net. + INPUT, // This is an input net. + OUTPUT // This is an output net. }; /** @@ -404,19 +404,19 @@ class GreedyCandidateSelector { * placement to the list of feasible blocks. */ void add_cluster_molecule_candidates_by_flat_placement( - ClusterGainStats& cluster_gain_stats, - LegalizationClusterId legalization_cluster_id, - const ClusterLegalizer& cluster_legalizer, - AttractionInfo& attraction_groups); + ClusterGainStats& cluster_gain_stats, + LegalizationClusterId legalization_cluster_id, + const ClusterLegalizer& cluster_legalizer, + AttractionInfo& attraction_groups); /* * @brief Add molecules with strong connectedness to the current cluster to * the list of feasible blocks. */ void add_cluster_molecule_candidates_by_connectivity_and_timing( - ClusterGainStats& cluster_gain_stats, - LegalizationClusterId legalization_cluster_id, - const ClusterLegalizer& cluster_legalizer, - AttractionInfo& attraction_groups); + ClusterGainStats& cluster_gain_stats, + LegalizationClusterId legalization_cluster_id, + const ClusterLegalizer& cluster_legalizer, + AttractionInfo& attraction_groups); /** * @brief Score unclustered atoms that are two hops away from current @@ -431,29 +431,29 @@ class GreedyCandidateSelector { * This is used when adding molecule candidates by transistive connectivity. */ void load_transitive_fanout_candidates( - ClusterGainStats& cluster_gain_stats, - LegalizationClusterId legalization_cluster_id, - const ClusterLegalizer& cluster_legalizer); + ClusterGainStats& cluster_gain_stats, + LegalizationClusterId legalization_cluster_id, + const ClusterLegalizer& cluster_legalizer); /* * @brief Add molecules based on transitive connections (eg. 2 hops away) * with current cluster. */ void add_cluster_molecule_candidates_by_transitive_connectivity( - ClusterGainStats& cluster_gain_stats, - LegalizationClusterId legalization_cluster_id, - const ClusterLegalizer& cluster_legalizer, - AttractionInfo& attraction_groups); + ClusterGainStats& cluster_gain_stats, + LegalizationClusterId legalization_cluster_id, + const ClusterLegalizer& cluster_legalizer, + AttractionInfo& attraction_groups); /* * @brief Add molecules based on weak connectedness (connected by high * fanout nets) with current cluster. */ void add_cluster_molecule_candidates_by_highfanout_connectivity( - ClusterGainStats& cluster_gain_stats, - LegalizationClusterId legalization_cluster_id, - const ClusterLegalizer& cluster_legalizer, - AttractionInfo& attraction_groups); + ClusterGainStats& cluster_gain_stats, + LegalizationClusterId legalization_cluster_id, + const ClusterLegalizer& cluster_legalizer, + AttractionInfo& attraction_groups); /* * @brief If the current cluster being packed has an attraction group @@ -467,18 +467,18 @@ class GreedyCandidateSelector { * candidates will vary each time you call this function. */ void add_cluster_molecule_candidates_by_attraction_group( - ClusterGainStats& cluster_gain_stats, - LegalizationClusterId legalization_cluster_id, - const ClusterLegalizer& cluster_legalizer, - AttractionInfo& attraction_groups); + ClusterGainStats& cluster_gain_stats, + LegalizationClusterId legalization_cluster_id, + const ClusterLegalizer& cluster_legalizer, + AttractionInfo& attraction_groups); /** * @brief Finds a molecule to propose which is unrelated but may be good to * cluster. */ PackMoleculeId get_unrelated_candidate_for_cluster( - LegalizationClusterId cluster_id, - const ClusterLegalizer& cluster_legalizer); + LegalizationClusterId cluster_id, + const ClusterLegalizer& cluster_legalizer); // ===================================================================== // // Internal Variables @@ -568,4 +568,3 @@ class GreedyCandidateSelector { /// could be used for other purposes in the future. vtr::RngContainer rng_; }; - diff --git a/vpr/src/pack/pb_type_graph.cpp b/vpr/src/pack/pb_type_graph.cpp index 0c6745b85e2..9cd0b668765 100644 --- a/vpr/src/pack/pb_type_graph.cpp +++ b/vpr/src/pack/pb_type_graph.cpp @@ -394,7 +394,6 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node, load_power_structures); } - // update the total number of primitives of that type if (pb_graph_node->is_primitive()) { int total_count = 1; @@ -1946,18 +1945,18 @@ const t_pb_graph_edge* get_edge_between_pins(const t_pb_graph_pin* driver_pin, c /* Date:June 8th, 2024 * Author: Kate Thurmer * Purpose: This subroutine computes the index of a pb graph node at its - level of the pb hierarchy; it is computed by the parent and - passed to each child of each child pb type. When the child is - a primitive, the computed indes is its flat site index. - For example, if there are 10 ALMs, each with 2 FFs and 2 LUTs, - then the ALM at index N, when calling this function for - its FF child at index M, would compute the child's index as: - N*(FFs per ALM) + M - e.g. for FF[1] in ALM[5], this returns - 5*(2 FFS per ALM) + 1 = 11 + * level of the pb hierarchy; it is computed by the parent and + * passed to each child of each child pb type. When the child is + * a primitive, the computed indes is its flat site index. + * For example, if there are 10 ALMs, each with 2 FFs and 2 LUTs, + * then the ALM at index N, when calling this function for + * its FF child at index M, would compute the child's index as: + * N*(FFs per ALM) + M + * e.g. for FF[1] in ALM[5], this returns + * 5*(2 FFS per ALM) + 1 = 11 */ static int compute_flat_index_for_child_node(int num_children_of_type, int parent_flat_index, int child_index) { - return parent_flat_index*num_children_of_type + child_index; + return parent_flat_index * num_children_of_type + child_index; } diff --git a/vpr/src/pack/verify_clustering.cpp b/vpr/src/pack/verify_clustering.cpp index fca8f19d409..a514c505ed4 100644 --- a/vpr/src/pack/verify_clustering.cpp +++ b/vpr/src/pack/verify_clustering.cpp @@ -243,10 +243,10 @@ static unsigned check_clustering_pb_consistency(const ClusteredNetlist& clb_nlis * @return The number of errors in the clustering floorplanning. */ static unsigned check_clustering_floorplanning_consistency( - const ClusteredNetlist& clb_nlist, - const vtr::vector>& clb_atoms, - const vtr::vector& cluster_constraints, - const UserPlaceConstraints& constraints) { + const ClusteredNetlist& clb_nlist, + const vtr::vector>& clb_atoms, + const vtr::vector& cluster_constraints, + const UserPlaceConstraints& constraints) { unsigned num_errors = 0; // Check that each cluster has a constraint. if (cluster_constraints.size() != clb_nlist.blocks().size()) { @@ -441,4 +441,3 @@ unsigned verify_clustering(const VprContext& ctx) { ctx.floorplanning().cluster_constraints, ctx.floorplanning().constraints); } - diff --git a/vpr/src/place/annealer.h b/vpr/src/place/annealer.h index cce6fb23276..66abceea1e3 100644 --- a/vpr/src/place/annealer.h +++ b/vpr/src/place/annealer.h @@ -233,7 +233,6 @@ class PlacementAnnealer { const MoveAbortionLogger& get_move_abortion_logger() const; private: - /** * @brief Pick some block and moves it to another spot. * @@ -331,8 +330,7 @@ class PlacementAnnealer { void LOG_MOVE_STATS_HEADER(); void LOG_MOVE_STATS_PROPOSED(); - void LOG_MOVE_STATS_OUTCOME(double delta_cost, double delta_bb_cost, double delta_td_cost, - const char* outcome, const char* reason); + void LOG_MOVE_STATS_OUTCOME(double delta_cost, double delta_bb_cost, double delta_td_cost, const char* outcome, const char* reason); /** * @brief Defines the RL agent's reward function factor constant. This factor controls the weight of bb cost diff --git a/vpr/src/place/move_generators/median_move_generator.h b/vpr/src/place/move_generators/median_move_generator.h index 37801e1303b..4dc037350f9 100644 --- a/vpr/src/place/move_generators/median_move_generator.h +++ b/vpr/src/place/move_generators/median_move_generator.h @@ -45,11 +45,11 @@ class MedianMoveGenerator : public MoveGenerator { * can be used. Essentially, I am assuming the pins always lie on the outside of the bounding box. * The x and y coordinates are the pin's x and y coordinates. IO blocks are considered to be * one cell in for simplicity. */ - bool get_bb_incrementally(ClusterNetId net_id, t_bb& bb_coord_new, + bool get_bb_incrementally(ClusterNetId net_id, + t_bb& bb_coord_new, t_physical_tile_loc old_pin_loc, t_physical_tile_loc new_pin_loc); - /** * @brief Finds the bounding box of a net and stores its coordinates in the bb_coord_new data structure. * diff --git a/vpr/src/place/move_generators/move_generator.h b/vpr/src/place/move_generators/move_generator.h index fc163492f36..2fc4cb8931d 100644 --- a/vpr/src/place/move_generators/move_generator.h +++ b/vpr/src/place/move_generators/move_generator.h @@ -71,11 +71,11 @@ struct MoveTypeStat { * @brief enum represents the different reward functions */ enum class e_reward_function { - BASIC, ///@ directly uses the change of the annealing cost function - NON_PENALIZING_BASIC, ///@ same as basic reward function but with 0 reward if it's a hill-climbing one - RUNTIME_AWARE, ///@ same as NON_PENALIZING_BASIC but with normalizing with the runtime factor of each move type - WL_BIASED_RUNTIME_AWARE, ///@ same as RUNTIME_AWARE but more biased to WL cost (the factor of the bias is REWARD_BB_TIMING_RELATIVE_WEIGHT) - UNDEFINED_REWARD ///@ Used for manual moves + BASIC, ///@ directly uses the change of the annealing cost function + NON_PENALIZING_BASIC, ///@ same as basic reward function but with 0 reward if it's a hill-climbing one + RUNTIME_AWARE, ///@ same as NON_PENALIZING_BASIC but with normalizing with the runtime factor of each move type + WL_BIASED_RUNTIME_AWARE, ///@ same as RUNTIME_AWARE but more biased to WL cost (the factor of the bias is REWARD_BB_TIMING_RELATIVE_WEIGHT) + UNDEFINED_REWARD ///@ Used for manual moves }; e_reward_function string_to_reward(const std::string& st); @@ -87,7 +87,6 @@ e_reward_function string_to_reward(const std::string& st); */ class MoveGenerator { public: - /** * @brief Initializes some protected member variables that are used * by inheriting classes. diff --git a/vpr/src/place/move_utils.cpp b/vpr/src/place/move_utils.cpp index 1e49f8d22aa..e1a4a986cfc 100644 --- a/vpr/src/place/move_utils.cpp +++ b/vpr/src/place/move_utils.cpp @@ -146,14 +146,13 @@ e_block_move_result record_single_block_swap(t_pl_blocks_to_be_moved& blocks_aff return e_block_move_result::ABORT; } - // Sets up the blocks moved outcome = blocks_affected.record_block_move(b_from, to, blk_loc_registry); if (outcome != e_block_move_result::VALID) { return outcome; } - + t_pl_loc from = block_locs[b_from].loc; outcome = blocks_affected.record_block_move(b_to, from, blk_loc_registry); @@ -473,7 +472,6 @@ bool is_legal_swap_to_location(ClusterBlockId blk, const auto& block_locs = blk_loc_registry.block_locs(); const GridBlock& grid_blocks = blk_loc_registry.grid_blocks(); - if (to.x < 0 || to.x >= int(device_ctx.grid.width()) || to.y < 0 || to.y >= int(device_ctx.grid.height()) || to.layer < 0 @@ -560,7 +558,6 @@ ClusterBlockId propose_block_to_move(const t_placer_opts& placer_opts, ClusterBlockId b_from = ClusterBlockId::INVALID(); - if (highly_crit_block) { b_from = pick_from_highly_critical_block(*net_from, *pin_from, logical_blk_type_index, placer_state, *placer_criticalities, rng); } else { @@ -626,7 +623,7 @@ ClusterBlockId pick_from_highly_critical_block(ClusterNetId& net_from, if (b_from_type->index == logical_blk_type_index || logical_blk_type_index < 0) { // ensure that the selected block is not fixed if (block_locs[b_from].is_fixed) { - return ClusterBlockId::INVALID(); // a fixed block can't be moved + return ClusterBlockId::INVALID(); // a fixed block can't be moved } net_from = crit_pin.first; @@ -1194,7 +1191,7 @@ bool intersect_range_limit_with_floorplan_constraints(ClusterBlockId b_from, const auto [layer_low, layer_high] = compressed_intersect_reg.get_layer_range(); VTR_ASSERT(layer_low == layer_num && layer_high == layer_num); - delta_cx = intersect_rect.xmax() - intersect_rect.xmin(); + delta_cx = intersect_rect.xmax() - intersect_rect.xmin(); std::tie(search_range.xmin, search_range.ymin, search_range.xmax, search_range.ymax) = intersect_rect.coordinates(); search_range.layer_min = layer_low; diff --git a/vpr/src/place/move_utils.h b/vpr/src/place/move_utils.h index 4d156d9c7a8..2b0fa65bba7 100644 --- a/vpr/src/place/move_utils.h +++ b/vpr/src/place/move_utils.h @@ -461,4 +461,3 @@ std::pair union_2d_bb_incr(const std::vector& num_edge_vec, */ void enable_placer_debug(const t_placer_opts& placer_opts, ClusterBlockId blk_id); - diff --git a/vpr/src/place/noc_place_utils.cpp b/vpr/src/place/noc_place_utils.cpp index d787e6b1faa..5716881de21 100644 --- a/vpr/src/place/noc_place_utils.cpp +++ b/vpr/src/place/noc_place_utils.cpp @@ -22,7 +22,6 @@ #include #include - /** * @brief Randomly select a movable NoC router cluster blocks * diff --git a/vpr/src/place/placer_breakpoint.cpp b/vpr/src/place/placer_breakpoint.cpp index a31a0add053..d71430f2090 100644 --- a/vpr/src/place/placer_breakpoint.cpp +++ b/vpr/src/place/placer_breakpoint.cpp @@ -1,6 +1,5 @@ #include "placer_breakpoint.h" - //map of the available move types and their corresponding type number std::map available_move_types = { {0, "Uniform"}}; @@ -17,8 +16,11 @@ void transform_blocks_affected(const t_pl_blocks_to_be_moved& blocksAffected) { } } -void stop_placement_and_check_breakpoints(t_pl_blocks_to_be_moved& blocks_affected, e_move_result move_outcome, - double delta_c, double bb_delta_c, double timing_delta_c) { +void stop_placement_and_check_breakpoints(t_pl_blocks_to_be_moved& blocks_affected, + e_move_result move_outcome, + double delta_c, + double bb_delta_c, + double timing_delta_c) { t_draw_state* draw_state = get_draw_state_vars(); BreakpointState* bp_state = get_bp_state_globals()->get_glob_breakpoint_state(); diff --git a/vpr/src/place/placer_breakpoint.h b/vpr/src/place/placer_breakpoint.h index 510b7071e0d..b202a25081e 100644 --- a/vpr/src/place/placer_breakpoint.h +++ b/vpr/src/place/placer_breakpoint.h @@ -1,5 +1,5 @@ -#ifndef PLACER_BREAKPOINT_H -#define PLACER_BREAKPOINT_H + +#pragma once #include "globals.h" #include "vpr_types.h" @@ -7,13 +7,12 @@ #include "breakpoint.h" #include "draw.h" - //transforms the vector moved_blocks to a vector of ints and adds it in glob_breakpoint_state void transform_blocks_affected(const t_pl_blocks_to_be_moved& blocksAffected); //checks the breakpoint and see whether one of them was reached and pause place,emt accordingly -void stop_placement_and_check_breakpoints(t_pl_blocks_to_be_moved& blocks_affected, e_move_result move_outcome, - double delta_c, double bb_delta_c, double timing_delta_c); - - -#endif +void stop_placement_and_check_breakpoints(t_pl_blocks_to_be_moved& blocks_affected, + e_move_result move_outcome, + double delta_c, + double bb_delta_c, + double timing_delta_c); \ No newline at end of file diff --git a/vpr/src/route/ParallelNetlistRouter.tpp b/vpr/src/route/ParallelNetlistRouter.tpp index 1268ed6030e..c845be8518d 100644 --- a/vpr/src/route/ParallelNetlistRouter.tpp +++ b/vpr/src/route/ParallelNetlistRouter.tpp @@ -22,7 +22,7 @@ inline RouteIterResults ParallelNetlistRouter::route_netlist(int itry, /* Organize netlist into a PartitionTree. * Nets in a given level of nodes are guaranteed to not have any overlapping bounding boxes, so they can be routed in parallel. */ vtr::Timer timer; - if(!_tree){ + if (!_tree) { _tree = PartitionTree(_net_list); PartitionTreeDebug::log("Iteration " + std::to_string(itry) + ": built partition tree in " + std::to_string(timer.elapsed_sec()) + " s"); } diff --git a/vpr/src/route/router_lookahead_map.cpp b/vpr/src/route/router_lookahead_map.cpp index b0c5e719eb9..621690f3bac 100644 --- a/vpr/src/route/router_lookahead_map.cpp +++ b/vpr/src/route/router_lookahead_map.cpp @@ -36,12 +36,12 @@ #include "rr_graph.h" #ifdef VTR_ENABLE_CAPNPROTO -# include "capnp/serialize.h" -# include "map_lookahead.capnp.h" -# include "ndmatrix_serdes.h" -# include "intra_cluster_serdes.h" -# include "mmap_file.h" -# include "serdes_utils.h" +#include "capnp/serialize.h" +#include "map_lookahead.capnp.h" +#include "ndmatrix_serdes.h" +#include "intra_cluster_serdes.h" +#include "mmap_file.h" +#include "serdes_utils.h" #endif /* VTR_ENABLE_CAPNPROTO */ static constexpr int VALID_NEIGHBOR_NUMBER = 3; @@ -331,15 +331,15 @@ std::pair MapLookahead::get_expected_delay_and_cong(RRNodeId from_ * the minimum cost among them. In the following for loop, we iterate over each layer and pass it the * routing segments on that layer reachable from the OPIN/SOURCE to segments on that layer. This for loop then calculates and returns * the minimum cost from the given OPIN/SOURCE to the specified SINK considering routing options across all layers. - */ + */ for (int layer_num = 0; layer_num < device_ctx.grid.get_num_layers(); layer_num++) { float this_delay_cost; float this_cong_cost; std::tie(this_delay_cost, this_cong_cost) = util::get_cost_from_src_opin(src_opin_delays[from_layer_num][from_tile_index][from_ptc][layer_num], - delta_x, - delta_y, - to_layer_num, - get_wire_cost_entry); + delta_x, + delta_y, + to_layer_num, + get_wire_cost_entry); expected_delay_cost = std::min(expected_delay_cost, this_delay_cost); expected_cong_cost = std::min(expected_cong_cost, this_cong_cost); } @@ -885,9 +885,9 @@ static void min_opin_distance_cost_map(const util::t_src_opin_delays& src_opin_d // #ifndef VTR_ENABLE_CAPNPROTO -# define DISABLE_ERROR \ - "is disabled because VTR_ENABLE_CAPNPROTO=OFF." \ - "Re-compile with CMake option VTR_ENABLE_CAPNPROTO=ON to enable." +#define DISABLE_ERROR \ + "is disabled because VTR_ENABLE_CAPNPROTO=OFF." \ + "Re-compile with CMake option VTR_ENABLE_CAPNPROTO=ON to enable." void read_router_lookahead(const std::string& /*file*/) { VPR_THROW(VPR_ERROR_PLACE, "MapLookahead::read_router_lookahead " DISABLE_ERROR); diff --git a/vpr/src/route/router_lookahead_map_utils.cpp b/vpr/src/route/router_lookahead_map_utils.cpp index 9ec6e6a9151..6e1b2013ee4 100644 --- a/vpr/src/route/router_lookahead_map_utils.cpp +++ b/vpr/src/route/router_lookahead_map_utils.cpp @@ -59,7 +59,6 @@ static void expand_dijkstra_neighbours(util::PQ_Entry parent_entry, vtr::vector& node_expanded, std::priority_queue& pq); - /** * @brief Computes the adjusted position of an RR graph node. * This function does not modify the position of the given node. @@ -780,7 +779,6 @@ t_routing_cost_map get_routing_cost_map(int longest_seg_length, //Finally, now that we have a list of sample locations, run a Dijkstra flood from //each sample location to profile the routing network from this type - t_routing_cost_map routing_cost_map({static_cast(device_ctx.grid.get_num_layers()), device_ctx.grid.width(), device_ctx.grid.height()}); if (sample_nodes.empty()) { diff --git a/vpr/src/route/router_lookahead_sampling.cpp b/vpr/src/route/router_lookahead_sampling.cpp index c7f2221ff9c..a8ad7dc2f15 100644 --- a/vpr/src/route/router_lookahead_sampling.cpp +++ b/vpr/src/route/router_lookahead_sampling.cpp @@ -60,9 +60,9 @@ static std::vector choose_points(const vtr::Matrix& counts, // sort by distance from center std::stable_sort(points.begin(), points.end(), - [&](const SamplePoint& a, const SamplePoint& b) { - return manhattan_distance(a.location, center) < manhattan_distance(b.location, center); - }); + [&](const SamplePoint& a, const SamplePoint& b) { + return manhattan_distance(a.location, center) < manhattan_distance(b.location, center); + }); return points; } @@ -233,9 +233,9 @@ std::vector find_sample_regions(int num_segments) { // sort regions std::stable_sort(sample_regions.begin(), sample_regions.end(), - [](const SampleRegion& a, const SampleRegion& b) { - return a.order < b.order; - }); + [](const SampleRegion& a, const SampleRegion& b) { + return a.order < b.order; + }); // build an index of sample points on segment type and location std::map, SamplePoint*> sample_point_index; diff --git a/vpr/src/route/rr_graph.cpp b/vpr/src/route/rr_graph.cpp index 2de698f307a..b8fb440a172 100644 --- a/vpr/src/route/rr_graph.cpp +++ b/vpr/src/route/rr_graph.cpp @@ -329,7 +329,6 @@ static void alloc_and_load_tile_rr_graph(RRGraphBuilder& rr_graph_builder, static float pattern_fmod(float a, float b); - /** * @brief Loads the tracks_connected_to_pin array with an even distribution of switches across the tracks for each pin. * @@ -761,8 +760,8 @@ static void build_intra_cluster_rr_graph(const t_graph_type graph_type, * @param det_routing_arch Contain the information from architecture file * @param load_rr_graph Indicate whether the RR graph is loaded from a file */ -static int get_delayless_switch_id(t_det_routing_arch* det_routing_arch, - bool load_rr_graph); +static int get_delayless_switch_id(t_det_routing_arch* det_routing_arch, + bool load_rr_graph); /******************* Subroutine definitions *******************************/ @@ -1363,7 +1362,7 @@ static void build_rr_graph(const t_graph_type graph_type, */ if (grid.get_num_layers() > 1 && sb_type == CUSTOM) { //keep how many nodes each switchblock requires for each x,y location - auto extra_nodes_per_switchblock = get_number_track_to_track_inter_die_conn(sb_conn_map,custom_3d_sb_fanin_fanout, device_ctx.rr_graph_builder); + auto extra_nodes_per_switchblock = get_number_track_to_track_inter_die_conn(sb_conn_map, custom_3d_sb_fanin_fanout, device_ctx.rr_graph_builder); //allocate new nodes in each switchblocks alloc_and_load_inter_die_rr_node_indices(device_ctx.rr_graph_builder, &nodes_per_chan, grid, extra_nodes_per_switchblock, &num_rr_nodes); device_ctx.rr_graph_builder.resize_nodes(num_rr_nodes); @@ -1474,9 +1473,9 @@ static void build_rr_graph(const t_graph_type graph_type, route_verbosity); // Verify no incremental node allocation. - // AA: Note that in the case of dedicated networks, we are currently underestimating the additional node count due to the clock networks. + // AA: Note that in the case of dedicated networks, we are currently underestimating the additional node count due to the clock networks. /* For now, the node count comparison is being skipped in the presence of clock networks. - * TODO: The node estimation needs to be fixed for dedicated clock networks. */ + * TODO: The node estimation needs to be fixed for dedicated clock networks. */ if (rr_graph.num_nodes() > expected_node_count && clock_modeling != DEDICATED_NETWORK) { VTR_LOG_ERROR("Expected no more than %zu nodes, have %zu nodes\n", expected_node_count, rr_graph.num_nodes()); @@ -1644,12 +1643,12 @@ static void build_intra_cluster_rr_graph(const t_graph_type graph_type, } static int get_delayless_switch_id(t_det_routing_arch* det_routing_arch, - bool load_rr_graph) { + bool load_rr_graph) { const auto& device_ctx = g_vpr_ctx.device(); int delayless_switch = OPEN; if (load_rr_graph) { const auto& rr_switches = device_ctx.rr_graph.rr_switch(); - for (size_t switch_id = 0; switch_id < rr_switches.size(); switch_id++){ + for (size_t switch_id = 0; switch_id < rr_switches.size(); switch_id++) { const auto& rr_switch = rr_switches[RRSwitchId(switch_id)]; if (rr_switch.name.find("delayless") != std::string::npos) { delayless_switch = static_cast(switch_id); @@ -2174,7 +2173,7 @@ static std::function alloc_and_load_rr_graph(RRGraphBuilder *Fc_clipped = false; /* This function is called to build the general routing graph resoruces. Thus, - the edges are not remapped yet.*/ + * the edges are not remapped yet.*/ bool switches_remapped = false; int num_edges = 0; @@ -2222,7 +2221,7 @@ static std::function alloc_and_load_rr_graph(RRGraphBuilder } } - VTR_LOGV(route_verbosity > 1,"SOURCE->OPIN and IPIN->SINK edge count:%d\n", num_edges); + VTR_LOGV(route_verbosity > 1, "SOURCE->OPIN and IPIN->SINK edge count:%d\n", num_edges); num_edges = 0; /* Build opins */ int rr_edges_before_directs = 0; @@ -2259,8 +2258,8 @@ static std::function alloc_and_load_rr_graph(RRGraphBuilder } } - VTR_LOGV(route_verbosity > 1,"OPIN->CHANX/CHANY edge count before creating direct connections: %d\n", rr_edges_before_directs); - VTR_LOGV(route_verbosity > 1,"OPIN->CHANX/CHANY edge count after creating direct connections: %d\n", num_edges); + VTR_LOGV(route_verbosity > 1, "OPIN->CHANX/CHANY edge count before creating direct connections: %d\n", rr_edges_before_directs); + VTR_LOGV(route_verbosity > 1, "OPIN->CHANX/CHANY edge count after creating direct connections: %d\n", num_edges); num_edges = 0; /* Build channels */ @@ -2270,14 +2269,14 @@ static std::function alloc_and_load_rr_graph(RRGraphBuilder vtr::NdMatrix num_of_3d_conns_custom_SB; t_rr_edge_info_set des_3d_rr_edges_to_create; - if(grid.get_num_layers() > 1 && sb_conn_map != nullptr){ - num_of_3d_conns_custom_SB.resize(std::array{grid.width(), grid.height()}, 0); + if (grid.get_num_layers() > 1 && sb_conn_map != nullptr) { + num_of_3d_conns_custom_SB.resize(std::array{grid.width(), grid.height()}, 0); } for (size_t i = 0; i < grid.width() - 1; ++i) { for (size_t j = 0; j < grid.height() - 1; ++j) { for (int layer = 0; layer < grid.get_num_layers(); ++layer) { - auto &device_ctx = g_vpr_ctx.device(); + auto& device_ctx = g_vpr_ctx.device(); /* Skip the current die if architecture file specifies that it doesn't require inter-cluster programmable resource routing */ if (!device_ctx.inter_cluster_prog_routing_resources.at(layer)) { continue; @@ -2339,15 +2338,14 @@ static std::function alloc_and_load_rr_graph(RRGraphBuilder } } - if(grid.get_num_layers() > 1 && sb_conn_map != nullptr){ + if (grid.get_num_layers() > 1 && sb_conn_map != nullptr) { uniquify_edges(des_3d_rr_edges_to_create); alloc_and_load_edges(rr_graph_builder, des_3d_rr_edges_to_create); num_edges += des_3d_rr_edges_to_create.size(); des_3d_rr_edges_to_create.clear(); } - - VTR_LOGV(route_verbosity > 1,"CHAN->CHAN type edge count:%d\n", num_edges); + VTR_LOGV(route_verbosity > 1, "CHAN->CHAN type edge count:%d\n", num_edges); num_edges = 0; std::function update_chan_width = [](t_chan_width*) noexcept {}; @@ -2958,11 +2956,11 @@ static void add_pb_edges(RRGraphBuilder& rr_graph_builder, float delay = g_vpr_ctx.device().all_sw_inf.at(sw_idx).Tdel(); bool is_new_sw; std::tie(is_new_sw, sw_idx) = find_create_intra_cluster_sw(rr_graph_builder, - all_sw_inf, - R_minW_nmos, - R_minW_pmos, - switches_remapped, - delay); + all_sw_inf, + R_minW_nmos, + R_minW_pmos, + switches_remapped, + delay); } rr_edges_to_create.emplace_back(parent_pin_node_id, conn_pin_node_id, sw_idx, switches_remapped); } @@ -3281,10 +3279,10 @@ static void build_rr_chan(RRGraphBuilder& rr_graph_builder, } if (to_seg_details->length() > 0) { get_track_to_tracks(rr_graph_builder, layer, chan_coord, start, track, chan_type, chan_coord, - opposite_chan_type, seg_dimension, max_opposite_chan_width, grid, + opposite_chan_type, seg_dimension, max_opposite_chan_width, grid, Fs_per_side, sblock_pattern, num_of_3d_conns_custom_SB, node, rr_edges_to_create, des_3d_rr_edges_to_create, from_seg_details, to_seg_details, opposite_chan_details, - directionality,custom_3d_sb_fanin_fanout,delayless_switch, + directionality, custom_3d_sb_fanin_fanout, delayless_switch, switch_block_conn, sb_conn_map); } } @@ -3301,10 +3299,10 @@ static void build_rr_chan(RRGraphBuilder& rr_graph_builder, } if (to_seg_details->length() > 0) { get_track_to_tracks(rr_graph_builder, layer, chan_coord, start, track, chan_type, chan_coord + 1, - opposite_chan_type, seg_dimension, max_opposite_chan_width, grid, + opposite_chan_type, seg_dimension, max_opposite_chan_width, grid, Fs_per_side, sblock_pattern, num_of_3d_conns_custom_SB, node, rr_edges_to_create, des_3d_rr_edges_to_create, from_seg_details, to_seg_details, opposite_chan_details, - directionality,custom_3d_sb_fanin_fanout, delayless_switch, switch_block_conn, sb_conn_map); + directionality, custom_3d_sb_fanin_fanout, delayless_switch, switch_block_conn, sb_conn_map); } } @@ -3333,10 +3331,10 @@ static void build_rr_chan(RRGraphBuilder& rr_graph_builder, } if (to_seg_details->length() > 0) { get_track_to_tracks(rr_graph_builder, layer, chan_coord, start, track, chan_type, target_seg, - chan_type, seg_dimension, max_chan_width, grid, + chan_type, seg_dimension, max_chan_width, grid, Fs_per_side, sblock_pattern, num_of_3d_conns_custom_SB, node, rr_edges_to_create, des_3d_rr_edges_to_create, from_seg_details, to_seg_details, from_chan_details, - directionality,custom_3d_sb_fanin_fanout, delayless_switch, + directionality, custom_3d_sb_fanin_fanout, delayless_switch, switch_block_conn, sb_conn_map); } } @@ -3443,9 +3441,9 @@ static vtr::NdMatrix, 5> alloc_and_load_pin_to_track_map(const * used to index into the correct entries when loading up 'result' */ auto& grid = g_vpr_ctx.device().grid; auto result = vtr::NdMatrix, 5>({ - size_t(tile_type->num_pins), //[0..num_pins-1] - size_t(tile_type->width), //[0..width-1] - size_t(tile_type->height), //[0..height-1] + size_t(tile_type->num_pins), //[0..num_pins-1] + size_t(tile_type->width), //[0..width-1] + size_t(tile_type->height), //[0..height-1] size_t(grid.get_num_layers()), //[0..layer-1] 4, //[0..sides-1] }); @@ -3535,12 +3533,12 @@ static vtr::NdMatrix alloc_and_load_pin_to_seg_type(const e_pin_type pin } auto tracks_connected_to_pin = vtr::NdMatrix({ - size_t(tile_type->num_pins), //[0..num_pins-1] - size_t(tile_type->width), //[0..width-1] - size_t(tile_type->height), //[0..height-1] + size_t(tile_type->num_pins), //[0..num_pins-1] + size_t(tile_type->width), //[0..width-1] + size_t(tile_type->height), //[0..height-1] size_t(grid.get_num_layers()), //[0..layer-1] NUM_2D_SIDES, //[0..NUM_2D_SIDES-1] - size_t(max_Fc) //[0..Fc-1] + size_t(max_Fc) //[0..Fc-1] }, OPEN); //Unconnected @@ -3549,8 +3547,8 @@ static vtr::NdMatrix alloc_and_load_pin_to_seg_type(const e_pin_type pin //Type->num_pins) if a logical pin has multiple specified physical //pinlocations (i.e. appears on multiple sides of the block) auto num_dir = vtr::NdMatrix({ - size_t(tile_type->width), //[0..width-1] - size_t(tile_type->height), //[0..height-1] + size_t(tile_type->width), //[0..width-1] + size_t(tile_type->height), //[0..height-1] size_t(grid.get_num_layers()), //[0..layer-1] NUM_2D_SIDES //[0..NUM_2D_SIDES-1] }, @@ -3564,16 +3562,16 @@ static vtr::NdMatrix alloc_and_load_pin_to_seg_type(const e_pin_type pin auto dir_list = vtr::NdMatrix({ size_t(tile_type->width), //[0..width-1] size_t(tile_type->height), //[0..height-1] - size_t(grid.get_num_layers()), //[0..layer-1] - NUM_2D_SIDES, //[0..NUM_2D_SIDES-1] + size_t(grid.get_num_layers()), //[0..layer-1] + NUM_2D_SIDES, //[0..NUM_2D_SIDES-1] size_t(tile_type->num_pins) * size_t(grid.get_num_layers()) //[0..num_pins * num_layers-1] }, -1); //Defensive coding: Initialize to invalid //Number of currently assigned physical pins auto num_done_per_dir = vtr::NdMatrix({ - size_t(tile_type->width), //[0..width-1] - size_t(tile_type->height), //[0..height-1] + size_t(tile_type->width), //[0..width-1] + size_t(tile_type->height), //[0..height-1] size_t(grid.get_num_layers()), //[0..layer-1] NUM_2D_SIDES //[0..NUM_2D_SIDES-1] }, @@ -4067,7 +4065,7 @@ static void load_perturbed_connection_block_pattern(vtr::NdMatrix& track int layer = pin_locations[i].layer_offset; int pin_Fc = Fc[pin][seg_index]; - int Fc_dense = ( pin_Fc / 2) + 1; + int Fc_dense = (pin_Fc / 2) + 1; int Fc_sparse = pin_Fc - Fc_dense; int Fc_half[2]; @@ -4399,7 +4397,7 @@ static t_clb_to_clb_directs* alloc_and_load_clb_to_clb_directs(const std::vector // Figure out which type, port, and pin is used for (const t_physical_tile_type& type : device_ctx.physical_tile_types) { - if (tile_name == type.name ) { + if (tile_name == type.name) { physical_tile = &type; break; } @@ -5134,15 +5132,15 @@ static std::pair find_create_intra_cluster_sw(RRGraphBuilder& rr_grap // If this assumption proven to not be accurate, the implementation needs to be changed. VTR_ASSERT(arch_sw.fixed_Tdel()); - t_rr_switch_inf new_rr_switch_inf = create_rr_switch_from_arch_switch(create_internal_arch_sw(delay), - R_minW_nmos, - R_minW_pmos); + t_rr_switch_inf new_rr_switch_inf = create_rr_switch_from_arch_switch(create_internal_arch_sw(delay), + R_minW_nmos, + R_minW_pmos); RRSwitchId rr_switch_id = rr_graph.add_rr_switch(new_rr_switch_inf); /*If the switch found inside the cluster has not seen before and RR graph is not read from a file, - we need to add this switch to switch_fanin_remap data strcutre which is used later to remap switch IDs - from architecture ID to RR graph switch ID. The reason why we don't this when RR graph is read from a file - is that in that case, the switch IDs of edges are alreay RR graph switch IDs. */ + * we need to add this switch to switch_fanin_remap data strcutre which is used later to remap switch IDs + * from architecture ID to RR graph switch ID. The reason why we don't this when RR graph is read from a file + * is that in that case, the switch IDs of edges are alreay RR graph switch IDs. */ auto& switch_fanin_remap = g_vpr_ctx.mutable_device().switch_fanin_remap; switch_fanin_remap.push_back({{UNDEFINED, size_t(rr_switch_id)}}); diff --git a/vpr/src/route/rr_graph2.cpp b/vpr/src/route/rr_graph2.cpp index 128617d317e..cf4d6e01eab 100644 --- a/vpr/src/route/rr_graph2.cpp +++ b/vpr/src/route/rr_graph2.cpp @@ -530,11 +530,10 @@ t_seg_details* alloc_and_load_seg_details(int* max_chan_width, //check for directionality to set the wire_switch and opin_switch //if not specified in the architecture file, we will use a same mux for both directions - if (seg_details[cur_track].direction == Direction::INC || seg_details[cur_track].direction == Direction::BIDIR || arch_wire_switch_dec == -1){ + if (seg_details[cur_track].direction == Direction::INC || seg_details[cur_track].direction == Direction::BIDIR || arch_wire_switch_dec == -1) { seg_details[cur_track].arch_opin_switch = arch_opin_switch; seg_details[cur_track].arch_wire_switch = arch_wire_switch; - } - else { + } else { VTR_ASSERT(seg_details[cur_track].direction == Direction::DEC); seg_details[cur_track].arch_opin_switch = arch_opin_switch_dec; seg_details[cur_track].arch_wire_switch = arch_wire_switch_dec; @@ -1279,17 +1278,17 @@ vtr::NdMatrix get_number_track_to_track_inter_die_conn(t_sb_connection_m for (int iconn = 0; iconn < (int)conn_vector.size(); ++iconn) { //check if both from_node and to_node exists in the rr-graph //CHANY -> CHANX connection - if(check_3d_SB_RRnodes(rr_graph_builder, x, y, conn_vector[iconn].from_wire, - conn_vector[iconn].from_wire_layer, CHANY, - conn_vector[iconn].to_wire, conn_vector[iconn].to_wire_layer, - CHANX)){ + if (check_3d_SB_RRnodes(rr_graph_builder, x, y, conn_vector[iconn].from_wire, + conn_vector[iconn].from_wire_layer, CHANY, + conn_vector[iconn].to_wire, conn_vector[iconn].to_wire_layer, + CHANX)) { num_of_3d_conn++; } //CHANX -> CHANY connection - if(check_3d_SB_RRnodes(rr_graph_builder, x, y, conn_vector[iconn].from_wire, - conn_vector[iconn].from_wire_layer, CHANX, - conn_vector[iconn].to_wire, conn_vector[iconn].to_wire_layer, - CHANY)){ + if (check_3d_SB_RRnodes(rr_graph_builder, x, y, conn_vector[iconn].from_wire, + conn_vector[iconn].from_wire_layer, CHANX, + conn_vector[iconn].to_wire, conn_vector[iconn].to_wire_layer, + CHANY)) { num_of_3d_conn++; } } @@ -1297,7 +1296,7 @@ vtr::NdMatrix get_number_track_to_track_inter_die_conn(t_sb_connection_m } } } - extra_nodes_per_switchblocks[x][y] += ((num_of_3d_conn + custom_3d_sb_fanin_fanout - 1)/ custom_3d_sb_fanin_fanout); + extra_nodes_per_switchblocks[x][y] += ((num_of_3d_conn + custom_3d_sb_fanin_fanout - 1) / custom_3d_sb_fanin_fanout); } } } @@ -2096,7 +2095,7 @@ int get_track_to_tracks(RRGraphBuilder& rr_graph_builder, if (Direction::INC == from_seg_details[from_track].direction() || BI_DIRECTIONAL == directionality) { num_conn += get_track_to_chan_seg(rr_graph_builder, layer, max_chan_width, from_track, to_chan, to_seg, to_type, from_side_b, to_side, - switch_override,custom_3d_sb_fanin_fanout, delayless_switch, + switch_override, custom_3d_sb_fanin_fanout, delayless_switch, sb_conn_map, num_of_3d_conns_custom_SB, from_rr_node, rr_edges_to_create, des_3d_rr_edges_to_create); } } else { From 6a7a21f6714bb83f96d7fb7b3d0722d80200f27e Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Mon, 17 Mar 2025 13:02:33 -0400 Subject: [PATCH 2/9] don't break before multi-line string. don't break before assignment operator --- .clang-format | 4 +- .../src/include/internal_bits.hpp | 87 +++++++------------ libs/libvtrutil/src/tl_optional.hpp | 30 +++---- libs/libvtrutil/src/vtr_prefix_sum.h | 2 +- odin_ii/src/ast/ast_util.cpp | 3 +- .../analytical_place/partial_legalizer.cpp | 48 +++++----- vpr/src/base/read_options.cpp | 21 +++-- vpr/src/base/read_place.cpp | 4 +- vpr/src/base/vpr_api.cpp | 22 +++-- vpr/src/noc/noc_storage.cpp | 12 +-- vpr/src/pack/cluster_feasibility_filter.cpp | 6 +- vpr/src/pack/pack.cpp | 13 ++- vpr/src/place/compressed_grid.h | 3 +- vpr/src/place/delay_model/place_delay_model.h | 3 +- vpr/src/place/move_utils.cpp | 2 +- vpr/src/place/noc_place_utils.cpp | 36 ++++---- vpr/src/place/place_macro.cpp | 3 - vpr/src/route/clock_network_builders.h | 3 +- vpr/src/route/connection_router_interface.h | 9 +- 19 files changed, 130 insertions(+), 181 deletions(-) diff --git a/.clang-format b/.clang-format index 0ac7bb11747..f53e8a6adf4 100644 --- a/.clang-format +++ b/.clang-format @@ -15,7 +15,7 @@ AllowShortIfStatementsOnASingleLine: true AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: true BinPackArguments: true BinPackParameters: false @@ -34,7 +34,7 @@ BraceWrapping: SplitEmptyFunction: false SplitEmptyRecord: true SplitEmptyNamespace: true -BreakBeforeBinaryOperators: All +BreakBeforeBinaryOperators: NonAssignment BreakBeforeBraces: Custom BreakBeforeInheritanceComma: false BreakBeforeTernaryOperators: true diff --git a/libs/librtlnumber/src/include/internal_bits.hpp b/libs/librtlnumber/src/include/internal_bits.hpp index 66f9612ba44..0d5c7388470 100644 --- a/libs/librtlnumber/src/include/internal_bits.hpp +++ b/libs/librtlnumber/src/include/internal_bits.hpp @@ -61,44 +61,37 @@ constexpr bit_value_t l_buf[4] = { _0, _1, _x, _x}; _static_unused(l_buf) - constexpr bit_value_t l_not[4] - = { + constexpr bit_value_t l_not[4] = { /* 0 1 x z <- a */ _1, _0, _x, _x}; _static_unused(l_not) - constexpr bit_value_t is_unk[4] - = { + constexpr bit_value_t is_unk[4] = { /* 0 1 x z <- a*/ _0, _0, _1, _1}; _static_unused(is_unk) - constexpr bit_value_t is_x_bit[4] - = { + constexpr bit_value_t is_x_bit[4] = { /* 0 1 x z <- a*/ _0, _0, _1, _0}; _static_unused(is_x_bit) - constexpr bit_value_t is_z_bit[4] - = { + constexpr bit_value_t is_z_bit[4] = { /* 0 1 x z <- a*/ _0, _0, _0, _1}; _static_unused(is_z_bit) - constexpr bit_value_t is_one_bit[4] - = { + constexpr bit_value_t is_one_bit[4] = { /* 0 1 x z <- a*/ _0, _1, _0, _0}; _static_unused(is_one_bit) - constexpr bit_value_t is_zero_bit[4] - = { + constexpr bit_value_t is_zero_bit[4] = { /* 0 1 x z <- a*/ _1, _0, _0, _0}; _static_unused(is_zero_bit) - constexpr bit_value_t l_and[4][4] - = { + constexpr bit_value_t l_and[4][4] = { /* a / 0 1 x z <-b */ /* 0 */ {_0, _0, _0, _0}, /* 1 */ {_0, _1, _x, _x}, @@ -106,12 +99,10 @@ _static_unused(is_zero_bit) /* z */ {_0, _x, _x, _x}}; _static_unused(l_and) - constexpr bit_value_t l_nand[4][4] - = unroll_2d_invert(l_and); + constexpr bit_value_t l_nand[4][4] = unroll_2d_invert(l_and); _static_unused(l_nand) - constexpr bit_value_t l_or[4][4] - = { + constexpr bit_value_t l_or[4][4] = { /* a / 0 1 x z <-b */ /* 0 */ {_0, _1, _x, _x}, /* 1 */ {_1, _1, _1, _1}, @@ -119,12 +110,10 @@ _static_unused(l_nand) /* z */ {_x, _1, _x, _x}}; _static_unused(l_or) - constexpr bit_value_t l_nor[4][4] - = unroll_2d_invert(l_or); + constexpr bit_value_t l_nor[4][4] = unroll_2d_invert(l_or); _static_unused(l_nor) - constexpr bit_value_t l_xor[4][4] - = { + constexpr bit_value_t l_xor[4][4] = { /* a / 0 1 x z <-b */ /* 0 */ {_0, _1, _x, _x}, /* 1 */ {_1, _0, _x, _x}, @@ -132,12 +121,10 @@ _static_unused(l_nor) /* z */ {_x, _x, _x, _x}}; _static_unused(l_xor) - constexpr bit_value_t l_xnor[4][4] - = unroll_2d_invert(l_xor); + constexpr bit_value_t l_xnor[4][4] = unroll_2d_invert(l_xor); _static_unused(l_xnor) - constexpr bit_value_t l_notif1[4][4] - = { + constexpr bit_value_t l_notif1[4][4] = { /* in / 0 1 x z <-control */ /* 0 */ {_z, _1, _x, _x}, /* 1 */ {_z, _0, _x, _x}, @@ -145,8 +132,7 @@ _static_unused(l_xnor) /* z */ {_z, _x, _x, _x}}; _static_unused(l_notif1) - constexpr bit_value_t l_notif0[4][4] - = { + constexpr bit_value_t l_notif0[4][4] = { /* in / 0 1 x z <-control */ /* 0 */ {_1, _z, _x, _x}, /* 1 */ {_0, _z, _x, _x}, @@ -154,8 +140,7 @@ _static_unused(l_notif1) /* z */ {_x, _z, _x, _x}}; _static_unused(l_notif0) - constexpr bit_value_t l_bufif1[4][4] - = { + constexpr bit_value_t l_bufif1[4][4] = { /* in / 0 1 x z <-control */ /* 0 */ {_z, _0, _x, _x}, /* 1 */ {_z, _1, _x, _x}, @@ -163,8 +148,7 @@ _static_unused(l_notif0) /* z */ {_z, _x, _x, _x}}; _static_unused(l_bufif1) - constexpr bit_value_t l_bufif0[4][4] - = { + constexpr bit_value_t l_bufif0[4][4] = { /* in / 0 1 x z <-control */ /* 0 */ {_0, _z, _x, _x}, /* 1 */ {_1, _z, _x, _x}, @@ -176,8 +160,7 @@ _static_unused(l_bufif0) * Tran NO SUPPORT FOR THESE YET */ /* cmos gates */ - constexpr bit_value_t l_rpmos[4][4] - = { + constexpr bit_value_t l_rpmos[4][4] = { /* in / 0 1 x z <-control */ /* 0 */ {_0, _z, _x, _x}, /* 1 */ {_1, _z, _x, _x}, @@ -185,8 +168,7 @@ _static_unused(l_bufif0) /* z */ {_z, _z, _z, _z}}; _static_unused(l_rpmos) - constexpr bit_value_t l_rnmos[4][4] - = { + constexpr bit_value_t l_rnmos[4][4] = { /* in / 0 1 x z <-control */ /* 0 */ {_z, _0, _x, _x}, /* 1 */ {_z, _1, _x, _x}, @@ -194,8 +176,7 @@ _static_unused(l_rpmos) /* z */ {_z, _z, _z, _z}}; _static_unused(l_rnmos) - constexpr bit_value_t l_nmos[4][4] - = { + constexpr bit_value_t l_nmos[4][4] = { /* in / 0 1 x z <-control */ /* 0 */ {_z, _0, _x, _x}, /* 1 */ {_z, _1, _x, _x}, @@ -204,8 +185,7 @@ _static_unused(l_rnmos) _static_unused(l_nmos) // see table 5-21 p:54 IEEE 1364-2005 - constexpr bit_value_t l_ternary[4][4] - = { + constexpr bit_value_t l_ternary[4][4] = { /* in / 0 1 x z <-control */ /* 0 */ {_0, _x, _x, _x}, /* 1 */ {_x, _1, _x, _x}, @@ -217,8 +197,7 @@ _static_unused(l_ternary) * these extend the library and simplify the process */ /* helper */ - constexpr bit_value_t l_unk[4][4] - = { + constexpr bit_value_t l_unk[4][4] = { /* in / 0 1 x z <-control */ /* 0 */ {_x, _x, _x, _x}, /* 1 */ {_x, _x, _x, _x}, @@ -226,8 +205,7 @@ _static_unused(l_ternary) /* z */ {_x, _x, _x, _x}}; _static_unused(l_unk) - constexpr bit_value_t l_case_eq[4][4] - = { + constexpr bit_value_t l_case_eq[4][4] = { /* a / 0 1 x z <-b */ /* 0 */ {_1, _0, _0, _0}, /* 1 */ {_0, _1, _0, _0}, @@ -235,8 +213,7 @@ _static_unused(l_unk) /* z */ {_0, _0, _0, _1}}; _static_unused(l_case_eq) - constexpr bit_value_t l_lt[4][4] - = { + constexpr bit_value_t l_lt[4][4] = { /* a / 0 1 x z <-b */ /* 0 */ {_0, _1, _x, _x}, /* 1 */ {_0, _0, _x, _x}, @@ -244,8 +221,7 @@ _static_unused(l_case_eq) /* z */ {_x, _x, _x, _x}}; _static_unused(l_lt) - constexpr bit_value_t l_gt[4][4] - = { + constexpr bit_value_t l_gt[4][4] = { /* a / 0 1 x z <-b */ /* 0 */ {_0, _0, _x, _x}, /* 1 */ {_1, _0, _x, _x}, @@ -253,12 +229,10 @@ _static_unused(l_lt) /* z */ {_x, _x, _x, _x}}; _static_unused(l_gt) - constexpr bit_value_t l_eq[4][4] - = unroll_2d(l_xnor); + constexpr bit_value_t l_eq[4][4] = unroll_2d(l_xnor); _static_unused(l_eq) - constexpr bit_value_t l_sum[4][4][4] - = { + constexpr bit_value_t l_sum[4][4][4] = { /* c_in */ /* 0 */ unroll_2d(l_xor), /* 1 */ unroll_2d(l_xnor), @@ -266,8 +240,7 @@ _static_unused(l_eq) /* z */ unroll_2d(l_unk)}; _static_unused(l_sum) - constexpr bit_value_t l_carry[4][4][4] - = { + constexpr bit_value_t l_carry[4][4][4] = { /* c_in */ /* 0 */ unroll_2d(l_and), /* 1 */ unroll_2d(l_or), @@ -275,12 +248,10 @@ _static_unused(l_sum) /* z */ unroll_2d(l_ternary)}; _static_unused(l_carry) - constexpr bit_value_t l_half_carry[4][4] - = unroll_2d(l_carry[_0]); + constexpr bit_value_t l_half_carry[4][4] = unroll_2d(l_carry[_0]); _static_unused(l_half_carry) - constexpr bit_value_t l_half_sum[4][4] - = unroll_2d(l_sum[_0]); + constexpr bit_value_t l_half_sum[4][4] = unroll_2d(l_sum[_0]); _static_unused(l_half_sum) static char bit_to_c(bit_value_t bit, bool uppercase) { diff --git a/libs/libvtrutil/src/tl_optional.hpp b/libs/libvtrutil/src/tl_optional.hpp index f3fc6244b6e..31e66738d04 100644 --- a/libs/libvtrutil/src/tl_optional.hpp +++ b/libs/libvtrutil/src/tl_optional.hpp @@ -505,8 +505,7 @@ struct optional_copy_assign_base : optional_move_base { return *this; } optional_copy_assign_base& - operator=(optional_copy_assign_base&& rhs) - = default; + operator=(optional_copy_assign_base&& rhs) = default; }; // This class manages conditionally having a trivial move assignment operator @@ -534,8 +533,7 @@ struct optional_move_assign_base : optional_copy_assign_base { optional_move_assign_base(optional_move_assign_base&& rhs) = default; optional_move_assign_base& - operator=(const optional_move_assign_base& rhs) - = default; + operator=(const optional_move_assign_base& rhs) = default; optional_move_assign_base& operator=(optional_move_assign_base&& rhs) noexcept( @@ -553,8 +551,7 @@ struct optional_delete_ctor_base { optional_delete_ctor_base(const optional_delete_ctor_base&) = default; optional_delete_ctor_base(optional_delete_ctor_base&&) noexcept = default; optional_delete_ctor_base& - operator=(const optional_delete_ctor_base&) - = default; + operator=(const optional_delete_ctor_base&) = default; optional_delete_ctor_base& operator=(optional_delete_ctor_base&&) noexcept = default; }; @@ -565,8 +562,7 @@ struct optional_delete_ctor_base { optional_delete_ctor_base(const optional_delete_ctor_base&) = default; optional_delete_ctor_base(optional_delete_ctor_base&&) noexcept = delete; optional_delete_ctor_base& - operator=(const optional_delete_ctor_base&) - = default; + operator=(const optional_delete_ctor_base&) = default; optional_delete_ctor_base& operator=(optional_delete_ctor_base&&) noexcept = default; }; @@ -577,8 +573,7 @@ struct optional_delete_ctor_base { optional_delete_ctor_base(const optional_delete_ctor_base&) = delete; optional_delete_ctor_base(optional_delete_ctor_base&&) noexcept = default; optional_delete_ctor_base& - operator=(const optional_delete_ctor_base&) - = default; + operator=(const optional_delete_ctor_base&) = default; optional_delete_ctor_base& operator=(optional_delete_ctor_base&&) noexcept = default; }; @@ -589,8 +584,7 @@ struct optional_delete_ctor_base { optional_delete_ctor_base(const optional_delete_ctor_base&) = delete; optional_delete_ctor_base(optional_delete_ctor_base&&) noexcept = delete; optional_delete_ctor_base& - operator=(const optional_delete_ctor_base&) - = default; + operator=(const optional_delete_ctor_base&) = default; optional_delete_ctor_base& operator=(optional_delete_ctor_base&&) noexcept = default; }; @@ -605,8 +599,7 @@ struct optional_delete_assign_base { optional_delete_assign_base(const optional_delete_assign_base&) = default; optional_delete_assign_base(optional_delete_assign_base&&) noexcept = default; optional_delete_assign_base& - operator=(const optional_delete_assign_base&) - = default; + operator=(const optional_delete_assign_base&) = default; optional_delete_assign_base& operator=(optional_delete_assign_base&&) noexcept = default; }; @@ -617,8 +610,7 @@ struct optional_delete_assign_base { optional_delete_assign_base(const optional_delete_assign_base&) = default; optional_delete_assign_base(optional_delete_assign_base&&) noexcept = default; optional_delete_assign_base& - operator=(const optional_delete_assign_base&) - = default; + operator=(const optional_delete_assign_base&) = default; optional_delete_assign_base& operator=(optional_delete_assign_base&&) noexcept = delete; }; @@ -629,8 +621,7 @@ struct optional_delete_assign_base { optional_delete_assign_base(const optional_delete_assign_base&) = default; optional_delete_assign_base(optional_delete_assign_base&&) noexcept = default; optional_delete_assign_base& - operator=(const optional_delete_assign_base&) - = delete; + operator=(const optional_delete_assign_base&) = delete; optional_delete_assign_base& operator=(optional_delete_assign_base&&) noexcept = default; }; @@ -641,8 +632,7 @@ struct optional_delete_assign_base { optional_delete_assign_base(const optional_delete_assign_base&) = default; optional_delete_assign_base(optional_delete_assign_base&&) noexcept = default; optional_delete_assign_base& - operator=(const optional_delete_assign_base&) - = delete; + operator=(const optional_delete_assign_base&) = delete; optional_delete_assign_base& operator=(optional_delete_assign_base&&) noexcept = delete; }; diff --git a/libs/libvtrutil/src/vtr_prefix_sum.h b/libs/libvtrutil/src/vtr_prefix_sum.h index dce04feecf4..5f4c744563c 100644 --- a/libs/libvtrutil/src/vtr_prefix_sum.h +++ b/libs/libvtrutil/src/vtr_prefix_sum.h @@ -219,7 +219,7 @@ class PrefixSum2D { prefix_sum_[x - 1][y - 1]; } } - } + } /** * @brief Constructs a 2D prefix sum from a 2D grid of values. diff --git a/odin_ii/src/ast/ast_util.cpp b/odin_ii/src/ast/ast_util.cpp index f60759b6ae9..cff0a438ca7 100644 --- a/odin_ii/src/ast/ast_util.cpp +++ b/odin_ii/src/ast/ast_util.cpp @@ -113,8 +113,7 @@ void add_top_module_to_ast(ast_t* ast, ast_node_t* to_add) { oassert(ast); if (to_add) { ast->top_modules_count += 1; - ast->top_modules - = (ast_node_t**)vtr::realloc(ast->top_modules, sizeof(ast_node_t*) * ast->top_modules_count); + ast->top_modules = (ast_node_t**)vtr::realloc(ast->top_modules, sizeof(ast_node_t*) * ast->top_modules_count); ast->top_modules[ast->top_modules_count - 1] = to_add; } diff --git a/vpr/src/analytical_place/partial_legalizer.cpp b/vpr/src/analytical_place/partial_legalizer.cpp index 072cd8ebd19..27bb6649548 100644 --- a/vpr/src/analytical_place/partial_legalizer.cpp +++ b/vpr/src/analytical_place/partial_legalizer.cpp @@ -86,8 +86,8 @@ static inline size_t get_num_models() { * the tile graph. Corners do not count. */ static std::unordered_set get_direct_neighbors_of_bin( - FlatPlacementBinId bin_id, - const FlatPlacementDensityManager& density_manager) { + FlatPlacementBinId bin_id, + const FlatPlacementDensityManager& density_manager) { const vtr::Rect& bin_region = density_manager.flat_placement_bins().bin_region(bin_id); int bl_x = bin_region.bottom_left().x(); int bl_y = bin_region.bottom_left().y(); @@ -202,7 +202,7 @@ void FlowBasedLegalizer::compute_neighbors_of_bin(FlatPlacementBinId src_bin_id, // Perform the BFS from the source node until all nodes have been explored // or all of the models have been found in all directions. - while(!q.empty() && !all_models_found_in_all_directions) { + while (!q.empty() && !all_models_found_in_all_directions) { // Pop the bin from the queue. FlatPlacementBinId bin_id = q.front(); q.pop(); @@ -262,9 +262,9 @@ void FlowBasedLegalizer::compute_neighbors_of_bin(FlatPlacementBinId src_bin_id, FlowBasedLegalizer::FlowBasedLegalizer(const APNetlist& netlist, std::shared_ptr density_manager, int log_verbosity) - : PartialLegalizer(netlist, log_verbosity) - , density_manager_(density_manager) - , bin_neighbors_(density_manager_->flat_placement_bins().bins().size()) { + : PartialLegalizer(netlist, log_verbosity) + , density_manager_(density_manager) + , bin_neighbors_(density_manager_->flat_placement_bins().bins().size()) { // Connect the bins. size_t num_models = get_num_models(); @@ -312,11 +312,11 @@ static inline float computeMaxMovement(size_t iter) { * @return A pair of the minimum cost moveable block and its cost. */ static inline std::pair get_min_cost_block_in_bin( - FlatPlacementBinId src_bin, - FlatPlacementBinId target_bin, - const PartialPlacement& p_placement, - const APNetlist& netlist, - const FlatPlacementDensityManager& density_manager) { + FlatPlacementBinId src_bin, + FlatPlacementBinId target_bin, + const PartialPlacement& p_placement, + const APNetlist& netlist, + const FlatPlacementDensityManager& density_manager) { // Get the min cost block and its cost. APBlockId min_cost_block; float min_cost = std::numeric_limits::infinity(); @@ -410,9 +410,9 @@ static inline float compute_cost(FlatPlacementBinId src_bin, } std::vector> FlowBasedLegalizer::get_paths( - FlatPlacementBinId src_bin_id, - const PartialPlacement& p_placement, - float psi) { + FlatPlacementBinId src_bin_id, + const PartialPlacement& p_placement, + float psi) { VTR_LOGV(log_verbosity_ >= 20, "\tGetting paths...\n"); const FlatPlacementBins& flat_placement_bins = density_manager_->flat_placement_bins(); size_t num_bins = flat_placement_bins.bins().size(); @@ -495,9 +495,9 @@ std::vector> FlowBasedLegalizer::get_paths( // Helpful debug messages. VTR_LOGV(log_verbosity_ >= 20, "\t\tSupply of source bin: %.2f\n", - starting_bin_supply.manhattan_norm()); + starting_bin_supply.manhattan_norm()); VTR_LOGV(log_verbosity_ >= 20, "\t\tDemand of all paths from source: %.2f\n", - starting_bin_supply.manhattan_norm()); + starting_bin_supply.manhattan_norm()); // Sort the paths in increasing order of cost. std::sort(paths.begin(), paths.end(), [&](const std::vector& a, @@ -594,7 +594,7 @@ static void print_flow_based_legalizer_status(size_t iteration, fflush(stdout); } -void FlowBasedLegalizer::legalize(PartialPlacement &p_placement) { +void FlowBasedLegalizer::legalize(PartialPlacement& p_placement) { VTR_LOGV(log_verbosity_ >= 10, "Running Flow-Based Legalizer\n"); // Reset the bins from the previous iteration and prepare for this iteration. @@ -675,10 +675,10 @@ void FlowBasedLegalizer::legalize(PartialPlacement &p_placement) { if (log_verbosity_ >= 10) { // TODO: Get the total cell displacement for debugging. print_flow_based_legalizer_status( - flowBasedIter, - overfilled_bins_vec.size(), - get_bin_supply(overfilled_bins_vec.back()).manhattan_norm(), - psi); + flowBasedIter, + overfilled_bins_vec.size(), + get_bin_supply(overfilled_bins_vec.back()).manhattan_norm(), + psi); } // Increment the iteration. @@ -824,9 +824,9 @@ static std::vector identify_non_overlapping_windows( region.ymax() - 1); float region_utilization = utilization_prefix_sum.get_sum(region.xmin(), - region.ymin(), - region.xmax() - 1, - region.ymax() - 1); + region.ymin(), + region.xmax() - 1, + region.ymax() - 1); if (region_utilization < region_capacity) break; } diff --git a/vpr/src/base/read_options.cpp b/vpr/src/base/read_options.cpp index 77f9c5dab47..e14b32e0295 100644 --- a/vpr/src/base/read_options.cpp +++ b/vpr/src/base/read_options.cpp @@ -2603,23 +2603,22 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio route_grp.add_argument(args.router_opt_choke_points, "--router_opt_choke_points") .help( "" - "Some FPGA architectures with limited fan-out options within a cluster (e.g. fracturable LUTs with shared pins) do" - " not converge well in routing unless these fan-out choke points are discovered and optimized for during net routing." + "Some FPGA architectures with limited fan-out options within a cluster (e.g. fracturable LUTs with shared pins) do" + " not converge well in routing unless these fan-out choke points are discovered and optimized for during net routing." " This option helps router convergence for such architectures.") .default_value("on") .show_in(argparse::ShowIn::HELP_ONLY); - route_grp.add_argument(args.route_verbosity, "--route_verbosity") .help("Controls the verbosity of routing's output. Higher values produce more output (useful for debugging routing problems)") .default_value("1") .show_in(argparse::ShowIn::HELP_ONLY); route_grp.add_argument(args.custom_3d_sb_fanin_fanout, "--custom_3d_sb_fanin_fanout") - .help( - "Specifies the number of tracks that can drive a 3D switch block connection" - "and the number of tracks that can be driven by a 3D switch block connection") - .default_value("1") - .show_in(argparse::ShowIn::HELP_ONLY); + .help( + "Specifies the number of tracks that can drive a 3D switch block connection" + "and the number of tracks that can be driven by a 3D switch block connection") + .default_value("1") + .show_in(argparse::ShowIn::HELP_ONLY); auto& route_timing_grp = parser.add_argument_group("timing-driven routing options"); @@ -3029,13 +3028,13 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio .default_value("0.25") .show_in(argparse::ShowIn::HELP_ONLY); - noc_grp.add_argument(args.noc_centroid_weight, "--noc_centroid_weight") + noc_grp.add_argument(args.noc_centroid_weight, "--noc_centroid_weight") .help( "Sets the minimum fraction of swaps attempted by the placer that are NoC blocks." "This value is an integer ranging from 0-100. 0 means NoC blocks will be moved at the same rate as other blocks. 100 means all swaps attempted by the placer are NoC router blocks.") .default_value("0") .show_in(argparse::ShowIn::HELP_ONLY); - + noc_grp.add_argument(args.noc_swap_percentage, "--noc_swap_percentage") .help( "Sets the minimum fraction of swaps attempted by the placer that are NoC blocks. " @@ -3088,7 +3087,7 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio server_grp.add_argument(args.is_server_mode_enabled, "--server") .help("Run in server mode." - "Accept client application connection and respond to requests." ) + "Accept client application connection and respond to requests.") .action(argparse::Action::STORE_TRUE) .default_value("off"); diff --git a/vpr/src/base/read_place.cpp b/vpr/src/base/read_place.cpp index bc751c5ab29..2c46c216b40 100644 --- a/vpr/src/base/read_place.cpp +++ b/vpr/src/base/read_place.cpp @@ -308,8 +308,8 @@ static std::string read_place_body(std::ifstream& placement_file, const t_pl_loc& constraint_loc = block_locs[blk_id].loc; if (loc != constraint_loc) { VPR_THROW(VPR_ERROR_PLACE, - "The new location assigned to cluster #%d is (%d,%d,%d,%d), which is inconsistent with the location specified in the constraint file (%d,%d,%d,%d).", - blk_id, loc.x, loc.y, loc.layer, loc.sub_tile, constraint_loc.x, constraint_loc.y, constraint_loc.layer, constraint_loc.sub_tile); + "The new location assigned to cluster #%d is (%d,%d,%d,%d), which is inconsistent with the location specified in the constraint file (%d,%d,%d,%d).", + blk_id, loc.x, loc.y, loc.layer, loc.sub_tile, constraint_loc.x, constraint_loc.y, constraint_loc.layer, constraint_loc.sub_tile); } } blk_loc_registry.set_block_location(blk_id, loc); diff --git a/vpr/src/base/vpr_api.cpp b/vpr/src/base/vpr_api.cpp index b39a8072f3a..4c3d7df4058 100644 --- a/vpr/src/base/vpr_api.cpp +++ b/vpr/src/base/vpr_api.cpp @@ -94,9 +94,9 @@ #include "load_flat_place.h" #ifdef VPR_USE_TBB -# define TBB_PREVIEW_GLOBAL_CONTROL 1 /* Needed for compatibility with old TBB versions */ -# include -# include +#define TBB_PREVIEW_GLOBAL_CONTROL 1 /* Needed for compatibility with old TBB versions */ +#include +#include #endif #ifndef NO_SERVER @@ -405,8 +405,7 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) { { // Analytical Place if (vpr_setup.APOpts.doAP == STAGE_DO) { // Passing flat placement input if provided and not loaded yet. - if (!vpr_setup.FileNameOpts.read_flat_place_file.empty() && - !g_vpr_ctx.atom().flat_placement_info().valid) { + if (!vpr_setup.FileNameOpts.read_flat_place_file.empty() && !g_vpr_ctx.atom().flat_placement_info().valid) { g_vpr_ctx.mutable_atom().mutable_flat_placement_info() = read_flat_placement( vpr_setup.FileNameOpts.read_flat_place_file, g_vpr_ctx.atom().netlist()); @@ -419,9 +418,9 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) { // flow if the option is specified. if (!vpr_setup.FileNameOpts.write_flat_place_file.empty()) { write_flat_placement(vpr_setup.FileNameOpts.write_flat_place_file.c_str(), - g_vpr_ctx.clustering().clb_nlist, - g_vpr_ctx.placement().block_locs(), - g_vpr_ctx.clustering().atoms_lookup); + g_vpr_ctx.clustering().clb_nlist, + g_vpr_ctx.placement().block_locs(), + g_vpr_ctx.clustering().atoms_lookup); } } // Print the placement generated by AP to a .place file. @@ -655,8 +654,7 @@ bool vpr_pack(t_vpr_setup& vpr_setup, const t_arch& arch) { // Read in the flat placement if a flat placement file is provided and it // has not been loaded already. - if (!vpr_setup.FileNameOpts.read_flat_place_file.empty() && - !g_vpr_ctx.atom().flat_placement_info().valid) { + if (!vpr_setup.FileNameOpts.read_flat_place_file.empty() && !g_vpr_ctx.atom().flat_placement_info().valid) { g_vpr_ctx.mutable_atom().mutable_flat_placement_info() = read_flat_placement( vpr_setup.FileNameOpts.read_flat_place_file, g_vpr_ctx.atom().netlist()); @@ -1409,8 +1407,8 @@ bool vpr_analysis_flow(const Netlist<>& net_list, std::string post_routing_packing_output_file_name = vpr_setup.PackerOpts.output_file + ".post_routing"; write_packing_results_to_xml(vpr_setup.PackerOpts.global_clocks, - Arch.architecture_id, - post_routing_packing_output_file_name.c_str()); + Arch.architecture_id, + post_routing_packing_output_file_name.c_str()); } else { VTR_LOG_WARN("Synchronization between packing and routing results is not applied due to illegal circuit implementation\n"); } diff --git a/vpr/src/noc/noc_storage.cpp b/vpr/src/noc/noc_storage.cpp index fec0ebec200..4cf62e8b173 100644 --- a/vpr/src/noc/noc_storage.cpp +++ b/vpr/src/noc/noc_storage.cpp @@ -184,9 +184,9 @@ bool NocStorage::remove_link(NocRouterId src_router_id, NocRouterId sink_router_ if (it == source_router_outgoing_links.end()) { VTR_LOG_WARN("No link could be found among outgoing links of source router with id(%d) " - "that that connects to the sink router with id (%d).\n", - (size_t)src_router_id, - (size_t)sink_router_id); + "that that connects to the sink router with id (%d).\n", + (size_t)src_router_id, + (size_t)sink_router_id); } source_router_outgoing_links.erase(it, source_router_outgoing_links.end()); @@ -197,9 +197,9 @@ bool NocStorage::remove_link(NocRouterId src_router_id, NocRouterId sink_router_ if (it == sink_router_incoming_links.end()) { VTR_LOG_WARN("No link could be found among incoming links of sink router with id(%d) " - "that that connects to the source router with id (%d).\n", - (size_t)sink_router_id, - (size_t)src_router_id); + "that that connects to the source router with id (%d).\n", + (size_t)sink_router_id, + (size_t)src_router_id); } sink_router_incoming_links.erase(it, sink_router_incoming_links.end()); diff --git a/vpr/src/pack/cluster_feasibility_filter.cpp b/vpr/src/pack/cluster_feasibility_filter.cpp index c8ecb987f00..dec597aa41e 100644 --- a/vpr/src/pack/cluster_feasibility_filter.cpp +++ b/vpr/src/pack/cluster_feasibility_filter.cpp @@ -333,16 +333,14 @@ static void expand_pb_graph_node_and_load_output_to_input_connections(t_pb_graph reference_pin->list_of_connectable_input_pin_ptrs[depth][i] = temp[i]; reference_pin->list_of_connectable_input_pin_ptrs[depth][reference_pin->num_connectable_primitive_input_pins[depth] - - 1] - = current_pb_graph_pin; + - 1] = current_pb_graph_pin; } else { reference_pin->list_of_connectable_input_pin_ptrs[depth] = new t_pb_graph_pin*[reference_pin->num_connectable_primitive_input_pins[depth]]; } reference_pin->list_of_connectable_input_pin_ptrs[depth][reference_pin->num_connectable_primitive_input_pins[depth] - - 1] - = current_pb_graph_pin; + - 1] = current_pb_graph_pin; } } } diff --git a/vpr/src/pack/pack.cpp b/vpr/src/pack/pack.cpp index f4a7985afec..902f766be2c 100644 --- a/vpr/src/pack/pack.cpp +++ b/vpr/src/pack/pack.cpp @@ -43,8 +43,10 @@ static void get_intercluster_switch_fanin_estimates(const t_arch& arch, int* wire_switch_fanin, int* ipin_switch_fanin); -static float get_arch_switch_info(short switch_index, int switch_fanin, - float& Tdel_switch, float& R_switch, +static float get_arch_switch_info(short switch_index, + int switch_fanin, + float& Tdel_switch, + float& R_switch, float& Cout_switch); static float approximate_inter_cluster_delay(const t_arch& arch, @@ -330,7 +332,11 @@ bool try_pack(t_packer_opts* packer_opts, return true; } -static float get_arch_switch_info(short switch_index, int switch_fanin, float& Tdel_switch, float& R_switch, float& Cout_switch) { +static float get_arch_switch_info(short switch_index, + int switch_fanin, + float& Tdel_switch, + float& R_switch, + float& Cout_switch) { /* Fetches delay, resistance and output capacitance of the architecture switch at switch_index. * Returns the total delay through the switch. Used to calculate inter-cluster net delay. */ @@ -546,4 +552,3 @@ static float approximate_inter_cluster_delay(const t_arch& arch, /* multiply by 4 to get a more conservative estimate */ return 4 * (first_wire_seg_delay + second_wire_seg_delay + wtoi_switch_del); } - diff --git a/vpr/src/place/compressed_grid.h b/vpr/src/place/compressed_grid.h index 83a78a76291..6f9575fb670 100644 --- a/vpr/src/place/compressed_grid.h +++ b/vpr/src/place/compressed_grid.h @@ -143,8 +143,7 @@ struct t_compressed_block_grid { int dist_prev = loc - *(itr - 1); int dist_next = *itr - loc; VTR_ASSERT_DEBUG(dist_prev >= 0 && dist_next >= 0); - return (dist_prev <= dist_next) ? (std::distance(compressed_grid_dim.begin(), itr - 1)) : - (std::distance(compressed_grid_dim.begin(), itr)); + return (dist_prev <= dist_next) ? (std::distance(compressed_grid_dim.begin(), itr - 1)) : (std::distance(compressed_grid_dim.begin(), itr)); } }; diff --git a/vpr/src/place/delay_model/place_delay_model.h b/vpr/src/place/delay_model/place_delay_model.h index 6f542667388..ba22125d712 100644 --- a/vpr/src/place/delay_model/place_delay_model.h +++ b/vpr/src/place/delay_model/place_delay_model.h @@ -48,8 +48,7 @@ class PlaceDelayModel { virtual void compute(RouterDelayProfiler& route_profiler, const t_placer_opts& placer_opts, const t_router_opts& router_opts, - int longest_length) - = 0; + int longest_length) = 0; /** * @brief Returns the delay estimate between the specified block pins. diff --git a/vpr/src/place/move_utils.cpp b/vpr/src/place/move_utils.cpp index e1a4a986cfc..5e941e2f3c1 100644 --- a/vpr/src/place/move_utils.cpp +++ b/vpr/src/place/move_utils.cpp @@ -581,7 +581,7 @@ ClusterBlockId pick_from_block(const int logical_blk_type_index, const BlkLocRegistry& blk_loc_registry) { // if logical block type is specified, pick the 'from' block from blocks of that type; // otherwise, select it randomly from all blocks - const auto& movable_blocks = (logical_blk_type_index < 0 ) ? blk_loc_registry.movable_blocks() : blk_loc_registry.movable_blocks_per_type()[logical_blk_type_index]; + const auto& movable_blocks = (logical_blk_type_index < 0) ? blk_loc_registry.movable_blocks() : blk_loc_registry.movable_blocks_per_type()[logical_blk_type_index]; if (movable_blocks.empty()) { return ClusterBlockId::INVALID(); diff --git a/vpr/src/place/noc_place_utils.cpp b/vpr/src/place/noc_place_utils.cpp index 5716881de21..cb3e80e9429 100644 --- a/vpr/src/place/noc_place_utils.cpp +++ b/vpr/src/place/noc_place_utils.cpp @@ -660,7 +660,6 @@ std::pair calculate_traffic_flow_latency_cost(const std::vector< noc_router_latency_component = noc_router_latency * num_of_routers_in_traffic_flow; } - // calculate the total traffic flow latency double latency = noc_router_latency_component + noc_link_latency_component; @@ -1002,26 +1001,25 @@ void NocCostHandler::print_noc_costs(std::string_view header, const t_placer_costs& costs, const t_noc_opts& noc_opts) const { VTR_LOG("%s. " - "cost: %g, " - "aggregate_bandwidth_cost: %g, " - "latency_cost: %g, " - "n_met_latency_constraints: %d, " - "latency_overrun_cost: %g, " - "congestion_cost: %g, " - "accum_congested_ratio: %g, " - "n_congested_links: %d \n", - header.data(), - calculate_noc_cost(costs.noc_cost_terms, costs.noc_cost_norm_factors, noc_opts), - costs.noc_cost_terms.aggregate_bandwidth, - costs.noc_cost_terms.latency, - get_number_of_traffic_flows_with_latency_cons_met(), - costs.noc_cost_terms.latency_overrun, - costs.noc_cost_terms.congestion, - get_total_congestion_bandwidth_ratio(), - get_number_of_congested_noc_links()); + "cost: %g, " + "aggregate_bandwidth_cost: %g, " + "latency_cost: %g, " + "n_met_latency_constraints: %d, " + "latency_overrun_cost: %g, " + "congestion_cost: %g, " + "accum_congested_ratio: %g, " + "n_congested_links: %d \n", + header.data(), + calculate_noc_cost(costs.noc_cost_terms, costs.noc_cost_norm_factors, noc_opts), + costs.noc_cost_terms.aggregate_bandwidth, + costs.noc_cost_terms.latency, + get_number_of_traffic_flows_with_latency_cons_met(), + costs.noc_cost_terms.latency_overrun, + costs.noc_cost_terms.congestion, + get_total_congestion_bandwidth_ratio(), + get_number_of_congested_noc_links()); } - static std::vector find_affected_links_by_flow_reroute(std::vector& prev_links, std::vector& curr_links) { // Sort both link containers diff --git a/vpr/src/place/place_macro.cpp b/vpr/src/place/place_macro.cpp index 6dda1f7a92c..aa3e361b459 100644 --- a/vpr/src/place/place_macro.cpp +++ b/vpr/src/place/place_macro.cpp @@ -671,8 +671,6 @@ const t_pl_macro& PlaceMacros::operator[](int idx) const { return pl_macros_[idx]; } - - static void validate_macros(const std::vector& macros, const ClusteredNetlist& clb_nlist) { //Perform sanity checks on macros @@ -705,4 +703,3 @@ static void validate_macros(const std::vector& macros, } } } - diff --git a/vpr/src/route/clock_network_builders.h b/vpr/src/route/clock_network_builders.h index f9983cd85e9..2e73fe211c0 100644 --- a/vpr/src/route/clock_network_builders.h +++ b/vpr/src/route/clock_network_builders.h @@ -113,8 +113,7 @@ class ClockNetwork { t_rr_graph_storage* rr_nodes, RRGraphBuilder& rr_graph_builder, t_rr_edge_info_set* rr_edges_to_create, - int num_segments_x) - = 0; + int num_segments_x) = 0; virtual size_t estimate_additional_nodes(const DeviceGrid& grid) = 0; virtual void map_relative_seg_indices(const t_unified_to_parallel_seg_index& index_map) = 0; }; diff --git a/vpr/src/route/connection_router_interface.h b/vpr/src/route/connection_router_interface.h index 62111edc285..96ef278833a 100644 --- a/vpr/src/route/connection_router_interface.h +++ b/vpr/src/route/connection_router_interface.h @@ -59,8 +59,7 @@ class ConnectionRouterInterface { const t_conn_cost_params& cost_params, const t_bb& bounding_box, RouterStats& router_stats, - const ConnectionParameters& conn_params) - = 0; + const ConnectionParameters& conn_params) = 0; /** Finds a path from the route tree rooted at rt_root to sink_node for a * high fanout net. @@ -79,8 +78,7 @@ class ConnectionRouterInterface { const t_bb& bounding_box, const SpatialRouteTreeLookup& spatial_rt_lookup, RouterStats& router_stats, - const ConnectionParameters& conn_params) - = 0; + const ConnectionParameters& conn_params) = 0; // Finds a path from the route tree rooted at rt_root to all sinks // available. @@ -99,8 +97,7 @@ class ConnectionRouterInterface { const t_conn_cost_params& cost_params, const t_bb& bounding_box, RouterStats& router_stats, - const ConnectionParameters& conn_params) - = 0; + const ConnectionParameters& conn_params) = 0; // Sets whether router debug information should be on. virtual void set_router_debug(bool router_debug) = 0; From fafdd07d9fcccaba87ee45c138fd23da96b82731 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Mon, 17 Mar 2025 13:22:23 -0400 Subject: [PATCH 3/9] fix a few issues to be compliant with break before binary operators --- libs/libvtrutil/src/vtr_prefix_sum.h | 42 ++-- vpr/src/analytical_place/ap_netlist.cpp | 11 +- .../analytical_place/partial_legalizer.cpp | 71 +++--- vpr/src/base/load_flat_place.cpp | 36 ++- vpr/src/base/read_place.cpp | 28 +-- vpr/src/base/vpr_api.cpp | 18 +- vpr/src/pack/greedy_candidate_selector.cpp | 222 +++++++++--------- vpr/src/pack/verify_flat_placement.cpp | 22 +- vpr/src/place/noc_place_utils.cpp | 16 +- vpr/src/place/place_macro.cpp | 4 +- vpr/src/timing/read_sdc.cpp | 6 +- vpr/src/util/vpr_utils.cpp | 3 +- 12 files changed, 218 insertions(+), 261 deletions(-) diff --git a/libs/libvtrutil/src/vtr_prefix_sum.h b/libs/libvtrutil/src/vtr_prefix_sum.h index 5f4c744563c..d2a9067e1ae 100644 --- a/libs/libvtrutil/src/vtr_prefix_sum.h +++ b/libs/libvtrutil/src/vtr_prefix_sum.h @@ -94,11 +94,12 @@ class PrefixSum1D { * @brief Construct the 1D prefix sum from a vector. */ PrefixSum1D(std::vector vals, T zero = T()) - : PrefixSum1D(vals.size(), - [&](size_t x) noexcept { - return vals[x]; - }, - zero) {} + : PrefixSum1D( + vals.size(), + [&](size_t x) noexcept { + return vals[x]; + }, + zero) {} /** * @brief Get the sum of all values in the original array of values between @@ -123,7 +124,7 @@ class PrefixSum1D { return prefix_sum_[upper_x + 1] - prefix_sum_[lower_x]; } -private: + private: /** * @brief The 1D prefix sum of the original array of values. * @@ -213,10 +214,10 @@ class PrefixSum2D { // to (x - 1, y - 1) inclusive. for (size_t x = 1; x < w + 1; x++) { for (size_t y = 1; y < h + 1; y++) { - prefix_sum_[x][y] = prefix_sum_[x - 1][y] + - prefix_sum_[x][y - 1] + - lookup(x - 1, y - 1) - - prefix_sum_[x - 1][y - 1]; + prefix_sum_[x][y] = prefix_sum_[x - 1][y] + + prefix_sum_[x][y - 1] + + lookup(x - 1, y - 1) + - prefix_sum_[x - 1][y - 1]; } } } @@ -225,12 +226,13 @@ class PrefixSum2D { * @brief Constructs a 2D prefix sum from a 2D grid of values. */ PrefixSum2D(const vtr::NdMatrix& vals, T zero = T()) - : PrefixSum2D(vals.dim_size(0), - vals.dim_size(1), - [&](size_t x, size_t y) { - return vals[x][y]; - }, - zero) {} + : PrefixSum2D( + vals.dim_size(0), + vals.dim_size(1), + [&](size_t x, size_t y) { + return vals[x][y]; + }, + zero) {} /** * @brief Get the sum of all values in the original grid of values between @@ -261,9 +263,10 @@ class PrefixSum2D { // Note: all of these are offset by 1 since the first row and column // are all zeros. This allows us to avoid bounds checking when // lower_x or lower_y are 0. - return prefix_sum_[upper_x + 1][upper_y + 1] - prefix_sum_[lower_x][upper_y + 1] - - prefix_sum_[upper_x + 1][lower_y] - + prefix_sum_[lower_x][lower_y]; + return prefix_sum_[upper_x + 1][upper_y + 1] + - prefix_sum_[lower_x][upper_y + 1] + - prefix_sum_[upper_x + 1][lower_y] + + prefix_sum_[lower_x][lower_y]; } private: @@ -280,4 +283,3 @@ class PrefixSum2D { }; } // namespace vtr - diff --git a/vpr/src/analytical_place/ap_netlist.cpp b/vpr/src/analytical_place/ap_netlist.cpp index 6a2d55e546e..a2d6cb7773e 100644 --- a/vpr/src/analytical_place/ap_netlist.cpp +++ b/vpr/src/analytical_place/ap_netlist.cpp @@ -59,18 +59,12 @@ void APNetlist::set_block_loc(const APBlockId id, const APFixedBlockLoc& loc) { VTR_ASSERT_SAFE(valid_block_id(id)); // Check that the location is fixed; if all dims are unfixed then it is not fixed. - if (loc.x == APFixedBlockLoc::UNFIXED_DIM && - loc.y == APFixedBlockLoc::UNFIXED_DIM && - loc.sub_tile == APFixedBlockLoc::UNFIXED_DIM && - loc.layer_num == APFixedBlockLoc::UNFIXED_DIM) + if (loc.x == APFixedBlockLoc::UNFIXED_DIM && loc.y == APFixedBlockLoc::UNFIXED_DIM && loc.sub_tile == APFixedBlockLoc::UNFIXED_DIM && loc.layer_num == APFixedBlockLoc::UNFIXED_DIM) return; // Ensure that the block is fixed to a single position on the grid (x, y, layer). // sub-tile is allowed to be unfixed. - VTR_ASSERT(loc.x != APFixedBlockLoc::UNFIXED_DIM && - loc.y != APFixedBlockLoc::UNFIXED_DIM && - loc.layer_num != APFixedBlockLoc::UNFIXED_DIM && - "AP: Currently, AP assumes block is locked down to a single position on the device grid."); + VTR_ASSERT(loc.x != APFixedBlockLoc::UNFIXED_DIM && loc.y != APFixedBlockLoc::UNFIXED_DIM && loc.layer_num != APFixedBlockLoc::UNFIXED_DIM && "AP: Currently, AP assumes block is locked down to a single position on the device grid."); block_locs_[id] = loc; block_mobilities_[id] = APBlockMobility::FIXED; @@ -207,4 +201,3 @@ bool APNetlist::validate_net_sizes_impl(size_t /*num_nets*/) const { // No AP-specific net data to check return true; } - diff --git a/vpr/src/analytical_place/partial_legalizer.cpp b/vpr/src/analytical_place/partial_legalizer.cpp index 27bb6649548..f91f66b74e0 100644 --- a/vpr/src/analytical_place/partial_legalizer.cpp +++ b/vpr/src/analytical_place/partial_legalizer.cpp @@ -97,10 +97,7 @@ static std::unordered_set get_direct_neighbors_of_bin( // the bounding box. We need to ensure that the bin represents a tile (not // part of a tile). If it did represent part of a tile, this algorithm // would need to change. - VTR_ASSERT_DEBUG(static_cast(bl_x) == bin_region.bottom_left().x() && - static_cast(bl_y) == bin_region.bottom_left().y() && - static_cast(bin_width) == bin_region.width() && - static_cast(bin_height) == bin_region.height()); + VTR_ASSERT_DEBUG(static_cast(bl_x) == bin_region.bottom_left().x() && static_cast(bl_y) == bin_region.bottom_left().y() && static_cast(bin_width) == bin_region.width() && static_cast(bin_height) == bin_region.height()); double placeable_region_width, placeable_region_height, placeable_region_depth; std::tie(placeable_region_width, placeable_region_height, placeable_region_depth) = density_manager.get_overall_placeable_region_size(); @@ -251,8 +248,7 @@ void FlowBasedLegalizer::compute_neighbors_of_bin(FlatPlacementBinId src_bin_id, q.push(dir_neighbor_bin_id); } // Check if all of the models have been found in all directions. - all_models_found_in_all_directions = all_up_found && all_down_found && - all_left_found && all_right_found; + all_models_found_in_all_directions = all_up_found && all_down_found && all_left_found && all_right_found; } // Assign the results into the neighbors of the bin. @@ -437,7 +433,7 @@ std::vector> FlowBasedLegalizer::get_paths( const PrimitiveVector& starting_bin_supply = get_bin_supply(src_bin_id); while (!queue.empty() && demand < starting_bin_supply) { // Pop the current bin off the queue. - std::vector &p = queue.front(); + std::vector& p = queue.front(); FlatPlacementBinId tail_bin_id = p.back(); // Look over its neighbors for (FlatPlacementBinId neighbor_bin_id : bin_neighbors_[tail_bin_id]) { @@ -500,8 +496,7 @@ std::vector> FlowBasedLegalizer::get_paths( starting_bin_supply.manhattan_norm()); // Sort the paths in increasing order of cost. - std::sort(paths.begin(), paths.end(), [&](const std::vector& a, - const std::vector& b) { + std::sort(paths.begin(), paths.end(), [&](const std::vector& a, const std::vector& b) { return bin_cost[a.back()] < bin_cost[b.back()]; }); @@ -730,11 +725,11 @@ struct SpreadingWindow { } // namespace BiPartitioningPartialLegalizer::BiPartitioningPartialLegalizer( - const APNetlist& netlist, - std::shared_ptr density_manager, - int log_verbosity) - : PartialLegalizer(netlist, log_verbosity) - , density_manager_(density_manager) {} + const APNetlist& netlist, + std::shared_ptr density_manager, + int log_verbosity) + : PartialLegalizer(netlist, log_verbosity) + , density_manager_(density_manager) {} /** * @brief Identify spreading windows which contain overfilled bins on the device @@ -750,8 +745,8 @@ BiPartitioningPartialLegalizer::BiPartitioningPartialLegalizer( * spreading easier. */ static std::vector identify_non_overlapping_windows( - const APNetlist& netlist, - FlatPlacementDensityManager& density_manager) { + const APNetlist& netlist, + FlatPlacementDensityManager& density_manager) { // Identify overfilled bins const std::unordered_set& overfilled_bins = density_manager.get_overfilled_bins(); @@ -763,27 +758,27 @@ static std::vector identify_non_overlapping_windows( size_t width, height, layers; std::tie(width, height, layers) = density_manager.get_overall_placeable_region_size(); vtr::PrefixSum2D capacity_prefix_sum(width, height, [&](size_t x, size_t y) { - FlatPlacementBinId bin_id = density_manager.get_bin(x, y, 0); - // For now we take the L1 norm of the bin divided by its area. - // The L1 norm is just a count of the number of primitives that - // can fit into the bin (without caring for primitive type). We - // divide by area such that large bins (1x4 for example) get - // normalized to 1x1 regions. - const vtr::Rect& bin_region = density_manager.flat_placement_bins().bin_region(bin_id); - float bin_area = bin_region.width() * bin_region.height(); - return density_manager.get_bin_capacity(bin_id).manhattan_norm() / bin_area; - }); + FlatPlacementBinId bin_id = density_manager.get_bin(x, y, 0); + // For now we take the L1 norm of the bin divided by its area. + // The L1 norm is just a count of the number of primitives that + // can fit into the bin (without caring for primitive type). We + // divide by area such that large bins (1x4 for example) get + // normalized to 1x1 regions. + const vtr::Rect& bin_region = density_manager.flat_placement_bins().bin_region(bin_id); + float bin_area = bin_region.width() * bin_region.height(); + return density_manager.get_bin_capacity(bin_id).manhattan_norm() / bin_area; + }); // Create a prefix sum for the utilization. // The utilization of the bins will change between routing iterations, so // this prefix sum must be recomputed. vtr::PrefixSum2D utilization_prefix_sum(width, height, [&](size_t x, size_t y) { - FlatPlacementBinId bin_id = density_manager.get_bin(x, y, 0); - // This is computed the same way as the capacity prefix sum above. - const vtr::Rect& bin_region = density_manager.flat_placement_bins().bin_region(bin_id); - float bin_area = bin_region.width() * bin_region.height(); - return density_manager.get_bin_utilization(bin_id).manhattan_norm() / bin_area; - }); + FlatPlacementBinId bin_id = density_manager.get_bin(x, y, 0); + // This is computed the same way as the capacity prefix sum above. + const vtr::Rect& bin_region = density_manager.flat_placement_bins().bin_region(bin_id); + float bin_area = bin_region.width() * bin_region.height(); + return density_manager.get_bin_utilization(bin_id).manhattan_norm() / bin_area; + }); // 1) For each of the overfilled bins, create and store a minimum window. // TODO: This is a very simple algorithm which currently only uses the number @@ -808,8 +803,7 @@ static std::vector identify_non_overlapping_windows( // If the region did not grow, exit. This is a maximal bin. // TODO: Maybe print warning. - if (new_xmin == region.xmin() && new_xmax == region.xmax() && - new_ymin == region.ymin() && new_ymax == region.ymax()) { + if (new_xmin == region.xmin() && new_xmax == region.xmax() && new_ymin == region.ymin() && new_ymax == region.ymax()) { break; } @@ -1040,15 +1034,15 @@ void BiPartitioningPartialLegalizer::legalize(PartialPlacement& p_placement) { if (partition_dir == e_partition_dir::VERTICAL) { // Sort the blocks in the window by the x coordinate. std::sort(window.contained_blocks.begin(), window.contained_blocks.end(), [&](APBlockId a, APBlockId b) { - return p_placement.block_x_locs[a] < p_placement.block_x_locs[b]; - }); + return p_placement.block_x_locs[a] < p_placement.block_x_locs[b]; + }); } else { VTR_ASSERT(partition_dir == e_partition_dir::HORIZONTAL); // Sort the blocks in the window by the y coordinate. std::sort(window.contained_blocks.begin(), window.contained_blocks.end(), [&](APBlockId a, APBlockId b) { - return p_placement.block_y_locs[a] < p_placement.block_y_locs[b]; - }); + return p_placement.block_y_locs[a] < p_placement.block_y_locs[b]; + }); } // Find the pivot block position. @@ -1092,4 +1086,3 @@ void BiPartitioningPartialLegalizer::legalize(PartialPlacement& p_placement) { // Export the legalized placement to the partial placement. density_manager_->export_placement_from_bins(p_placement); } - diff --git a/vpr/src/base/load_flat_place.cpp b/vpr/src/base/load_flat_place.cpp index 0e77c9b9192..e651f38f879 100644 --- a/vpr/src/base/load_flat_place.cpp +++ b/vpr/src/base/load_flat_place.cpp @@ -159,8 +159,8 @@ FlatPlacementInfo read_flat_placement(const std::string& read_flat_place_file_pa // Check if this atom already has a flat placement // Using the x_pos and y_pos as identifiers. - if (flat_placement_info.blk_x_pos[atom_blk_id] != FlatPlacementInfo::UNDEFINED_POS || - flat_placement_info.blk_y_pos[atom_blk_id] != FlatPlacementInfo::UNDEFINED_POS) { + if (flat_placement_info.blk_x_pos[atom_blk_id] != FlatPlacementInfo::UNDEFINED_POS + || flat_placement_info.blk_y_pos[atom_blk_id] != FlatPlacementInfo::UNDEFINED_POS) { VTR_LOG_WARN("Flat placement file, line %d, atom %s has multiple " "placement definitions in the flat placement file.\n", line_num, atom_netlist.block_name(atom_blk_id).c_str()); @@ -202,12 +202,12 @@ bool load_flat_placement(t_vpr_setup& vpr_setup, const t_arch& arch) { } void log_flat_placement_reconstruction_info( - const FlatPlacementInfo& flat_placement_info, - const vtr::vector_map& block_locs, - const vtr::vector>& atoms_lookup, - const AtomLookup& cluster_of_atom_lookup, - const AtomNetlist& atom_netlist, - const ClusteredNetlist& clustered_netlist) { + const FlatPlacementInfo& flat_placement_info, + const vtr::vector_map& block_locs, + const vtr::vector>& atoms_lookup, + const AtomLookup& cluster_of_atom_lookup, + const AtomNetlist& atom_netlist, + const ClusteredNetlist& clustered_netlist) { // Go through each cluster and see how many clusters have atoms that // do not belong (cluster is imperfect). unsigned num_imperfect_clusters = 0; @@ -243,10 +243,7 @@ void log_flat_placement_reconstruction_info( // want to be in this cluster. // FIXME: This should take into account large blocks somehow, just // being 0.5 tiles away may not be sufficient. - if (std::abs(centroid_x - flat_placement_info.blk_x_pos[atom_blk_id]) > 0.5f || - std::abs(centroid_y - flat_placement_info.blk_y_pos[atom_blk_id]) > 0.5f || - std::abs(centroid_layer - flat_placement_info.blk_layer[atom_blk_id]) > 0.5f || - std::abs(centroid_sub_tile - flat_placement_info.blk_sub_tile[atom_blk_id]) > 0.5f) { + if (std::abs(centroid_x - flat_placement_info.blk_x_pos[atom_blk_id]) > 0.5f || std::abs(centroid_y - flat_placement_info.blk_y_pos[atom_blk_id]) > 0.5f || std::abs(centroid_layer - flat_placement_info.blk_layer[atom_blk_id]) > 0.5f || std::abs(centroid_sub_tile - flat_placement_info.blk_sub_tile[atom_blk_id]) > 0.5f) { num_imperfect_clusters++; break; } @@ -298,13 +295,13 @@ void log_flat_placement_reconstruction_info( // TODO: Make this debug option of higher verbosity. Helpful for // debugging flat placement reconstruction. /* - VTR_LOG("%s %d %d %d %d\n", - g_vpr_ctx.atom().netlist().block_name(atom_blk_id).c_str(), - clb_loc.loc.x, - clb_loc.loc.y, - clb_loc.loc.layer, - clb_loc.loc.sub_tile); - */ + * VTR_LOG("%s %d %d %d %d\n", + * g_vpr_ctx.atom().netlist().block_name(atom_blk_id).c_str(), + * clb_loc.loc.x, + * clb_loc.loc.y, + * clb_loc.loc.layer, + * clb_loc.loc.sub_tile); + */ } // Log the flat placement reconstruction info. @@ -322,4 +319,3 @@ void log_flat_placement_reconstruction_info( VTR_LOG("\tPercent of atoms misplaced from the flat placement: %f\n", static_cast(num_atoms_missplaced) / static_cast(num_atoms)); } - diff --git a/vpr/src/base/read_place.cpp b/vpr/src/base/read_place.cpp index 2c46c216b40..258fc05ed96 100644 --- a/vpr/src/base/read_place.cpp +++ b/vpr/src/base/read_place.cpp @@ -140,12 +140,12 @@ static void read_place_header(std::ifstream& placement_file, seen_netlist_id = true; - } else if (tokens.size() == 7 && - tokens[0] == "Array" && - tokens[1] == "size:" && - tokens[3] == "x" && - tokens[5] == "logic" && - tokens[6] == "blocks") { + } else if (tokens.size() == 7 + && tokens[0] == "Array" + && tokens[1] == "size:" + && tokens[3] == "x" + && tokens[5] == "logic" + && tokens[6] == "blocks") { //Load the device grid dimensions size_t place_file_width = vtr::atou(tokens[2]); @@ -182,8 +182,8 @@ static void read_place_header(std::ifstream& placement_file, "--verify_file_digests command line option is off."); } - if ((tokens.size() == 4 || (tokens.size() > 4 && tokens[4][0] == '#')) || - (tokens.size() == 5 || (tokens.size() > 5 && tokens[5][0] == '#'))) { + if ((tokens.size() == 4|| (tokens.size() > 4 && tokens[4][0] == '#')) + || (tokens.size() == 5 || (tokens.size() > 5 && tokens[5][0] == '#'))) { placement_file.seekg(file_pos); break; } @@ -234,8 +234,8 @@ static std::string read_place_body(std::ifstream& placement_file, } else if (tokens[0][0] == '#') { continue; //Skip commented lines - } else if ((tokens.size() == 4 || (tokens.size() > 4 && tokens[4][0] == '#')) || - (tokens.size() == 5 || (tokens.size() > 5 && tokens[5][0] == '#'))) { + } else if ((tokens.size() == 4 || (tokens.size() > 4 && tokens[4][0] == '#')) + || (tokens.size() == 5 || (tokens.size() > 5 && tokens[5][0] == '#'))) { //Load the block location // // If the place file corresponds to a 3D architecture, it should contain 5 tokens of actual data, with an optional 6th (commented) token indicating VPR's internal block number. @@ -285,10 +285,10 @@ static std::string read_place_body(std::ifstream& placement_file, //Check if block is listed multiple times with conflicting locations in constraints file if (seen_blocks[blk_id] > 0) { - if (block_x != block_locs[blk_id].loc.x || - block_y != block_locs[blk_id].loc.y || - sub_tile_index != block_locs[blk_id].loc.sub_tile || - block_layer != block_locs[blk_id].loc.layer) { + if (block_x != block_locs[blk_id].loc.x + || block_y != block_locs[blk_id].loc.y + || sub_tile_index != block_locs[blk_id].loc.sub_tile + || block_layer != block_locs[blk_id].loc.layer) { std::string cluster_name = cluster_ctx.clb_nlist.block_name(blk_id); VPR_THROW(VPR_ERROR_PLACE, "The location of cluster %s (#%d) is specified %d times in the constraints file with conflicting locations. \n" diff --git a/vpr/src/base/vpr_api.cpp b/vpr/src/base/vpr_api.cpp index 4c3d7df4058..cd62b697e05 100644 --- a/vpr/src/base/vpr_api.cpp +++ b/vpr/src/base/vpr_api.cpp @@ -406,9 +406,8 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) { if (vpr_setup.APOpts.doAP == STAGE_DO) { // Passing flat placement input if provided and not loaded yet. if (!vpr_setup.FileNameOpts.read_flat_place_file.empty() && !g_vpr_ctx.atom().flat_placement_info().valid) { - g_vpr_ctx.mutable_atom().mutable_flat_placement_info() = read_flat_placement( - vpr_setup.FileNameOpts.read_flat_place_file, - g_vpr_ctx.atom().netlist()); + g_vpr_ctx.mutable_atom().mutable_flat_placement_info() = read_flat_placement(vpr_setup.FileNameOpts.read_flat_place_file, + g_vpr_ctx.atom().netlist()); } // TODO: Make this return a bool if the placement was successful or not. @@ -655,9 +654,8 @@ bool vpr_pack(t_vpr_setup& vpr_setup, const t_arch& arch) { // Read in the flat placement if a flat placement file is provided and it // has not been loaded already. if (!vpr_setup.FileNameOpts.read_flat_place_file.empty() && !g_vpr_ctx.atom().flat_placement_info().valid) { - g_vpr_ctx.mutable_atom().mutable_flat_placement_info() = read_flat_placement( - vpr_setup.FileNameOpts.read_flat_place_file, - g_vpr_ctx.atom().netlist()); + g_vpr_ctx.mutable_atom().mutable_flat_placement_info() = read_flat_placement(vpr_setup.FileNameOpts.read_flat_place_file, + g_vpr_ctx.atom().netlist()); } return try_pack(&vpr_setup.PackerOpts, &vpr_setup.AnalysisOpts, @@ -819,11 +817,9 @@ void vpr_place(const Netlist<>& net_list, // Read in the flat placement if a flat placement file is provided and it // has not been loaded already. - if (!vpr_setup.FileNameOpts.read_flat_place_file.empty() && - !g_vpr_ctx.atom().flat_placement_info().valid) { - g_vpr_ctx.mutable_atom().mutable_flat_placement_info() = read_flat_placement( - vpr_setup.FileNameOpts.read_flat_place_file, - g_vpr_ctx.atom().netlist()); + if (!vpr_setup.FileNameOpts.read_flat_place_file.empty() && !g_vpr_ctx.atom().flat_placement_info().valid) { + g_vpr_ctx.mutable_atom().mutable_flat_placement_info() = read_flat_placement(vpr_setup.FileNameOpts.read_flat_place_file, + g_vpr_ctx.atom().netlist()); } try_place(net_list, diff --git a/vpr/src/pack/greedy_candidate_selector.cpp b/vpr/src/pack/greedy_candidate_selector.cpp index f5c9235af2b..78b9005977b 100644 --- a/vpr/src/pack/greedy_candidate_selector.cpp +++ b/vpr/src/pack/greedy_candidate_selector.cpp @@ -46,47 +46,47 @@ static float get_molecule_gain(PackMoleculeId molecule_id, * has been found to be illegal, we don't repeatedly consider it. */ static void remove_molecule_from_pb_stats_candidates( - PackMoleculeId molecule_id, - ClusterGainStats& cluster_gain_stats); + PackMoleculeId molecule_id, + ClusterGainStats& cluster_gain_stats); /* * @brief Add blk to list of feasible blocks sorted according to gain. */ static void add_molecule_to_pb_stats_candidates( - PackMoleculeId molecule_id, - ClusterGainStats& cluster_gain_stats, - int max_queue_size, - AttractionInfo& attraction_groups, - const Prepacker& prepacker, - const AtomNetlist& atom_netlist); + PackMoleculeId molecule_id, + ClusterGainStats& cluster_gain_stats, + int max_queue_size, + AttractionInfo& attraction_groups, + const Prepacker& prepacker, + const AtomNetlist& atom_netlist); GreedyCandidateSelector::GreedyCandidateSelector( - const AtomNetlist& atom_netlist, - const Prepacker& prepacker, - const t_packer_opts& packer_opts, - bool allow_unrelated_clustering, - const t_molecule_stats& max_molecule_stats, - const std::map>& primitive_candidate_block_types, - const t_pack_high_fanout_thresholds& high_fanout_thresholds, - const std::unordered_set& is_clock, - const std::unordered_set& is_global, - const std::unordered_set& net_output_feeds_driving_block_input, - const SetupTimingInfo& timing_info, - const FlatPlacementInfo& flat_placement_info, - int log_verbosity) - : atom_netlist_(atom_netlist), - prepacker_(prepacker), - packer_opts_(packer_opts), - allow_unrelated_clustering_(allow_unrelated_clustering), - log_verbosity_(log_verbosity), - primitive_candidate_block_types_(primitive_candidate_block_types), - high_fanout_thresholds_(high_fanout_thresholds), - is_clock_(is_clock), - is_global_(is_global), - net_output_feeds_driving_block_input_(net_output_feeds_driving_block_input), - timing_info_(timing_info), - flat_placement_info_(flat_placement_info), - rng_(0) { + const AtomNetlist& atom_netlist, + const Prepacker& prepacker, + const t_packer_opts& packer_opts, + bool allow_unrelated_clustering, + const t_molecule_stats& max_molecule_stats, + const std::map>& primitive_candidate_block_types, + const t_pack_high_fanout_thresholds& high_fanout_thresholds, + const std::unordered_set& is_clock, + const std::unordered_set& is_global, + const std::unordered_set& net_output_feeds_driving_block_input, + const SetupTimingInfo& timing_info, + const FlatPlacementInfo& flat_placement_info, + int log_verbosity) + : atom_netlist_(atom_netlist) + , prepacker_(prepacker) + , packer_opts_(packer_opts) + , allow_unrelated_clustering_(allow_unrelated_clustering) + , log_verbosity_(log_verbosity) + , primitive_candidate_block_types_(primitive_candidate_block_types) + , high_fanout_thresholds_(high_fanout_thresholds) + , is_clock_(is_clock) + , is_global_(is_global) + , net_output_feeds_driving_block_input_(net_output_feeds_driving_block_input) + , timing_info_(timing_info) + , flat_placement_info_(flat_placement_info) + , rng_(0) { // Initialize the list of molecules to pack, the clustering data, and the // net info. @@ -147,9 +147,7 @@ GreedyCandidateSelector::GreedyCandidateSelector( // Populate the ND-Matrix with each of the molecules. std::unordered_set seen_molecules; for (AtomBlockId blk_id : atom_netlist_.blocks()) { - VTR_ASSERT(flat_placement_info.blk_x_pos[blk_id] != -1.f && - flat_placement_info.blk_y_pos[blk_id] != -1.f && - flat_placement_info.blk_layer[blk_id] != -1.f); + VTR_ASSERT(flat_placement_info.blk_x_pos[blk_id] != -1.f && flat_placement_info.blk_y_pos[blk_id] != -1.f && flat_placement_info.blk_layer[blk_id] != -1.f); // Get the molecule for this atom block. PackMoleculeId blk_mol_id = prepacker.get_atom_molecule(blk_id); // Skip if we have already seen this molecule. @@ -176,10 +174,10 @@ GreedyCandidateSelector::~GreedyCandidateSelector() { } ClusterGainStats GreedyCandidateSelector::create_cluster_gain_stats( - PackMoleculeId cluster_seed_mol_id, - LegalizationClusterId cluster_id, - const ClusterLegalizer& cluster_legalizer, - AttractionInfo& attraction_groups) { + PackMoleculeId cluster_seed_mol_id, + LegalizationClusterId cluster_id, + const ClusterLegalizer& cluster_legalizer, + AttractionInfo& attraction_groups) { // Initialize the cluster gain stats. ClusterGainStats cluster_gain_stats; cluster_gain_stats.seed_molecule_id = cluster_seed_mol_id; @@ -208,11 +206,11 @@ ClusterGainStats GreedyCandidateSelector::create_cluster_gain_stats( } void GreedyCandidateSelector::update_cluster_gain_stats_candidate_success( - ClusterGainStats& cluster_gain_stats, - PackMoleculeId successful_mol_id, - LegalizationClusterId cluster_id, - const ClusterLegalizer& cluster_legalizer, - AttractionInfo& attraction_groups) { + ClusterGainStats& cluster_gain_stats, + PackMoleculeId successful_mol_id, + LegalizationClusterId cluster_id, + const ClusterLegalizer& cluster_legalizer, + AttractionInfo& attraction_groups) { VTR_ASSERT(successful_mol_id.is_valid()); // TODO: If this threshold lookup gets expensive, move outside. int high_fanout_net_threshold = high_fanout_thresholds_.get_threshold(cluster_legalizer.get_cluster_type(cluster_id)->name); @@ -301,13 +299,13 @@ void GreedyCandidateSelector::update_cluster_gain_stats_candidate_success( } void GreedyCandidateSelector::mark_and_update_partial_gain( - ClusterGainStats& cluster_gain_stats, - AtomNetId net_id, - e_gain_update gain_flag, - AtomBlockId clustered_blk_id, - const ClusterLegalizer& cluster_legalizer, - int high_fanout_net_threshold, - e_net_relation_to_clustered_block net_relation_to_clustered_block) { + ClusterGainStats& cluster_gain_stats, + AtomNetId net_id, + e_gain_update gain_flag, + AtomBlockId clustered_blk_id, + const ClusterLegalizer& cluster_legalizer, + int high_fanout_net_threshold, + e_net_relation_to_clustered_block net_relation_to_clustered_block) { if (int(atom_netlist_.net_sinks(net_id).size()) > high_fanout_net_threshold) { /* Optimization: It can be too runtime costly for marking all sinks for @@ -393,11 +391,11 @@ static bool is_atom_blk_in_pb(const AtomBlockId blk_id, const t_pb* pb) { } void GreedyCandidateSelector::update_connection_gain_values( - ClusterGainStats& cluster_gain_stats, - AtomNetId net_id, - AtomBlockId clustered_blk_id, - const ClusterLegalizer& cluster_legalizer, - e_net_relation_to_clustered_block net_relation_to_clustered_block) { + ClusterGainStats& cluster_gain_stats, + AtomNetId net_id, + AtomBlockId clustered_blk_id, + const ClusterLegalizer& cluster_legalizer, + e_net_relation_to_clustered_block net_relation_to_clustered_block) { /*This function is called when the connection_gain values on the net net_id *require updating. */ @@ -466,10 +464,10 @@ void GreedyCandidateSelector::update_connection_gain_values( } void GreedyCandidateSelector::update_timing_gain_values( - ClusterGainStats& cluster_gain_stats, - AtomNetId net_id, - const ClusterLegalizer& cluster_legalizer, - e_net_relation_to_clustered_block net_relation_to_clustered_block) { + ClusterGainStats& cluster_gain_stats, + AtomNetId net_id, + const ClusterLegalizer& cluster_legalizer, + e_net_relation_to_clustered_block net_relation_to_clustered_block) { /*This function is called when the timing_gain values on the atom net *net_id requires updating. */ @@ -553,26 +551,26 @@ void GreedyCandidateSelector::update_total_gain(ClusterGainStats& cluster_gain_s if (packer_opts_.connection_driven) { /*try to absorb as many connections as possible*/ cluster_gain_stats.gain[blk_id] = ((1 - packer_opts_.beta) - * (float)cluster_gain_stats.sharing_gain[blk_id] - + packer_opts_.beta * (float)cluster_gain_stats.connection_gain[blk_id]) - / (num_used_pins); + * (float)cluster_gain_stats.sharing_gain[blk_id] + + packer_opts_.beta * (float)cluster_gain_stats.connection_gain[blk_id]) + / (num_used_pins); } else { cluster_gain_stats.gain[blk_id] = ((float)cluster_gain_stats.sharing_gain[blk_id]) - / (num_used_pins); + / (num_used_pins); } /* Add in timing driven cost into cost function */ if (packer_opts_.timing_driven) { cluster_gain_stats.gain[blk_id] = packer_opts_.alpha - * cluster_gain_stats.timing_gain[blk_id] - + (1.0 - packer_opts_.alpha) * (float)cluster_gain_stats.gain[blk_id]; + * cluster_gain_stats.timing_gain[blk_id] + + (1.0 - packer_opts_.alpha) * (float)cluster_gain_stats.gain[blk_id]; } } } void GreedyCandidateSelector::update_cluster_gain_stats_candidate_failed( - ClusterGainStats& cluster_gain_stats, - PackMoleculeId failed_mol_id) { + ClusterGainStats& cluster_gain_stats, + PackMoleculeId failed_mol_id) { VTR_ASSERT(failed_mol_id.is_valid()); auto got = cluster_gain_stats.mol_failures.find(failed_mol_id); if (got == cluster_gain_stats.mol_failures.end()) { @@ -583,10 +581,10 @@ void GreedyCandidateSelector::update_cluster_gain_stats_candidate_failed( } PackMoleculeId GreedyCandidateSelector::get_next_candidate_for_cluster( - ClusterGainStats& cluster_gain_stats, - LegalizationClusterId cluster_id, - const ClusterLegalizer& cluster_legalizer, - AttractionInfo& attraction_groups) { + ClusterGainStats& cluster_gain_stats, + LegalizationClusterId cluster_id, + const ClusterLegalizer& cluster_legalizer, + AttractionInfo& attraction_groups) { /* Finds the block with the greatest gain that satisfies the * input, clock and capacity constraints of a cluster that are * passed in. If no suitable block is found it returns nullptr. @@ -625,8 +623,7 @@ PackMoleculeId GreedyCandidateSelector::get_next_candidate_for_cluster( } // If this is the second pass of candidate selection, use connectivity // and timing. - if (cluster_gain_stats.num_feasible_blocks == 0 && - !cluster_gain_stats.has_done_connectivity_and_timing) { + if (cluster_gain_stats.num_feasible_blocks == 0 && !cluster_gain_stats.has_done_connectivity_and_timing) { add_cluster_molecule_candidates_by_connectivity_and_timing(cluster_gain_stats, cluster_id, cluster_legalizer, @@ -717,10 +714,10 @@ PackMoleculeId GreedyCandidateSelector::get_next_candidate_for_cluster( } void GreedyCandidateSelector::add_cluster_molecule_candidates_by_flat_placement( - ClusterGainStats& cluster_gain_stats, - LegalizationClusterId legalization_cluster_id, - const ClusterLegalizer& cluster_legalizer, - AttractionInfo& attraction_groups) { + ClusterGainStats& cluster_gain_stats, + LegalizationClusterId legalization_cluster_id, + const ClusterLegalizer& cluster_legalizer, + AttractionInfo& attraction_groups) { // Get the seed molecule root block. const t_pack_molecule& seed_molecule = prepacker_.get_molecule(cluster_gain_stats.seed_molecule_id); AtomBlockId root_blk_id = seed_molecule.atom_block_ids[seed_molecule.root]; @@ -740,8 +737,7 @@ void GreedyCandidateSelector::add_cluster_molecule_candidates_by_flat_placement( for (PackMoleculeId molecule_id : mols_in_tile) { // Add the molecule as a candidate if the molecule is not clustered and // is compatible with this cluster (using simple checks). - if (!cluster_legalizer.is_mol_clustered(molecule_id) && - cluster_legalizer.is_molecule_compatible(molecule_id, legalization_cluster_id)) { + if (!cluster_legalizer.is_mol_clustered(molecule_id) && cluster_legalizer.is_molecule_compatible(molecule_id, legalization_cluster_id)) { add_molecule_to_pb_stats_candidates(molecule_id, cluster_gain_stats, packer_opts_.feasible_block_array_size, @@ -753,10 +749,10 @@ void GreedyCandidateSelector::add_cluster_molecule_candidates_by_flat_placement( } void GreedyCandidateSelector::add_cluster_molecule_candidates_by_connectivity_and_timing( - ClusterGainStats& cluster_gain_stats, - LegalizationClusterId legalization_cluster_id, - const ClusterLegalizer& cluster_legalizer, - AttractionInfo& attraction_groups) { + ClusterGainStats& cluster_gain_stats, + LegalizationClusterId legalization_cluster_id, + const ClusterLegalizer& cluster_legalizer, + AttractionInfo& attraction_groups) { cluster_gain_stats.explore_transitive_fanout = true; /* If no legal molecules found, enable exploration of molecules two hops away */ for (AtomBlockId blk_id : cluster_gain_stats.marked_blocks) { @@ -764,8 +760,7 @@ void GreedyCandidateSelector::add_cluster_molecule_candidates_by_connectivity_an PackMoleculeId molecule_id = prepacker_.get_atom_molecule(blk_id); // Add the molecule as a candidate if the molecule is not clustered and // is compatible with this cluster (using simple checks). - if (!cluster_legalizer.is_mol_clustered(molecule_id) && - cluster_legalizer.is_molecule_compatible(molecule_id, legalization_cluster_id)) { + if (!cluster_legalizer.is_mol_clustered(molecule_id) && cluster_legalizer.is_molecule_compatible(molecule_id, legalization_cluster_id)) { add_molecule_to_pb_stats_candidates(molecule_id, cluster_gain_stats, packer_opts_.feasible_block_array_size, @@ -777,10 +772,10 @@ void GreedyCandidateSelector::add_cluster_molecule_candidates_by_connectivity_an } void GreedyCandidateSelector::add_cluster_molecule_candidates_by_transitive_connectivity( - ClusterGainStats& cluster_gain_stats, - LegalizationClusterId legalization_cluster_id, - const ClusterLegalizer& cluster_legalizer, - AttractionInfo& attraction_groups) { + ClusterGainStats& cluster_gain_stats, + LegalizationClusterId legalization_cluster_id, + const ClusterLegalizer& cluster_legalizer, + AttractionInfo& attraction_groups) { //TODO: For now, only done by fan-out; should also consider fan-in cluster_gain_stats.explore_transitive_fanout = false; @@ -792,8 +787,7 @@ void GreedyCandidateSelector::add_cluster_molecule_candidates_by_transitive_conn /* Only consider candidates that pass a very simple legality check */ for (const auto& transitive_candidate : cluster_gain_stats.transitive_fanout_candidates) { PackMoleculeId molecule_id = transitive_candidate.second; - if (!cluster_legalizer.is_mol_clustered(molecule_id) && - cluster_legalizer.is_molecule_compatible(molecule_id, legalization_cluster_id)) { + if (!cluster_legalizer.is_mol_clustered(molecule_id) && cluster_legalizer.is_molecule_compatible(molecule_id, legalization_cluster_id)) { add_molecule_to_pb_stats_candidates(molecule_id, cluster_gain_stats, std::min(packer_opts_.feasible_block_array_size, @@ -806,10 +800,10 @@ void GreedyCandidateSelector::add_cluster_molecule_candidates_by_transitive_conn } void GreedyCandidateSelector::add_cluster_molecule_candidates_by_highfanout_connectivity( - ClusterGainStats& cluster_gain_stats, - LegalizationClusterId legalization_cluster_id, - const ClusterLegalizer& cluster_legalizer, - AttractionInfo& attraction_groups) { + ClusterGainStats& cluster_gain_stats, + LegalizationClusterId legalization_cluster_id, + const ClusterLegalizer& cluster_legalizer, + AttractionInfo& attraction_groups) { /* Because the packer ignores high fanout nets when marking what blocks * to consider, use one of the ignored high fanout net to fill up lightly * related blocks */ @@ -825,8 +819,7 @@ void GreedyCandidateSelector::add_cluster_molecule_candidates_by_highfanout_conn AtomBlockId blk_id = atom_netlist_.pin_block(pin_id); PackMoleculeId molecule_id = prepacker_.get_atom_molecule(blk_id); - if (!cluster_legalizer.is_mol_clustered(molecule_id) && - cluster_legalizer.is_molecule_compatible(molecule_id, legalization_cluster_id)) { + if (!cluster_legalizer.is_mol_clustered(molecule_id) && cluster_legalizer.is_molecule_compatible(molecule_id, legalization_cluster_id)) { add_molecule_to_pb_stats_candidates(molecule_id, cluster_gain_stats, std::min(packer_opts_.feasible_block_array_size, @@ -841,10 +834,10 @@ void GreedyCandidateSelector::add_cluster_molecule_candidates_by_highfanout_conn } void GreedyCandidateSelector::add_cluster_molecule_candidates_by_attraction_group( - ClusterGainStats& cluster_gain_stats, - LegalizationClusterId legalization_cluster_id, - const ClusterLegalizer& cluster_legalizer, - AttractionInfo& attraction_groups) { + ClusterGainStats& cluster_gain_stats, + LegalizationClusterId legalization_cluster_id, + const ClusterLegalizer& cluster_legalizer, + AttractionInfo& attraction_groups) { auto cluster_type = cluster_legalizer.get_cluster_type(legalization_cluster_id); /* @@ -885,8 +878,7 @@ void GreedyCandidateSelector::add_cluster_molecule_candidates_by_attraction_grou for (AtomBlockId atom_id : available_atoms) { //Only consider molecules that are unpacked and of the correct type PackMoleculeId molecule_id = prepacker_.get_atom_molecule(atom_id); - if (!cluster_legalizer.is_mol_clustered(molecule_id) && - cluster_legalizer.is_molecule_compatible(molecule_id, legalization_cluster_id)) { + if (!cluster_legalizer.is_mol_clustered(molecule_id) && cluster_legalizer.is_molecule_compatible(molecule_id, legalization_cluster_id)) { add_molecule_to_pb_stats_candidates(molecule_id, cluster_gain_stats, packer_opts_.feasible_block_array_size, @@ -906,8 +898,7 @@ void GreedyCandidateSelector::add_cluster_molecule_candidates_by_attraction_grou //Only consider molecules that are unpacked and of the correct type PackMoleculeId molecule_id = prepacker_.get_atom_molecule(blk_id); - if (!cluster_legalizer.is_mol_clustered(molecule_id) && - cluster_legalizer.is_molecule_compatible(molecule_id, legalization_cluster_id)) { + if (!cluster_legalizer.is_mol_clustered(molecule_id) && cluster_legalizer.is_molecule_compatible(molecule_id, legalization_cluster_id)) { add_molecule_to_pb_stats_candidates(molecule_id, cluster_gain_stats, packer_opts_.feasible_block_array_size, @@ -1093,9 +1084,9 @@ static float get_molecule_gain(PackMoleculeId molecule_id, } void GreedyCandidateSelector::load_transitive_fanout_candidates( - ClusterGainStats& cluster_gain_stats, - LegalizationClusterId legalization_cluster_id, - const ClusterLegalizer& cluster_legalizer) { + ClusterGainStats& cluster_gain_stats, + LegalizationClusterId legalization_cluster_id, + const ClusterLegalizer& cluster_legalizer) { // iterate over all the nets that have pins in this cluster for (AtomNetId net_id : cluster_gain_stats.marked_nets) { // only consider small nets to constrain runtime @@ -1140,8 +1131,8 @@ void GreedyCandidateSelector::load_transitive_fanout_candidates( } PackMoleculeId GreedyCandidateSelector::get_unrelated_candidate_for_cluster( - LegalizationClusterId cluster_id, - const ClusterLegalizer& cluster_legalizer) { + LegalizationClusterId cluster_id, + const ClusterLegalizer& cluster_legalizer) { // Necessary data structures are only allocated in unrelated clustering is // on. VTR_ASSERT(allow_unrelated_clustering_); @@ -1181,8 +1172,8 @@ PackMoleculeId GreedyCandidateSelector::get_unrelated_candidate_for_cluster( } void GreedyCandidateSelector::update_candidate_selector_finalize_cluster( - ClusterGainStats& cluster_gain_stats, - LegalizationClusterId cluster_id) { + ClusterGainStats& cluster_gain_stats, + LegalizationClusterId cluster_id) { // store info that will be used later in packing. for (const AtomNetId mnet_id : cluster_gain_stats.marked_nets) { int external_terminals = atom_netlist_.net_pins(mnet_id).size() - cluster_gain_stats.num_pins_of_net_in_pb[mnet_id]; @@ -1197,4 +1188,3 @@ void GreedyCandidateSelector::update_candidate_selector_finalize_cluster( } } } - diff --git a/vpr/src/pack/verify_flat_placement.cpp b/vpr/src/pack/verify_flat_placement.cpp index 1aee5bd53ae..079a7235fe4 100644 --- a/vpr/src/pack/verify_flat_placement.cpp +++ b/vpr/src/pack/verify_flat_placement.cpp @@ -14,11 +14,7 @@ unsigned verify_flat_placement_for_packing(const FlatPlacementInfo& flat_placeme // Quick check to ensure that the flat placement info has the correct size // for each piece of information. - if (flat_placement_info.blk_x_pos.size() != atom_netlist.blocks().size() || - flat_placement_info.blk_y_pos.size() != atom_netlist.blocks().size() || - flat_placement_info.blk_layer.size() != atom_netlist.blocks().size() || - flat_placement_info.blk_sub_tile.size() != atom_netlist.blocks().size() || - flat_placement_info.blk_site_idx.size() != atom_netlist.blocks().size()) { + if (flat_placement_info.blk_x_pos.size() != atom_netlist.blocks().size() || flat_placement_info.blk_y_pos.size() != atom_netlist.blocks().size() || flat_placement_info.blk_layer.size() != atom_netlist.blocks().size() || flat_placement_info.blk_sub_tile.size() != atom_netlist.blocks().size() || flat_placement_info.blk_site_idx.size() != atom_netlist.blocks().size()) { VTR_LOG_ERROR( "The number of blocks in the flat placement does not match the " "number of blocks in the atom netlist.\n"); @@ -32,9 +28,7 @@ unsigned verify_flat_placement_for_packing(const FlatPlacementInfo& flat_placeme // TODO: In the future, we may be able to allow some blocks to have // undefined positions. for (AtomBlockId blk_id : atom_netlist.blocks()) { - if (flat_placement_info.blk_x_pos[blk_id] == FlatPlacementInfo::UNDEFINED_POS || - flat_placement_info.blk_y_pos[blk_id] == FlatPlacementInfo::UNDEFINED_POS || - flat_placement_info.blk_layer[blk_id] == FlatPlacementInfo::UNDEFINED_POS) { + if (flat_placement_info.blk_x_pos[blk_id] == FlatPlacementInfo::UNDEFINED_POS || flat_placement_info.blk_y_pos[blk_id] == FlatPlacementInfo::UNDEFINED_POS || flat_placement_info.blk_layer[blk_id] == FlatPlacementInfo::UNDEFINED_POS) { VTR_LOG_ERROR( "Atom block %s has an undefined position in the flat placement.\n", atom_netlist.block_name(blk_id).c_str()); @@ -53,11 +47,7 @@ unsigned verify_flat_placement_for_packing(const FlatPlacementInfo& flat_placeme float blk_layer = flat_placement_info.blk_layer[blk_id]; int blk_sub_tile = flat_placement_info.blk_sub_tile[blk_id]; int blk_site_idx = flat_placement_info.blk_site_idx[blk_id]; - if ((blk_x_pos < 0.f && blk_x_pos != FlatPlacementInfo::UNDEFINED_POS) || - (blk_y_pos < 0.f && blk_y_pos != FlatPlacementInfo::UNDEFINED_POS) || - (blk_layer < 0.f && blk_layer != FlatPlacementInfo::UNDEFINED_POS) || - (blk_sub_tile < 0 && blk_sub_tile != FlatPlacementInfo::UNDEFINED_SUB_TILE) || - (blk_site_idx < 0 && blk_site_idx != FlatPlacementInfo::UNDEFINED_SITE_IDX)) { + if ((blk_x_pos < 0.f && blk_x_pos != FlatPlacementInfo::UNDEFINED_POS) || (blk_y_pos < 0.f && blk_y_pos != FlatPlacementInfo::UNDEFINED_POS) || (blk_layer < 0.f && blk_layer != FlatPlacementInfo::UNDEFINED_POS) || (blk_sub_tile < 0 && blk_sub_tile != FlatPlacementInfo::UNDEFINED_SUB_TILE) || (blk_site_idx < 0 && blk_site_idx != FlatPlacementInfo::UNDEFINED_SITE_IDX)) { VTR_LOG_ERROR( "Atom block %s is placed at an invalid position on the FPGA.\n", atom_netlist.block_name(blk_id).c_str()); @@ -79,10 +69,7 @@ unsigned verify_flat_placement_for_packing(const FlatPlacementInfo& flat_placeme for (AtomBlockId mol_blk_id : mol.atom_block_ids) { if (!mol_blk_id.is_valid()) continue; - if (flat_placement_info.blk_x_pos[mol_blk_id] != root_pos_x || - flat_placement_info.blk_y_pos[mol_blk_id] != root_pos_y || - flat_placement_info.blk_layer[mol_blk_id] != root_layer || - flat_placement_info.blk_sub_tile[mol_blk_id] != root_sub_tile) { + if (flat_placement_info.blk_x_pos[mol_blk_id] != root_pos_x || flat_placement_info.blk_y_pos[mol_blk_id] != root_pos_y || flat_placement_info.blk_layer[mol_blk_id] != root_layer || flat_placement_info.blk_sub_tile[mol_blk_id] != root_sub_tile) { VTR_LOG_ERROR( "Molecule with root atom block %s contains atom block %s " "which is not at the same position as the root atom " @@ -101,4 +88,3 @@ unsigned verify_flat_placement_for_packing(const FlatPlacementInfo& flat_placeme return num_errors; } - diff --git a/vpr/src/place/noc_place_utils.cpp b/vpr/src/place/noc_place_utils.cpp index cb3e80e9429..569408bb354 100644 --- a/vpr/src/place/noc_place_utils.cpp +++ b/vpr/src/place/noc_place_utils.cpp @@ -80,8 +80,8 @@ void NocCostHandler::initial_noc_routing(const vtr::vector= 0., "Clock period must be positive"); float constraint = std::numeric_limits::quiet_NaN(); - if (vtr::isclose(launch_clock.period, capture_clock.period) && - vtr::isclose(launch_clock.rise_edge, capture_clock.rise_edge) && - vtr::isclose(launch_clock.fall_edge, capture_clock.fall_edge)) { + if (vtr::isclose(launch_clock.period, capture_clock.period) + && vtr::isclose(launch_clock.rise_edge, capture_clock.rise_edge) + && vtr::isclose(launch_clock.fall_edge, capture_clock.fall_edge)) { //The source and sink domains have the same period and edges, the constraint is the common clock period. constraint = launch_clock.period; diff --git a/vpr/src/util/vpr_utils.cpp b/vpr/src/util/vpr_utils.cpp index 94541f5523b..828c024f9a8 100644 --- a/vpr/src/util/vpr_utils.cpp +++ b/vpr/src/util/vpr_utils.cpp @@ -1473,7 +1473,8 @@ std::tuple parse_direct_pin_name(std::string std::string source_string{src_string}; // Replace '.' and '[' characters with ' ' - std::replace_if(source_string.begin(), source_string.end(), + std::replace_if( + source_string.begin(), source_string.end(), [](char c) { return c == '.' || c == '[' || c == ':' || c == ']'; }, ' '); From 30489092862eda7dc5b61a611d9a105674377563 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Mon, 17 Mar 2025 13:24:14 -0400 Subject: [PATCH 4/9] added a space before binary operators --- vpr/src/base/read_place.cpp | 2 +- vpr/src/place/place_macro.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vpr/src/base/read_place.cpp b/vpr/src/base/read_place.cpp index 258fc05ed96..5b07ef33f28 100644 --- a/vpr/src/base/read_place.cpp +++ b/vpr/src/base/read_place.cpp @@ -182,7 +182,7 @@ static void read_place_header(std::ifstream& placement_file, "--verify_file_digests command line option is off."); } - if ((tokens.size() == 4|| (tokens.size() > 4 && tokens[4][0] == '#')) + if ((tokens.size() == 4 || (tokens.size() > 4 && tokens[4][0] == '#')) || (tokens.size() == 5 || (tokens.size() > 5 && tokens[5][0] == '#'))) { placement_file.seekg(file_pos); break; diff --git a/vpr/src/place/place_macro.cpp b/vpr/src/place/place_macro.cpp index d636543e272..ff564fd656c 100644 --- a/vpr/src/place/place_macro.cpp +++ b/vpr/src/place/place_macro.cpp @@ -212,7 +212,7 @@ int PlaceMacros::find_all_the_macro_(const ClusteredNetlist& clb_nlist, // blocks in the middle of a chain with internal constant signals are not detected as potential // head blocks. if (to_src_or_sink == SINK && to_idirect != OPEN - && (to_net_id == ClusterNetId::INVALID()|| (is_constant_clb_net(to_net_id, atom_lookup, atom_nlist) && !net_is_driven_by_direct_(to_net_id, clb_nlist)))) { + && (to_net_id == ClusterNetId::INVALID() || (is_constant_clb_net(to_net_id, atom_lookup, atom_nlist) && !net_is_driven_by_direct_(to_net_id, clb_nlist)))) { for (int from_iblk_pin = 0; from_iblk_pin < num_blk_pins; from_iblk_pin++) { int from_physical_pin = get_physical_pin(physical_tile, logical_block, from_iblk_pin); From e0967ff2d03cc74ae2650ae9d47dce67959d3cb1 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Tue, 18 Mar 2025 11:07:42 -0400 Subject: [PATCH 5/9] apply PR comments --- vpr/src/pack/pb_type_graph.cpp | 18 +++++++++--------- vpr/src/pack/verify_flat_placement.cpp | 16 +++++++++++++--- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/vpr/src/pack/pb_type_graph.cpp b/vpr/src/pack/pb_type_graph.cpp index 9cd0b668765..2727d05e2b8 100644 --- a/vpr/src/pack/pb_type_graph.cpp +++ b/vpr/src/pack/pb_type_graph.cpp @@ -1945,15 +1945,15 @@ const t_pb_graph_edge* get_edge_between_pins(const t_pb_graph_pin* driver_pin, c /* Date:June 8th, 2024 * Author: Kate Thurmer * Purpose: This subroutine computes the index of a pb graph node at its - * level of the pb hierarchy; it is computed by the parent and - * passed to each child of each child pb type. When the child is - * a primitive, the computed indes is its flat site index. - * For example, if there are 10 ALMs, each with 2 FFs and 2 LUTs, - * then the ALM at index N, when calling this function for - * its FF child at index M, would compute the child's index as: - * N*(FFs per ALM) + M - * e.g. for FF[1] in ALM[5], this returns - * 5*(2 FFS per ALM) + 1 = 11 + * level of the pb hierarchy; it is computed by the parent and + * passed to each child of each child pb type. When the child is + * a primitive, the computed indes is its flat site index. + * For example, if there are 10 ALMs, each with 2 FFs and 2 LUTs, + * then the ALM at index N, when calling this function for + * its FF child at index M, would compute the child's index as: + * N*(FFs per ALM) + M + * e.g. for FF[1] in ALM[5], this returns + * 5*(2 FFS per ALM) + 1 = 11 */ static int compute_flat_index_for_child_node(int num_children_of_type, int parent_flat_index, diff --git a/vpr/src/pack/verify_flat_placement.cpp b/vpr/src/pack/verify_flat_placement.cpp index 079a7235fe4..ecba4ca6e5e 100644 --- a/vpr/src/pack/verify_flat_placement.cpp +++ b/vpr/src/pack/verify_flat_placement.cpp @@ -14,7 +14,11 @@ unsigned verify_flat_placement_for_packing(const FlatPlacementInfo& flat_placeme // Quick check to ensure that the flat placement info has the correct size // for each piece of information. - if (flat_placement_info.blk_x_pos.size() != atom_netlist.blocks().size() || flat_placement_info.blk_y_pos.size() != atom_netlist.blocks().size() || flat_placement_info.blk_layer.size() != atom_netlist.blocks().size() || flat_placement_info.blk_sub_tile.size() != atom_netlist.blocks().size() || flat_placement_info.blk_site_idx.size() != atom_netlist.blocks().size()) { + if (flat_placement_info.blk_x_pos.size() != atom_netlist.blocks().size() + || flat_placement_info.blk_y_pos.size() != atom_netlist.blocks().size() + || flat_placement_info.blk_layer.size() != atom_netlist.blocks().size() + || flat_placement_info.blk_sub_tile.size() != atom_netlist.blocks().size() + || flat_placement_info.blk_site_idx.size() != atom_netlist.blocks().size()) { VTR_LOG_ERROR( "The number of blocks in the flat placement does not match the " "number of blocks in the atom netlist.\n"); @@ -28,7 +32,9 @@ unsigned verify_flat_placement_for_packing(const FlatPlacementInfo& flat_placeme // TODO: In the future, we may be able to allow some blocks to have // undefined positions. for (AtomBlockId blk_id : atom_netlist.blocks()) { - if (flat_placement_info.blk_x_pos[blk_id] == FlatPlacementInfo::UNDEFINED_POS || flat_placement_info.blk_y_pos[blk_id] == FlatPlacementInfo::UNDEFINED_POS || flat_placement_info.blk_layer[blk_id] == FlatPlacementInfo::UNDEFINED_POS) { + if (flat_placement_info.blk_x_pos[blk_id] == FlatPlacementInfo::UNDEFINED_POS + || flat_placement_info.blk_y_pos[blk_id] == FlatPlacementInfo::UNDEFINED_POS + || flat_placement_info.blk_layer[blk_id] == FlatPlacementInfo::UNDEFINED_POS) { VTR_LOG_ERROR( "Atom block %s has an undefined position in the flat placement.\n", atom_netlist.block_name(blk_id).c_str()); @@ -47,7 +53,11 @@ unsigned verify_flat_placement_for_packing(const FlatPlacementInfo& flat_placeme float blk_layer = flat_placement_info.blk_layer[blk_id]; int blk_sub_tile = flat_placement_info.blk_sub_tile[blk_id]; int blk_site_idx = flat_placement_info.blk_site_idx[blk_id]; - if ((blk_x_pos < 0.f && blk_x_pos != FlatPlacementInfo::UNDEFINED_POS) || (blk_y_pos < 0.f && blk_y_pos != FlatPlacementInfo::UNDEFINED_POS) || (blk_layer < 0.f && blk_layer != FlatPlacementInfo::UNDEFINED_POS) || (blk_sub_tile < 0 && blk_sub_tile != FlatPlacementInfo::UNDEFINED_SUB_TILE) || (blk_site_idx < 0 && blk_site_idx != FlatPlacementInfo::UNDEFINED_SITE_IDX)) { + if ((blk_x_pos < 0.f && blk_x_pos != FlatPlacementInfo::UNDEFINED_POS) + || (blk_y_pos < 0.f && blk_y_pos != FlatPlacementInfo::UNDEFINED_POS) + || (blk_layer < 0.f && blk_layer != FlatPlacementInfo::UNDEFINED_POS) + || (blk_sub_tile < 0 && blk_sub_tile != FlatPlacementInfo::UNDEFINED_SUB_TILE) + || (blk_site_idx < 0 && blk_site_idx != FlatPlacementInfo::UNDEFINED_SITE_IDX)) { VTR_LOG_ERROR( "Atom block %s is placed at an invalid position on the FPGA.\n", atom_netlist.block_name(blk_id).c_str()); From 0fd5d54057978d50c9baed7ec77c0ce6cc9ac270 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Tue, 18 Mar 2025 11:17:15 -0400 Subject: [PATCH 6/9] break long lines in ap_netlist.cpp --- vpr/src/analytical_place/ap_netlist.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vpr/src/analytical_place/ap_netlist.cpp b/vpr/src/analytical_place/ap_netlist.cpp index a2d6cb7773e..26c80119b9a 100644 --- a/vpr/src/analytical_place/ap_netlist.cpp +++ b/vpr/src/analytical_place/ap_netlist.cpp @@ -59,12 +59,18 @@ void APNetlist::set_block_loc(const APBlockId id, const APFixedBlockLoc& loc) { VTR_ASSERT_SAFE(valid_block_id(id)); // Check that the location is fixed; if all dims are unfixed then it is not fixed. - if (loc.x == APFixedBlockLoc::UNFIXED_DIM && loc.y == APFixedBlockLoc::UNFIXED_DIM && loc.sub_tile == APFixedBlockLoc::UNFIXED_DIM && loc.layer_num == APFixedBlockLoc::UNFIXED_DIM) + if (loc.x == APFixedBlockLoc::UNFIXED_DIM + && loc.y == APFixedBlockLoc::UNFIXED_DIM + && loc.sub_tile == APFixedBlockLoc::UNFIXED_DIM + && loc.layer_num == APFixedBlockLoc::UNFIXED_DIM) return; // Ensure that the block is fixed to a single position on the grid (x, y, layer). // sub-tile is allowed to be unfixed. - VTR_ASSERT(loc.x != APFixedBlockLoc::UNFIXED_DIM && loc.y != APFixedBlockLoc::UNFIXED_DIM && loc.layer_num != APFixedBlockLoc::UNFIXED_DIM && "AP: Currently, AP assumes block is locked down to a single position on the device grid."); + VTR_ASSERT(loc.x != APFixedBlockLoc::UNFIXED_DIM + && loc.y != APFixedBlockLoc::UNFIXED_DIM + && loc.layer_num != APFixedBlockLoc::UNFIXED_DIM + && "AP: Currently, AP assumes block is locked down to a single position on the device grid."); block_locs_[id] = loc; block_mobilities_[id] = APBlockMobility::FIXED; From a210310f9a47e67a9d1f858d406934abc4b39c22 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Tue, 18 Mar 2025 11:19:41 -0400 Subject: [PATCH 7/9] update submodules when checkout action is executed in Format job --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0f0dbf3231b..5977e1221ba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -89,6 +89,8 @@ jobs: with: python-version: 3.10.10 - uses: actions/checkout@v4 + with: + submodules: 'true' - name: Install dependencies run: ./.github/scripts/install_dependencies.sh From 694654b10b5ab4a1ab969088e97cbe7781373546 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Tue, 18 Mar 2025 15:09:05 -0400 Subject: [PATCH 8/9] make format-py --- dev/pylint_check.py | 2 +- dev/submit_slurm.py | 2 +- dev/vtr_gdb_pretty_printers.py | 2 + .../tools/8_bit_arithmetic_power_output.py | 4 +- .../regression_test/tools/asr_vector_maker.py | 2 +- vpr/scripts/profile/util.py | 1 + .../system_verilog/f4pga/make_sv_flattened.py | 16 +++++-- vtr_flow/scripts/arch_gen/arch_gen.py | 4 +- .../scripts/benchtracker/flask_cors/six.py | 3 +- vtr_flow/scripts/benchtracker/populate_db.py | 2 + vtr_flow/scripts/blif_splicer.py | 8 ++-- vtr_flow/scripts/download_noc_mlp.py | 8 ++-- vtr_flow/scripts/download_titan.py | 5 +- vtr_flow/scripts/python_libs/vtr/__init__.py | 1 + .../scripts/python_libs/vtr/abc/__init__.py | 1 + vtr_flow/scripts/python_libs/vtr/abc/abc.py | 38 ++++++++------- .../scripts/python_libs/vtr/ace/__init__.py | 1 + vtr_flow/scripts/python_libs/vtr/ace/ace.py | 2 + vtr_flow/scripts/python_libs/vtr/flow.py | 7 +-- vtr_flow/scripts/python_libs/vtr/log_parse.py | 3 +- .../scripts/python_libs/vtr/odin/__init__.py | 1 + vtr_flow/scripts/python_libs/vtr/odin/odin.py | 1 + .../python_libs/vtr/parmys/__init__.py | 1 + .../scripts/python_libs/vtr/parmys/parmys.py | 1 + .../scripts/python_libs/vtr/parse_vtr_flow.py | 1 - .../scripts/python_libs/vtr/parse_vtr_task.py | 2 +- vtr_flow/scripts/python_libs/vtr/paths.py | 4 +- vtr_flow/scripts/python_libs/vtr/task.py | 47 ++++++++++--------- vtr_flow/scripts/python_libs/vtr/util.py | 4 +- .../scripts/python_libs/vtr/vpr/__init__.py | 1 + vtr_flow/scripts/python_libs/vtr/vpr/vpr.py | 8 ++-- vtr_flow/scripts/run_vtr_flow.py | 16 ++++--- vtr_flow/scripts/run_vtr_task.py | 6 +-- vtr_flow/scripts/tuning_runs/control_runs.py | 17 +++---- 34 files changed, 127 insertions(+), 95 deletions(-) diff --git a/dev/pylint_check.py b/dev/pylint_check.py index 96e78a2393d..4d2b9bba7c6 100755 --- a/dev/pylint_check.py +++ b/dev/pylint_check.py @@ -132,7 +132,7 @@ def expand_paths(): """Build a list of all python files to process by going through 'paths_to_lint'""" paths = [] - for (path, is_recursive) in paths_to_lint: + for path, is_recursive in paths_to_lint: # Make sure all hard-coded paths point to .py files if path.is_file(): if path.suffix.lower() != ".py": diff --git a/dev/submit_slurm.py b/dev/submit_slurm.py index fe6ef4b9ab5..f372f787e45 100755 --- a/dev/submit_slurm.py +++ b/dev/submit_slurm.py @@ -188,7 +188,7 @@ def get_resource_estimates(filepath): mem_bytes = float(match.groupdict()["mem_bytes"]) time_minutes = time_sec / 60 - mem_mb = mem_bytes / (1024 ** 2) + mem_mb = mem_bytes / (1024**2) return time_minutes, mem_mb diff --git a/dev/vtr_gdb_pretty_printers.py b/dev/vtr_gdb_pretty_printers.py index 86e2e14074d..3f4b7a951b3 100644 --- a/dev/vtr_gdb_pretty_printers.py +++ b/dev/vtr_gdb_pretty_printers.py @@ -7,8 +7,10 @@ https://docs.verilogtorouting.org/en/latest/dev/developing#vtr-pretty-printers """ + import re + # VTR related class VtrStrongIdPrinter: def __init__(self, val, typename="vtr::StrongId"): diff --git a/odin_ii/regression_test/tools/8_bit_arithmetic_power_output.py b/odin_ii/regression_test/tools/8_bit_arithmetic_power_output.py index 617316e5541..c0800584a71 100644 --- a/odin_ii/regression_test/tools/8_bit_arithmetic_power_output.py +++ b/odin_ii/regression_test/tools/8_bit_arithmetic_power_output.py @@ -11,12 +11,12 @@ def make_output_vector(power): print("c") next_a = 0 for i in range(0, 512): - value = next_a ** power + value = next_a**power output = f"{value:#0{4}x}" print(output[0:2] + output[-2:]) if i % 2 == 1: next_a += 1 - value = next_a ** power + value = next_a**power output = f"{value:#0{4}x}" print(output[0:2] + output[-2:]) print("0x00") diff --git a/odin_ii/regression_test/tools/asr_vector_maker.py b/odin_ii/regression_test/tools/asr_vector_maker.py index b3477e36f7d..27c5262303e 100644 --- a/odin_ii/regression_test/tools/asr_vector_maker.py +++ b/odin_ii/regression_test/tools/asr_vector_maker.py @@ -67,7 +67,7 @@ def make_input_vector(bits): # One for each value (2^bits) # a rising edge for each line ( * 2) # a line for reset ( + 1) - lines = ((2 ** bits) * 2) + 2 + lines = ((2**bits) * 2) + 2 for i in range(0, lines): if i < (lines - 1): inputs[0].append(value) diff --git a/vpr/scripts/profile/util.py b/vpr/scripts/profile/util.py index c6a252a3c75..8ac1e2930e5 100644 --- a/vpr/scripts/profile/util.py +++ b/vpr/scripts/profile/util.py @@ -5,6 +5,7 @@ import socket import getpass + # working on the task directory def sort_runs(runs): natural_sort(runs) diff --git a/vtr_flow/benchmarks/system_verilog/f4pga/make_sv_flattened.py b/vtr_flow/benchmarks/system_verilog/f4pga/make_sv_flattened.py index bcc72a26634..930d5fb40a6 100644 --- a/vtr_flow/benchmarks/system_verilog/f4pga/make_sv_flattened.py +++ b/vtr_flow/benchmarks/system_verilog/f4pga/make_sv_flattened.py @@ -1,32 +1,36 @@ """ Module for flattening the SV design files. """ + import os import re + def find_verilog_files(): """Find all Verilog (.sv, .v) files in the current directory.""" - return [f for f in os.listdir('.') if f.endswith(('.sv', '.v'))] + return [f for f in os.listdir(".") if f.endswith((".sv", ".v"))] + def identify_top_module(file_list): """Identify the file containing the top module definition.""" top_module_regex = re.compile(r"module\s+top\s*\(") for file in file_list: - with open(file, 'r') as f: + with open(file, "r") as f: for line in f: if top_module_regex.search(line): return file return None + def create_flattened_file(top_file, file_list): """Create a flattened Verilog file with all file contents.""" current_dir = os.path.basename(os.getcwd()) output_file_name = f"flattened_{current_dir}.sv" - with open(output_file_name, 'w') as output_file: + with open(output_file_name, "w") as output_file: if top_file: # Write the top module first - with open(top_file, 'r') as top_module: + with open(top_file, "r") as top_module: output_file.write(f"// Content from {top_file}\n") output_file.write(top_module.read()) output_file.write("\n\n") @@ -34,13 +38,14 @@ def create_flattened_file(top_file, file_list): # Write the rest of the files for file in file_list: if file != top_file: - with open(file, 'r') as verilog_file: + with open(file, "r") as verilog_file: output_file.write(f"// Content from {file}\n") output_file.write(verilog_file.read()) output_file.write("\n\n") print(f"Flattened file created: {output_file_name}") + def main(): """Main function to generate the flattened Verilog file.""" print("Searching for Verilog files...") @@ -61,5 +66,6 @@ def main(): print("Creating flattened file...") create_flattened_file(top_file, verilog_files) + if __name__ == "__main__": main() diff --git a/vtr_flow/scripts/arch_gen/arch_gen.py b/vtr_flow/scripts/arch_gen/arch_gen.py index 2039bf26e06..ef68cde7af5 100755 --- a/vtr_flow/scripts/arch_gen/arch_gen.py +++ b/vtr_flow/scripts/arch_gen/arch_gen.py @@ -172,7 +172,7 @@ def xLUT(LUT_size, num_LUT): def xCLB(k_LUT, N_BLE, I_CLB, I_BLE, fracture_level, num_FF, crossbar_str): - O_LUT = 2 ** fracture_level + O_LUT = 2**fracture_level O_soft = O_LUT O_ble = O_soft O_CLB = N_BLE * O_ble @@ -430,7 +430,7 @@ def xCLB(k_LUT, N_BLE, I_CLB, I_BLE, fracture_level, num_FF, crossbar_str): else: special_stage = False - num_LUT = 2 ** frac_stage + num_LUT = 2**frac_stage LUT_size = k_LUT - frac_stage idx = "[" + str(LUT_size - 1) + ":0]" diff --git a/vtr_flow/scripts/benchtracker/flask_cors/six.py b/vtr_flow/scripts/benchtracker/flask_cors/six.py index c06164c97d0..80c9e7e618d 100644 --- a/vtr_flow/scripts/benchtracker/flask_cors/six.py +++ b/vtr_flow/scripts/benchtracker/flask_cors/six.py @@ -687,7 +687,6 @@ def reraise(tp, value, tb=None): raise value.with_traceback(tb) raise value - else: def exec_(_code_, _globs_=None, _locs_=None): @@ -809,13 +808,13 @@ def wrapper(f): return wrapper - else: wraps = functools.wraps def with_metaclass(meta, *bases): """Create a base class with a metaclass.""" + # This requires a bit of explanation: the basic idea is to make a dummy # metaclass for one level of class instantiation that replaces itself with # the actual metaclass. diff --git a/vtr_flow/scripts/benchtracker/populate_db.py b/vtr_flow/scripts/benchtracker/populate_db.py index 39c898bde1e..358ef190fd7 100755 --- a/vtr_flow/scripts/benchtracker/populate_db.py +++ b/vtr_flow/scripts/benchtracker/populate_db.py @@ -25,6 +25,7 @@ nullval = "-1" type_map = {int: "INT", float: "REAL", str: "TEXT"} + # main program sequence def main(): params = Params() @@ -59,6 +60,7 @@ def update_db(params, db): # check if table for task exists; if not then create it task_table_name = params.task_table_name create_table(params, db, task_table_name) + # load up latest run and parsed date for task def check_last_runs_table(runs): natural_sort(runs) diff --git a/vtr_flow/scripts/blif_splicer.py b/vtr_flow/scripts/blif_splicer.py index dcfb71fc7d1..08058163f65 100755 --- a/vtr_flow/scripts/blif_splicer.py +++ b/vtr_flow/scripts/blif_splicer.py @@ -88,9 +88,11 @@ # and is not 're') with the name of the circuit. sections[sectionNumber] += " ".join( - name + "_" + word - if word != "re" and any(char not in nonNetChars for char in word) - else word + ( + name + "_" + word + if word != "re" and any(char not in nonNetChars for char in word) + else word + ) for word in line.split(" ") ) diff --git a/vtr_flow/scripts/download_noc_mlp.py b/vtr_flow/scripts/download_noc_mlp.py index c483da753df..c541c91c021 100755 --- a/vtr_flow/scripts/download_noc_mlp.py +++ b/vtr_flow/scripts/download_noc_mlp.py @@ -17,6 +17,7 @@ import shutil import errno + class ExtractionError(Exception): """ Raised when extracting the downlaoded file fails @@ -39,8 +40,9 @@ def parse_args(): does nothing (unless --force is specified). """ ) - parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, - description=description) + parser = argparse.ArgumentParser( + formatter_class=argparse.ArgumentDefaultsHelpFormatter, description=description + ) parser.add_argument( "--vtr_flow_dir", @@ -132,7 +134,7 @@ def extract_to_vtr_flow_dir(args, tar_gz_filename): raise ExtractionError("{} should be a directory".format(directory)) # Create a temporary working directory - tmpdir = tempfile.mkdtemp(suffix="download_NoC_MLP", dir= os.path.abspath(".")) + tmpdir = tempfile.mkdtemp(suffix="download_NoC_MLP", dir=os.path.abspath(".")) try: # Extract the contents of the .tar.gz archive directly into the destination directory with tarfile.open(tar_gz_filename, "r:gz") as tar: diff --git a/vtr_flow/scripts/download_titan.py b/vtr_flow/scripts/download_titan.py index cf025dc38ab..483ba5c04d0 100755 --- a/vtr_flow/scripts/download_titan.py +++ b/vtr_flow/scripts/download_titan.py @@ -41,8 +41,9 @@ def parse_args(): does nothing (unless --force is specified). """ ) - parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, - description=description) + parser = argparse.ArgumentParser( + formatter_class=argparse.ArgumentDefaultsHelpFormatter, description=description + ) parser.add_argument( "--titan_version", default="2.0.0", help="Titan release version to download" diff --git a/vtr_flow/scripts/python_libs/vtr/__init__.py b/vtr_flow/scripts/python_libs/vtr/__init__.py index 6a0b38d7639..5fce29c9d63 100644 --- a/vtr_flow/scripts/python_libs/vtr/__init__.py +++ b/vtr_flow/scripts/python_libs/vtr/__init__.py @@ -1,6 +1,7 @@ """ __init__ for the VTR python module """ + from .util import ( load_config_lines, CommandRunner, diff --git a/vtr_flow/scripts/python_libs/vtr/abc/__init__.py b/vtr_flow/scripts/python_libs/vtr/abc/__init__.py index 26d376b3420..cdb3a62e69d 100644 --- a/vtr_flow/scripts/python_libs/vtr/abc/__init__.py +++ b/vtr_flow/scripts/python_libs/vtr/abc/__init__.py @@ -1,4 +1,5 @@ """ __init__ for abc module """ + from .abc import run, run_lec diff --git a/vtr_flow/scripts/python_libs/vtr/abc/abc.py b/vtr_flow/scripts/python_libs/vtr/abc/abc.py index 0ec3ca5ccef..a49de129d69 100644 --- a/vtr_flow/scripts/python_libs/vtr/abc/abc.py +++ b/vtr_flow/scripts/python_libs/vtr/abc/abc.py @@ -1,6 +1,7 @@ """ Module to run ABC with its various options """ + import shutil from collections import OrderedDict from pathlib import Path @@ -8,6 +9,7 @@ from vtr import paths from vtr.error import InspectError + # pylint: disable=too-many-arguments, too-many-locals def run( architecture_file, @@ -186,24 +188,26 @@ def run( ] ) if abc_script is None - else "; ".join( - [ - "read {pre_abc_blif}".format(pre_abc_blif=pre_abc_blif.name), - "time", - "resyn", - "resyn2", - "if -K {lut_size}".format(lut_size=lut_size), - "time", - "scleanup", - "write_hie {pre_abc_blif} {post_abc_raw_blif}".format( - pre_abc_blif=pre_abc_blif.name, - post_abc_raw_blif=post_abc_raw_blif.name, - ), - "print_stats", - ] + else ( + "; ".join( + [ + "read {pre_abc_blif}".format(pre_abc_blif=pre_abc_blif.name), + "time", + "resyn", + "resyn2", + "if -K {lut_size}".format(lut_size=lut_size), + "time", + "scleanup", + "write_hie {pre_abc_blif} {post_abc_raw_blif}".format( + pre_abc_blif=pre_abc_blif.name, + post_abc_raw_blif=post_abc_raw_blif.name, + ), + "print_stats", + ] + ) + if use_old_abc_script + else abc_script ) - if use_old_abc_script - else abc_script ) cmd = [abc_exec, "-c", abc_script] diff --git a/vtr_flow/scripts/python_libs/vtr/ace/__init__.py b/vtr_flow/scripts/python_libs/vtr/ace/__init__.py index 9666f7710ac..50682d93b35 100644 --- a/vtr_flow/scripts/python_libs/vtr/ace/__init__.py +++ b/vtr_flow/scripts/python_libs/vtr/ace/__init__.py @@ -1,4 +1,5 @@ """ init for the ACE module """ + from .ace import run diff --git a/vtr_flow/scripts/python_libs/vtr/ace/ace.py b/vtr_flow/scripts/python_libs/vtr/ace/ace.py index 7c5a274dc7e..a2e6af00fd5 100644 --- a/vtr_flow/scripts/python_libs/vtr/ace/ace.py +++ b/vtr_flow/scripts/python_libs/vtr/ace/ace.py @@ -1,9 +1,11 @@ """ Module to run ACE with its various options """ + from pathlib import Path from vtr import verify_file, CommandRunner, paths + # pylint: disable=too-many-arguments def run( circuit_file, diff --git a/vtr_flow/scripts/python_libs/vtr/flow.py b/vtr_flow/scripts/python_libs/vtr/flow.py index 70f7cc3b513..55d9025f7d5 100644 --- a/vtr_flow/scripts/python_libs/vtr/flow.py +++ b/vtr_flow/scripts/python_libs/vtr/flow.py @@ -1,6 +1,7 @@ """ Module to run the VTR flow. This module calls other modules that then access the tools like VPR. """ + import shutil from pathlib import Path from collections import OrderedDict @@ -258,9 +259,9 @@ def run( if should_run_stage(VtrStage.ACE, start_stage, end_stage): vtr.ace.run( next_stage_netlist, - old_netlist=post_odin_netlist - if start_stage == VtrStage.ODIN - else post_yosys_netlist, + old_netlist=( + post_odin_netlist if start_stage == VtrStage.ODIN else post_yosys_netlist + ), output_netlist=post_ace_netlist, output_activity_file=post_ace_activity_file, command_runner=command_runner, diff --git a/vtr_flow/scripts/python_libs/vtr/log_parse.py b/vtr_flow/scripts/python_libs/vtr/log_parse.py index 623c4545e22..69e8d72e7d7 100644 --- a/vtr_flow/scripts/python_libs/vtr/log_parse.py +++ b/vtr_flow/scripts/python_libs/vtr/log_parse.py @@ -1,6 +1,7 @@ """ module that contains functions to inspect various files to determine important values """ + import re from collections import OrderedDict from pathlib import Path @@ -25,7 +26,7 @@ def __init__(self, name, filename, regex_str, default_value=None): self._filename = filename # Look for the specified pattern somewhere in the line, but any characters # can occur before and after it. Detailed in GitHub Issue #2743. - self._regex = re.compile(f'^.*{regex_str}.*$') + self._regex = re.compile(f"^.*{regex_str}.*$") self._default_value = default_value def name(self): diff --git a/vtr_flow/scripts/python_libs/vtr/odin/__init__.py b/vtr_flow/scripts/python_libs/vtr/odin/__init__.py index b55d5c160cd..f1006248346 100644 --- a/vtr_flow/scripts/python_libs/vtr/odin/__init__.py +++ b/vtr_flow/scripts/python_libs/vtr/odin/__init__.py @@ -1,4 +1,5 @@ """ init for the ODIN module """ + from .odin import run diff --git a/vtr_flow/scripts/python_libs/vtr/odin/odin.py b/vtr_flow/scripts/python_libs/vtr/odin/odin.py index c4346d115b8..846b743b814 100644 --- a/vtr_flow/scripts/python_libs/vtr/odin/odin.py +++ b/vtr_flow/scripts/python_libs/vtr/odin/odin.py @@ -1,6 +1,7 @@ """ Module to run ODIN II with its various arguments """ + import os import shutil from collections import OrderedDict diff --git a/vtr_flow/scripts/python_libs/vtr/parmys/__init__.py b/vtr_flow/scripts/python_libs/vtr/parmys/__init__.py index 581b8681c71..a8a520b91ed 100644 --- a/vtr_flow/scripts/python_libs/vtr/parmys/__init__.py +++ b/vtr_flow/scripts/python_libs/vtr/parmys/__init__.py @@ -1,5 +1,6 @@ """ init for the YOSYS module """ + from .parmys import run from .parmys import YOSYS_PARSERS diff --git a/vtr_flow/scripts/python_libs/vtr/parmys/parmys.py b/vtr_flow/scripts/python_libs/vtr/parmys/parmys.py index e11478e8f18..c067ee7e7cf 100644 --- a/vtr_flow/scripts/python_libs/vtr/parmys/parmys.py +++ b/vtr_flow/scripts/python_libs/vtr/parmys/parmys.py @@ -1,6 +1,7 @@ """ Module to run Parmys with its various arguments """ + import os import shutil from collections import OrderedDict diff --git a/vtr_flow/scripts/python_libs/vtr/parse_vtr_flow.py b/vtr_flow/scripts/python_libs/vtr/parse_vtr_flow.py index d500eca0643..e238f2d9bb8 100755 --- a/vtr_flow/scripts/python_libs/vtr/parse_vtr_flow.py +++ b/vtr_flow/scripts/python_libs/vtr/parse_vtr_flow.py @@ -16,7 +16,6 @@ def parse_file_and_update_results(filename, patterns, results): - """ Find filename, and then look through for the matching patterns, updating results """ diff --git a/vtr_flow/scripts/python_libs/vtr/parse_vtr_task.py b/vtr_flow/scripts/python_libs/vtr/parse_vtr_task.py index d2aac387bcc..32df9b17e07 100755 --- a/vtr_flow/scripts/python_libs/vtr/parse_vtr_task.py +++ b/vtr_flow/scripts/python_libs/vtr/parse_vtr_task.py @@ -433,7 +433,7 @@ def check_two_files( ) num_qor_failures = 0 # Verify that the first results pass each metric for all cases in the second results - for (arch, circuit, script_params) in second_primary_keys: + for arch, circuit, script_params in second_primary_keys: second_metrics = second_results.metrics(arch, circuit, script_params) first_metrics = first_results.metrics(arch, circuit, script_params) first_fail = True diff --git a/vtr_flow/scripts/python_libs/vtr/paths.py b/vtr_flow/scripts/python_libs/vtr/paths.py index 5f0888c328f..2ab1e4c31b5 100644 --- a/vtr_flow/scripts/python_libs/vtr/paths.py +++ b/vtr_flow/scripts/python_libs/vtr/paths.py @@ -23,8 +23,8 @@ yosys_script_path = yosys_tcl_path / "synthesis.tcl" # Synlig paths -synlig_path = root_path/"build"/"bin"/"synlig_install" -synlig_exe_path = synlig_path / "usr"/"local"/"bin"/"synlig" +synlig_path = root_path / "build" / "bin" / "synlig_install" +synlig_exe_path = synlig_path / "usr" / "local" / "bin" / "synlig" # PARMYS paths parmys_path = root_path / "parmys" diff --git a/vtr_flow/scripts/python_libs/vtr/task.py b/vtr_flow/scripts/python_libs/vtr/task.py index 5af290578f7..be2559446fe 100644 --- a/vtr_flow/scripts/python_libs/vtr/task.py +++ b/vtr_flow/scripts/python_libs/vtr/task.py @@ -1,6 +1,7 @@ """ Module that contains the task functions """ + import itertools from pathlib import Path @@ -22,6 +23,7 @@ paths, ) + # pylint: disable=too-many-instance-attributes, too-many-arguments, too-many-locals, too-few-public-methods class TaskConfig: """ @@ -55,7 +57,7 @@ def __init__( pad_file=None, additional_files=None, additional_files_list_add=None, - circuit_constraint_list_add=None + circuit_constraint_list_add=None, ): self.task_name = task_name self.config_dir = config_dir @@ -82,9 +84,9 @@ def __init__( self.pad_file = pad_file self.additional_files = additional_files self.additional_files_list_add = additional_files_list_add - self.circuit_constraints = parse_circuit_constraint_list(circuit_constraint_list_add, - self.circuits, - self.archs) + self.circuit_constraints = parse_circuit_constraint_list( + circuit_constraint_list_add, self.circuits, self.archs + ) # pylint: enable=too-few-public-methods @@ -306,9 +308,8 @@ def check_include_fields(config_file, key_values): ) ) -def parse_circuit_constraint_list( - circuit_constraint_list, circuits_list, arch_list -) -> dict: + +def parse_circuit_constraint_list(circuit_constraint_list, circuits_list, arch_list) -> dict: """ Parse the circuit constraints passed in via the config file. Circuit constraints are expected to have the following syntax: @@ -343,38 +344,39 @@ def parse_circuit_constraint_list( # Parse the circuit constraint list for circuit_constraint in circuit_constraint_list: # Remove the round brackets. - if circuit_constraint[0] != '(' or circuit_constraint[-1] != ')': - raise VtrError(f"Circuit constraint syntax error: \"{circuit_constraint}\"") + if circuit_constraint[0] != "(" or circuit_constraint[-1] != ")": + raise VtrError(f'Circuit constraint syntax error: "{circuit_constraint}"') circuit_constraint = circuit_constraint[1:-1] # Split the circuit and the constraint - split_constraint_line = circuit_constraint.split(',') + split_constraint_line = circuit_constraint.split(",") if len(split_constraint_line) != 2: - raise VtrError(f"Circuit constraint has too many arguments: \"{circuit_constraint}\"") + raise VtrError(f'Circuit constraint has too many arguments: "{circuit_constraint}"') circuit = split_constraint_line[0].strip() constraint = split_constraint_line[1].strip() # Check that the circuit actually exists. if circuit not in circuits_list: - raise VtrError(f"Cannot constrain circuit \"{circuit}\", circuit has not been added") + raise VtrError(f'Cannot constrain circuit "{circuit}", circuit has not been added') # Parse the constraint split_constraint = constraint.split("=") if len(split_constraint) != 2: - raise VtrError(f"Circuit constraint syntax error: \"{circuit_constraint}\"") + raise VtrError(f'Circuit constraint syntax error: "{circuit_constraint}"') constr_key = split_constraint[0].strip() constr_val = split_constraint[1].strip() # Check that the constr_key is valid. if constr_key not in circuit_constraint_keys: - raise VtrError(f"Invalid constraint \"{constr_key}\" used on circuit \"{circuit}\"") + raise VtrError(f'Invalid constraint "{constr_key}" used on circuit "{circuit}"') # In the case of arch constraints, make sure this arch exists. if constr_key == "arch" and constr_val not in arch_list: - raise VtrError(f"Cannot constrain arch \"{constr_key}\", arch has not been added") + raise VtrError(f'Cannot constrain arch "{constr_key}", arch has not been added') # Make sure this circuit is not already constrained with this constr_arg if res_circuit_constraints[circuit][constr_key] is not None: - raise VtrError(f"Circuit \"{circuit}\" cannot be constrained more than once") + raise VtrError(f'Circuit "{circuit}" cannot be constrained more than once') # Add the constraint for this circuit res_circuit_constraints[circuit][constr_key] = constr_val return res_circuit_constraints + def shorten_task_names(configs, common_task_prefix): """ Shorten the task names of the configs by remove the common task prefix. @@ -407,7 +409,7 @@ def find_longest_task_description(configs): def get_work_dir_addr(arch, circuit, noc_traffic): - """ Get the work directory address under under run_dir """ + """Get the work directory address under under run_dir""" work_dir = None if noc_traffic: work_dir = str(PurePath(arch).joinpath(circuit).joinpath(noc_traffic)) @@ -418,7 +420,7 @@ def get_work_dir_addr(arch, circuit, noc_traffic): def create_second_parse_cmd(config): - """ Create the parse command to run the second time """ + """Create the parse command to run the second time""" second_parse_cmd = None if config.second_parse_file: second_parse_cmd = [ @@ -436,7 +438,7 @@ def create_second_parse_cmd(config): def create_cmd( abs_circuit_filepath, abs_arch_filepath, config, args, circuit, noc_traffic ) -> Tuple: - """ Create the command to run the task """ + """Create the command to run the task""" # Collect any extra script params from the config file cmd = [abs_circuit_filepath, abs_arch_filepath] @@ -583,10 +585,7 @@ def create_jobs(args, configs, after_run=False) -> List[Job]: work_dir = get_work_dir_addr(arch, circuit, noc_traffic) run_dir = ( - str( - Path(get_latest_run_dir(find_task_dir(config, args.alt_tasks_dir))) - / work_dir - ) + str(Path(get_latest_run_dir(find_task_dir(config, args.alt_tasks_dir))) / work_dir) if after_run else str( Path(get_next_run_dir(find_task_dir(config, args.alt_tasks_dir))) / work_dir @@ -780,6 +779,7 @@ def ret_expected_vpr_status(arch, circuit, golden_results, script_params=None): return golden_metrics["vpr_status"] + def apply_cmd_line_circuit_constraints(cmd, circuit, config): """ Apply the circuit constraints to the command line. If the circuit is not @@ -798,6 +798,7 @@ def apply_cmd_line_circuit_constraints(cmd, circuit, config): if constrained_route_w is not None: cmd += ["--route_chan_width", constrained_route_w] + def resolve_vtr_source_file(config, filename, base_dir=""): """ Resolves an filename with a base_dir diff --git a/vtr_flow/scripts/python_libs/vtr/util.py b/vtr_flow/scripts/python_libs/vtr/util.py index 61b52ee991b..7d1c7dbab11 100644 --- a/vtr_flow/scripts/python_libs/vtr/util.py +++ b/vtr_flow/scripts/python_libs/vtr/util.py @@ -154,7 +154,7 @@ def run_system_command( # or RR graph files to VPR. PWD environment variable is updated # manually to prevent capnproto from throwing exceptions. modified_environ = os.environ.copy() - modified_environ['PWD'] = str(temp_dir) + modified_environ["PWD"] = str(temp_dir) proc = subprocess.Popen( cmd, @@ -162,7 +162,7 @@ def run_system_command( stderr=stderr, # stderr redirected to stderr universal_newlines=True, # Lines always end in \n cwd=str(temp_dir), # Where to run the command - env=modified_environ + env=modified_environ, ) # Read the output line-by-line and log it diff --git a/vtr_flow/scripts/python_libs/vtr/vpr/__init__.py b/vtr_flow/scripts/python_libs/vtr/vpr/__init__.py index 895950332ef..823908b93e2 100644 --- a/vtr_flow/scripts/python_libs/vtr/vpr/__init__.py +++ b/vtr_flow/scripts/python_libs/vtr/vpr/__init__.py @@ -1,4 +1,5 @@ """ __init__ for the VPR Module """ + from .vpr import run, run_relax_w, cmp_full_vs_incr_sta, run_second_time diff --git a/vtr_flow/scripts/python_libs/vtr/vpr/vpr.py b/vtr_flow/scripts/python_libs/vtr/vpr/vpr.py index 003adb9f8cb..50278757656 100644 --- a/vtr_flow/scripts/python_libs/vtr/vpr/vpr.py +++ b/vtr_flow/scripts/python_libs/vtr/vpr/vpr.py @@ -1,12 +1,14 @@ """ Module to interact with VPR and its various options """ + from collections import OrderedDict from pathlib import Path from os import environ from vtr import CommandRunner, relax_w, determine_min_w, verify_file, paths from vtr.error import InspectError + # pylint: disable=too-many-arguments,too-many-locals def run_relax_w( architecture, @@ -296,9 +298,9 @@ def run_second_time( if "write_intra_cluster_router_lookahead" in second_run_args: intra_cluster_router_lookahead = second_run_args["write_intra_cluster_router_lookahead"] second_run_args["read_intra_cluster_router_lookahead"] = intra_cluster_router_lookahead - second_run_args[ - "write_intra_cluster_router_lookahead" - ] = "intra_cluster_router_lookahead2.capnp" + second_run_args["write_intra_cluster_router_lookahead"] = ( + "intra_cluster_router_lookahead2.capnp" + ) # run VPR run( diff --git a/vtr_flow/scripts/run_vtr_flow.py b/vtr_flow/scripts/run_vtr_flow.py index 3d584274e3f..70ff3f2ac9b 100755 --- a/vtr_flow/scripts/run_vtr_flow.py +++ b/vtr_flow/scripts/run_vtr_flow.py @@ -22,6 +22,7 @@ VTR_STAGES = ["odin", "parmys", "abc", "ace", "vpr"] + # pylint: disable=too-few-public-methods class VtrStageArgparseAction(argparse.Action): """ @@ -45,6 +46,7 @@ def __call__(self, parser, namespace, value, option_string=None): # pylint: enable=too-few-public-methods + # pylint: disable=too-many-statements def vtr_command_argparser(prog=None): """ @@ -459,10 +461,10 @@ def format_human_readable_memory(num_kbytes): """format the number of bytes given as a human readable value""" if num_kbytes < 1024: value = "%.2f KiB" % (num_kbytes) - elif num_kbytes < (1024 ** 2): - value = "%.2f MiB" % (num_kbytes / (1024 ** 1)) + elif num_kbytes < (1024**2): + value = "%.2f MiB" % (num_kbytes / (1024**1)) else: - value = "%.2f GiB" % (num_kbytes / (1024 ** 2)) + value = "%.2f GiB" % (num_kbytes / (1024**2)) return value @@ -550,9 +552,11 @@ def vtr_command_main(arg_list, prog=None): vpr_args["read_vpr_constraints"] = Path(vpr_constraint_file_copy).name print( - args.name - if args.name - else Path(args.architecture_file).stem + "/" + Path(args.circuit_file).stem, + ( + args.name + if args.name + else Path(args.architecture_file).stem + "/" + Path(args.circuit_file).stem + ), end="\t\t", ) # Run the flow diff --git a/vtr_flow/scripts/run_vtr_task.py b/vtr_flow/scripts/run_vtr_task.py index 0d9c5013181..ce16f44d518 100755 --- a/vtr_flow/scripts/run_vtr_task.py +++ b/vtr_flow/scripts/run_vtr_task.py @@ -471,9 +471,9 @@ def format_human_readable_time(seconds): def format_human_readable_memory(num_bytes): """format the number of bytes given as a human readable value""" - if num_bytes < 1024 ** 3: - return "%.2f MiB" % (num_bytes / (1024 ** 2)) - return "%.2f GiB" % (num_bytes / (1024 ** 3)) + if num_bytes < 1024**3: + return "%.2f MiB" % (num_bytes / (1024**2)) + return "%.2f GiB" % (num_bytes / (1024**3)) def run_vtr_flow_process(queue, run_dirs, job, script) -> None: diff --git a/vtr_flow/scripts/tuning_runs/control_runs.py b/vtr_flow/scripts/tuning_runs/control_runs.py index 825b3b7609c..c38e2cd7292 100755 --- a/vtr_flow/scripts/tuning_runs/control_runs.py +++ b/vtr_flow/scripts/tuning_runs/control_runs.py @@ -46,9 +46,7 @@ def parse_results(input_path): Parse the output results """ # Find the runXXX directory with the largest XXX - run_dirs = [ - d for d in os.listdir(input_path) if d.startswith("run") and d[3:].isdigit() - ] + run_dirs = [d for d in os.listdir(input_path) if d.startswith("run") and d[3:].isdigit()] if not run_dirs: print("No runXXX directories found in the specified input path.") sys.exit(1) @@ -63,9 +61,9 @@ def parse_results(input_path): sys.exit(1) # Read the parse_results.txt file and write to full_res.csv - with open( - os.path.join(largest_run_path, "parse_results.txt"), "r" - ) as txt_file, open(full_res_csv_path, "w", newline="") as csv_file: + with open(os.path.join(largest_run_path, "parse_results.txt"), "r") as txt_file, open( + full_res_csv_path, "w", newline="" + ) as csv_file: reader = csv.reader(txt_file, delimiter="\t") writer = csv.writer(csv_file) @@ -97,9 +95,7 @@ def parse_results(input_path): print("Generated average seed results") # Generate gmean_res.csv - generate_geomean_res_csv( - os.path.join(largest_run_path, "avg_seed.csv"), largest_run_path - ) + generate_geomean_res_csv(os.path.join(largest_run_path, "avg_seed.csv"), largest_run_path) print("Generated geometric average results over all the circuits") generate_xlsx(largest_run_path) @@ -147,8 +143,7 @@ def parse_script_params(script_params): j = i + key_length while j < len(parts) and not any( - parts[j : j + len(k.split("_"))] == k.split("_") - for k in PARAMS_DICT + parts[j : j + len(k.split("_"))] == k.split("_") for k in PARAMS_DICT ): value_parts.append(parts[j]) j += 1 From 859864bb6303700c3b7bfb9804ad20dc9d55ed23 Mon Sep 17 00:00:00 2001 From: soheilshahrouz Date: Tue, 18 Mar 2025 15:09:55 -0400 Subject: [PATCH 9/9] make foramt-py for parse_result.py --- odin_ii/regression_test/parse_result/parse_result.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/odin_ii/regression_test/parse_result/parse_result.py b/odin_ii/regression_test/parse_result/parse_result.py index 83373489d22..0e3bb7faefc 100755 --- a/odin_ii/regression_test/parse_result/parse_result.py +++ b/odin_ii/regression_test/parse_result/parse_result.py @@ -567,7 +567,7 @@ def compare_instances(header, toml_dict, tbl_entry, golden_tbl_entry): if len(tbl_entry[header]) != len(golden_tbl_entry[header]): return False - for (value, golden_value) in zip(tbl_entry[header], golden_tbl_entry[header]): + for value, golden_value in zip(tbl_entry[header], golden_tbl_entry[header]): if not compare_values(header, toml_dict, value, golden_value): return False @@ -778,7 +778,12 @@ def main(): arguments = parse_shared_args(sys.argv[2:]) exit( - {"display": display, "parse": parse, "join": join, "compare": compare,}.get( + { + "display": display, + "parse": parse, + "join": join, + "compare": compare, + }.get( command, lambda: "Invalid Command" )(arguments) )