Skip to content

Commit

Permalink
dump net decomposition code
Browse files Browse the repository at this point in the history
  • Loading branch information
duck2 committed Aug 17, 2023
1 parent f2783e2 commit a53cdea
Show file tree
Hide file tree
Showing 47 changed files with 1,754 additions and 692 deletions.
3 changes: 2 additions & 1 deletion .github/scripts/hostsetup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ apt install -y \
default-jdk \
g++-9 \
gcc-9 \
wget
wget \
libtbb-dev

# installing the latest version of cmake
apt install -y apt-transport-https ca-certificates gnupg
Expand Down
3 changes: 3 additions & 0 deletions dev/pylint_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ def main():
cmd = ["pylint", path, "-s", "n"]
if ignore_list:
cmd.append("--disable=" + ",".join(ignore_list))
# Don't object to single-letter variable names (that's not in PEP8)
# see https://stackoverflow.com/q/21833872
cmd.append('--variable-rgx=[a-z][a-z0-9_]{1,30}$')

# Run pylint and check output
process = subprocess.run(cmd, check=False, stdout=subprocess.PIPE)
Expand Down
5 changes: 0 additions & 5 deletions libs/librrgraph/src/base/rr_graph_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -631,11 +631,6 @@ class t_rr_graph_storage {
static inline Direction get_node_direction(
vtr::array_view_id<RRNodeId, const t_rr_node_data> node_storage,
RRNodeId id) {
auto& node_data = node_storage[id];
if (node_data.type_ != CHANX && node_data.type_ != CHANY) {
VTR_LOG_ERROR("Attempted to access RR node 'direction' for non-channel type '%s'",
rr_node_typename[node_data.type_]);
}
return node_storage[id].dir_side_.direction;
}

Expand Down
4 changes: 2 additions & 2 deletions libs/librrgraph/src/io/rr_graph_reader.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*This function loads in a routing resource graph written in xml format
/* This function loads in a routing resource graph written in xml format
* into vpr when the option --read_rr_graph <file name> is specified.
* When it is not specified the build_rr_graph function is then called.
* This is done using the libpugixml library. This is useful
Expand All @@ -11,7 +11,7 @@
* to ensure it matches. An error will through if any feature does not match.
* Other elements such as edges, nodes, and switches
* are overwritten by the rr graph file if one is specified. If an optional
* identifier such as capacitance is not specified, it is set to 0*/
* identifier such as capacitance is not specified, it is set to 0 */

#include "rr_graph_reader.h"

Expand Down
12 changes: 12 additions & 0 deletions libs/libvtrutil/src/vtr_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <map>
#include <vector>
#include <cmath>
#include <cstdint>

#include "vtr_assert.h"

Expand Down Expand Up @@ -163,6 +164,17 @@ bool isclose(T a, T b) {
return isclose<T>(a, b, DEFAULT_REL_TOL, DEFAULT_ABS_TOL);
}

/** Log2, round down.
* From https://stackoverflow.com/a/51351885 */
static inline uint64_t log2_floor(uint64_t x) {
return 63U - __builtin_clzl(x);
}

/** Log2, round up */
static inline uint64_t log2_ceil(uint64_t x) {
return log2_floor(x - 1) + 1;
}

} // namespace vtr

#endif
24 changes: 6 additions & 18 deletions libs/libvtrutil/src/vtr_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <cstdlib>
#include <cerrno> //For errno
#include <cstring>
#include <filesystem>
#include <memory>
#include <sstream>

Expand Down Expand Up @@ -455,28 +456,15 @@ bool file_exists(const char* filename) {
return false;
}

