Skip to content

Add extended lookahead map #1449

New issue

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

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

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/libvtrcapnproto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set(CAPNP_DEFS
matrix.capnp
gen/rr_graph_uxsdcxx.capnp
map_lookahead.capnp
extended_map_lookahead.capnp
)
capnp_generate_cpp(CAPNP_SRCS CAPNP_HDRS
${CAPNP_DEFS}
Expand Down
25 changes: 25 additions & 0 deletions libs/libvtrcapnproto/extended_map_lookahead.capnp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@0x876ec83c2fea5a18;

using Matrix = import "matrix.capnp";

struct VprCostEntry {
delay @0 :Float32;
congestion @1 :Float32;
fill @2 :Bool;
}

struct VprVector2D {
x @0 :Int64;
y @1 :Int64;
}

struct VprFloatEntry {
value @0 :Float32;
}

struct VprCostMap {
costMap @0 :Matrix.Matrix((Matrix.Matrix(VprCostEntry)));
offset @1 :Matrix.Matrix(VprVector2D);
depField @2 :List(Int64);
penalty @3 :Matrix.Matrix(VprFloatEntry);
}
6 changes: 6 additions & 0 deletions libs/libvtrutil/src/vtr_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ Rect<T> bounding_box(const Rect<T>& lhs, const Rect<T>& rhs);
template<typename T, typename std::enable_if<std::is_integral<T>::value>::type...>
Point<T> sample(const vtr::Rect<T>& r, T x, T y, T d);

// clamps v to be between low (lo) and high (hi), inclusive.
template<class T>
static constexpr const T& clamp(const T& v, const T& lo, const T& hi) {
return std::min(std::max(v, lo), hi);
}

//A 2D line
template<class T>
class Line {
Expand Down
6 changes: 6 additions & 0 deletions vpr/src/base/ShowSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
case e_router_lookahead::MAP:
VTR_LOG("MAP\n");
break;
case e_router_lookahead::EXTENDED_MAP:
VTR_LOG("EXTENDED_MAP\n");
break;
case e_router_lookahead::NO_OP:
VTR_LOG("NO_OP\n");
break;
Expand Down Expand Up @@ -444,6 +447,9 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
case e_router_lookahead::MAP:
VTR_LOG("MAP\n");
break;
case e_router_lookahead::EXTENDED_MAP:
VTR_LOG("EXTENDED_MAP\n");
break;
case e_router_lookahead::NO_OP:
VTR_LOG("NO_OP\n");
break;
Expand Down
1 change: 1 addition & 0 deletions vpr/src/base/echo_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ void alloc_and_load_echo_file_info() {
setEchoFileName(E_ECHO_CHAN_DETAILS, "chan_details.txt");
setEchoFileName(E_ECHO_SBLOCK_PATTERN, "sblock_pattern.txt");
setEchoFileName(E_ECHO_ENDPOINT_TIMING, "endpoint_timing.echo.json");
setEchoFileName(E_ECHO_LOOKAHEAD_MAP, "lookahead_map.echo");
}

void free_echo_file_info() {
Expand Down
1 change: 1 addition & 0 deletions vpr/src/base/echo_files.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ enum e_echo_files {
E_ECHO_CHAN_DETAILS,
E_ECHO_SBLOCK_PATTERN,
E_ECHO_ENDPOINT_TIMING,
E_ECHO_LOOKAHEAD_MAP,

//Timing Graphs
E_ECHO_PRE_PACKING_TIMING_GRAPH,
Expand Down
19 changes: 15 additions & 4 deletions vpr/src/base/read_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,8 @@ struct ParseRouterLookahead {
conv_value.set_value(e_router_lookahead::CLASSIC);
else if (str == "map")
conv_value.set_value(e_router_lookahead::MAP);
else if (str == "extended_map")
conv_value.set_value(e_router_lookahead::EXTENDED_MAP);
else {
std::stringstream msg;
msg << "Invalid conversion from '"
Expand All @@ -788,15 +790,17 @@ struct ParseRouterLookahead {
ConvertedValue<std::string> conv_value;
if (val == e_router_lookahead::CLASSIC)
conv_value.set_value("classic");
else {
VTR_ASSERT(val == e_router_lookahead::MAP);
else if (val == e_router_lookahead::MAP) {
conv_value.set_value("map");
} else {
VTR_ASSERT(val == e_router_lookahead::EXTENDED_MAP);
conv_value.set_value("extended_map");
}
return conv_value;
}

std::vector<std::string> default_choices() {
return {"classic", "map"};
return {"classic", "map", "extended_map"};
}
};

Expand Down Expand Up @@ -2093,7 +2097,14 @@ argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& arg
"Controls what lookahead the router uses to calculate cost of completing a connection.\n"
" * classic: The classic VPR lookahead (may perform better on un-buffered routing\n"
" architectures)\n"
" * map: A more advanced lookahead which accounts for diverse wire type\n")
" * map: An advanced lookahead which accounts for diverse wire type\n"
" * extended_map: A more advanced and extended lookahead which accounts for a more\n"
" exhaustive node sampling method\n"
"\n"
" The extended map differs from the map lookahead in the lookahead computation.\n"
" It is better suited for architectures that have specialized routing for specific\n"
" kinds of connections, but note that the time and memory necessary to compute the\n"
" extended lookahead map are greater than the basic lookahead map.\n")
.default_value("map")
.show_in(argparse::ShowIn::HELP_ONLY);

Expand Down
3 changes: 2 additions & 1 deletion vpr/src/base/vpr_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ struct DeviceContext : public Context {
///@brief The indicies of rr nodes of a given type at a specific x,y grid location
t_rr_node_indices rr_node_indices; // [0..NUM_RR_TYPES-1][0..grid.width()-1][0..grid.width()-1][0..size-1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to make all the rr-related comments here Doxygen compatiable (e.g. /// on rr_node_indicies)


std::vector<t_rr_switch_inf> rr_switch_inf; // autogenerated in build_rr_graph based on switch fan-in. [0..(num_rr_switches-1)]
///@brief Autogenerated in build_rr_graph based on switch fan-in. [0..(num_rr_switches-1)]
std::vector<t_rr_switch_inf> rr_switch_inf;

///@brief Wire segment types in RR graph
std::vector<t_segment_inf> rr_segments;
Expand Down
7 changes: 4 additions & 3 deletions vpr/src/base/vpr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ constexpr const char* EMPTY_BLOCK_NAME = "EMPTY";
#endif

enum class e_router_lookahead {
CLASSIC, ///<VPR's classic lookahead (assumes uniform wire types)
MAP, ///<Lookahead considering different wire types (see Oleg Petelin's MASc Thesis)
NO_OP ///<A no-operation lookahead which always returns zero
CLASSIC, ///<VPR's classic lookahead (assumes uniform wire types)
MAP, ///<Lookahead considering different wire types (see Oleg Petelin's MASc Thesis)
EXTENDED_MAP, ///<Lookahead with a more extensive node sampling method
NO_OP ///<A no-operation lookahead which always returns zero
};

enum class e_route_bb_update {
Expand Down
2 changes: 0 additions & 2 deletions vpr/src/route/route_timing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
#include "bucket.h"
#include "connection_router.h"

#include "router_lookahead_map.h"

#include "tatum/TimingReporter.hpp"
#include "overuse_report.h"

Expand Down
2 changes: 2 additions & 0 deletions vpr/src/route/route_timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "heap_type.h"
#include "routing_predictor.h"

extern bool f_router_debug;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed by your code? I think Mahshad is using it for router breakpoints and is commenting it; if you need it you can comment it. Not sure why it's added here, but as others are going to use it likely OK.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had missed this comment.
So, f_router_debug gets used in the extended lookahead map code to enable debugging prints of the returned lookahead costs (with all the various details such as delay, congestion, site_pin_delay, etc.).

Usure how to bring it in the lookahead if it gets commented here. I need to see if there is another solution.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may need a new variable then. Adding @MohamedElgammal to comment. If f_router_debug means "stopped at a breakpoint" (we probably need to rename the variable to f_router_breakpoint in that case) then we shouldn't use it to control whether or not we print out additional lookahead info. Should be a different variable then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the comment in route_timing.cpp to explain what this variable does. The comment currently says it is for breakpoints, which is no longer true (which is good news). Explain it is to output extra debugging info.


int get_max_pins_per_net();

bool try_timing_driven_route(const t_router_opts& router_opts,
Expand Down
3 changes: 3 additions & 0 deletions vpr/src/route/router_lookahead.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "router_lookahead.h"

#include "router_lookahead_map.h"
#include "router_lookahead_extended_map.h"
#include "vpr_error.h"
#include "globals.h"
#include "route_timing.h"
Expand All @@ -13,6 +14,8 @@ static std::unique_ptr<RouterLookahead> make_router_lookahead_object(e_router_lo
return std::make_unique<ClassicLookahead>();
} else if (router_lookahead_type == e_router_lookahead::MAP) {
return std::make_unique<MapLookahead>();
} else if (router_lookahead_type == e_router_lookahead::EXTENDED_MAP) {
return std::make_unique<ExtendedMapLookahead>();
} else if (router_lookahead_type == e_router_lookahead::NO_OP) {
return std::make_unique<NoOpLookahead>();
}
Expand Down
Loading