/* Date:July 17th, 2013
* Author: Daniel Chen */
/**
* @brief Checks the file extension of an file to ensure correct file format.
*
* Returns true if format is correct, and false otherwise.
* @note This is probably a fragile check, but at least should
* prevent common problems such as swapping architecture file
* and blif file on the VPR command line.
* Returns true if the extension is correct, and false otherwise.
*/
bool check_file_name_extension(const char* file_name,
const char* file_extension) {
const char* str;
int len_extension;

len_extension = std::strlen(file_extension);
str = std::strstr(file_name, file_extension);
if (str == nullptr || (*(str + len_extension) != '\0')) {
return false;
}

return true;
bool check_file_name_extension(std::string file_name,
std::string file_extension) {
auto ext = std::filesystem::path(file_name).extension();
return ext == file_extension;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions libs/libvtrutil/src/vtr_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ double atod(const std::string& value);
*/
int get_file_line_number_of_last_opened_file();
bool file_exists(const char* filename);
bool check_file_name_extension(const char* file_name,
const char* file_extension);
bool check_file_name_extension(std::string file_name, std::string file_extension);

extern std::string out_file_prefix;

Expand Down
17 changes: 10 additions & 7 deletions utils/route_diag/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,16 @@ static void do_one_route(const Netlist<>& net_list,
-1,
false,
std::unordered_map<RRNodeId, int>());
std::tie(found_path, std::ignore, cheapest) = router.timing_driven_route_connection_from_route_tree(tree.root(),
sink_node,
cost_params,
bounding_box,
router_stats,
conn_params,
true);
std::tie(found_path, std::ignore, cheapest) = router.timing_driven_route_connection_from_route_tree(
tree.root(),
tree.root().inode,
sink_node,
cost_params,
bounding_box,
router_stats,
conn_params,
true
);

if (found_path) {
VTR_ASSERT(cheapest.index == sink_node);
Expand Down
5 changes: 5 additions & 0 deletions vpr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ if(${VTR_ENABLE_CAPNPROTO})
add_definitions("-DVTR_ENABLE_CAPNPROTO")
endif()

if(${VPR_DEBUG_PARTITION_TREE})
message(STATUS "VPR: Partition tree debug logs: enabled")
add_definitions("-DVPR_DEBUG_PARTITION_TREE")
endif()

#Create the library
add_library(libvpr STATIC
${LIB_HEADERS}
Expand Down
3 changes: 3 additions & 0 deletions vpr/src/base/SetupVPR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ void SetupVPR(const t_options* Options,
/* Set seed for pseudo-random placement, default seed to 1 */
vtr::srandom(PlacerOpts->seed);

/* Make num_workers available to the router */
RouterOpts->num_workers = vpr_setup->num_workers;

{
vtr::ScopedStartFinishTimer t("Building complex block graph");
alloc_and_load_all_pb_graphs(PowerOpts->do_power, RouterOpts->flat_routing);
Expand Down
9 changes: 7 additions & 2 deletions vpr/src/base/vpr_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,11 @@ void vpr_init_with_options(const t_options* options, t_vpr_setup* vpr_setup, t_a
#ifdef VPR_USE_TBB
//Using Thread Building Blocks
if (num_workers == 0) {
//Use default concurrency (i.e. maximum conccurency)
//Use default concurrency (i.e. maximum concurrency)
num_workers = tbb::this_task_arena::max_concurrency();
}

VTR_LOG("Using up to %zu parallel worker(s)\n", num_workers);
tbb::global_control c(tbb::global_control::max_allowed_parallelism, num_workers);
#else
//No parallel execution support
if (num_workers != 1) {
Expand All @@ -237,6 +236,7 @@ void vpr_init_with_options(const t_options* options, t_vpr_setup* vpr_setup, t_a
vpr_setup->clock_modeling = options->clock_modeling;
vpr_setup->two_stage_clock_routing = options->two_stage_clock_routing;
vpr_setup->exit_before_pack = options->exit_before_pack;
vpr_setup->num_workers = num_workers;

VTR_LOG("\n");
VTR_LOG("Architecture file: %s\n", options->ArchFile.value().c_str());
Expand Down Expand Up @@ -366,6 +366,10 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
return true;
}

/* Set this here, because tbb::global_control doesn't control anything once it's out of scope
* (contrary to the name). */
tbb::global_control c(tbb::global_control::max_allowed_parallelism, vpr_setup.num_workers);

{ //Pack
bool pack_success = vpr_pack_flow(vpr_setup, arch);

Expand Down Expand Up @@ -912,6 +916,7 @@ RouteStatus vpr_route_fixed_W(const Netlist<>& net_list,
if (NO_FIXED_CHANNEL_WIDTH == fixed_channel_width || fixed_channel_width <= 0) {
VPR_FATAL_ERROR(VPR_ERROR_ROUTE, "Fixed channel width must be specified when routing at fixed channel width (was %d)", fixed_channel_width);
}

bool status = false;
status = try_route(net_list,
fixed_channel_width,
Expand Down
3 changes: 3 additions & 0 deletions vpr/src/base/vpr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,8 @@ struct t_router_opts {
bool flat_routing;
bool has_choking_spot;

size_t num_workers;

// Options related to rr_node reordering, for testing and possible cache optimization
e_rr_node_reorder_algorithm reorder_rr_graph_nodes_algorithm = DONT_REORDER;
int reorder_rr_graph_nodes_threshold = 0;
Expand Down Expand Up @@ -1790,6 +1792,7 @@ struct t_vpr_setup {
e_clock_modeling clock_modeling; ///<How clocks should be handled
bool two_stage_clock_routing; ///<How clocks should be routed in the presence of a dedicated clock network
bool exit_before_pack; ///<Exits early before starting packing (useful for collecting statistics without running/loading any stages)
unsigned int num_workers; ///Maximum number of worker threads (determined from an env var or cmdline option)
};

class RouteStatus {
Expand Down
10 changes: 1 addition & 9 deletions vpr/src/route/connection_based_routing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,7 @@ Connection_based_routing_resources::Connection_based_routing_resources(const Net
* reached_rt_sinks will also reserve enough space, but instead of
* indices, it will store the pointers to route tree nodes */

// can have as many targets as sink pins (total number of pins - SOURCE pin)
// supposed to be used as persistent vector growing with push_back and clearing at the start of each net routing iteration
auto max_sink_pins_per_net = std::max(get_max_pins_per_net(net_list_) - 1, 0);
remaining_targets.reserve(max_sink_pins_per_net);
reached_rt_sinks.reserve(max_sink_pins_per_net);

size_t routing_num_nets = net_list_.nets().size();
remaining_targets.resize(routing_num_nets);
reached_rt_sinks.resize(routing_num_nets);
lower_bound_connection_delay.resize(routing_num_nets);
forcible_reroute_connection_flag.resize(routing_num_nets);

Expand Down Expand Up @@ -114,7 +106,7 @@ bool Connection_based_routing_resources::forcibly_reroute_connections(float max_

forcible_reroute_connection_flag[net_id][rr_sink_node] = true;
// note that we don't set forcible_reroute_connection_flag to false when the converse is true
// resetting back to false will be done during tree pruning, after the sink has been legally reached
// resetting back to false will be done during tree pruning, after the sink has been legally reached [!]
any_connection_rerouted = true;

profiling::mark_for_forced_reroute();
Expand Down
30 changes: 0 additions & 30 deletions vpr/src/route/connection_based_routing.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,10 @@
// pruning the route tree of large fanouts. Instead of rerouting to each sink of a congested net,
// reroute only the connections to the ones that did not have a legal connection the previous time
class Connection_based_routing_resources {
/** Holds remaining target pin indices (if this net has a RouteTree from the previous
* iteration, its prune() call will update this) (should be moved into RouteTree) */
vtr::vector<ParentNetId, std::vector<int>> remaining_targets;

/** Holds RRNodeIds of legally reached sinks. Used to build the external rt_node_to_sink
* lookup. (should be moved into RouteTree)*/
vtr::vector<ParentNetId, std::vector<RRNodeId>> reached_rt_sinks;

public:
Connection_based_routing_resources(const Netlist<>& net_list,
const vtr::vector<ParentNetId, std::vector<RRNodeId>>& net_terminals,
bool is_flat);
// adding to the resources when they are reached during pruning
// mark rr sink node as something that still needs to be reached
void toreach_rr_sink(ParentNetId net_id, int rr_sink_node) {
remaining_targets[net_id].push_back(rr_sink_node);
}
// mark rt sink node as something that has been legally reached
void reached_rt_sink(ParentNetId net_id, RRNodeId rt_sink) {
reached_rt_sinks[net_id].push_back(rt_sink);
}

// get a handle on the resources
std::vector<int>& get_remaining_targets(ParentNetId net_id) {
return remaining_targets[net_id];
}
std::vector<RRNodeId>& get_reached_rt_sinks(ParentNetId net_id) {
return reached_rt_sinks[net_id];
}

bool sanity_check_lookup() const;

Expand Down Expand Up @@ -87,11 +62,6 @@ class Connection_based_routing_resources {
//Updates the connection delay lower bound (if less than current best found)
void update_lower_bound_connection_delay(ParentNetId net, int ipin, float delay);

void prepare_routing_for_net(ParentNetId net_id) {
remaining_targets[net_id].clear();
reached_rt_sinks[net_id].clear();
}

// get a handle on the resources
float get_stable_critical_path_delay() const { return last_stable_critical_path_delay; }

Expand Down
Loading

0 comments on commit a53cdea

Please sign in to comment.