Prime lookahead cache when routing with a fixed width.

This avoids computing the router lookahead inside of the routing
timer.

Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
diff --git a/vpr/src/base/vpr_api.cpp b/vpr/src/base/vpr_api.cpp
index e1fc47b..348545f 100644
--- a/vpr/src/base/vpr_api.cpp
+++ b/vpr/src/base/vpr_api.cpp
@@ -717,6 +717,16 @@
                               std::shared_ptr<SetupHoldTimingInfo> timing_info,
                               std::shared_ptr<RoutingDelayCalculator> delay_calc,
                               vtr::vector<ClusterNetId, float*>& net_delay) {
+    if (router_needs_lookahead(vpr_setup.RouterOpts.router_algorithm)) {
+        // Prime lookahead cache to avoid adding lookahead computation cost to
+        // the routing timer.
+        get_cached_router_lookahead(
+            vpr_setup.RouterOpts.lookahead_type,
+            vpr_setup.RouterOpts.write_router_lookahead,
+            vpr_setup.RouterOpts.read_router_lookahead,
+            vpr_setup.Segments);
+    }
+
     vtr::ScopedStartFinishTimer timer("Routing");
 
     if (NO_FIXED_CHANNEL_WIDTH == fixed_channel_width || fixed_channel_width <= 0) {
@@ -743,6 +753,9 @@
                             std::shared_ptr<SetupHoldTimingInfo> timing_info,
                             std::shared_ptr<RoutingDelayCalculator> delay_calc,
                             vtr::vector<ClusterNetId, float*>& net_delay) {
+    // Note that lookahead cache is not primed here because
+    // binary_search_place_and_route will change the channel width, and result
+    // in the lookahead cache being recomputed.
     vtr::ScopedStartFinishTimer timer("Routing");
 
     auto& router_opts = vpr_setup.RouterOpts;
@@ -1176,9 +1189,9 @@
 }
 
 /* This function performs power estimation. It relies on the
- * placement/routing results, as well as the critical path. 
+ * placement/routing results, as well as the critical path.
  * Power estimation can be performed as part of a full or
- * partial flow. More information on the power estimation functions of 
+ * partial flow. More information on the power estimation functions of
  * VPR can be found here:
  *   http://docs.verilogtorouting.org/en/latest/vtr/power_estimation/
  */
diff --git a/vpr/src/route/route_common.cpp b/vpr/src/route/route_common.cpp
index 0b96c9c..a788735 100644
--- a/vpr/src/route/route_common.cpp
+++ b/vpr/src/route/route_common.cpp
@@ -734,7 +734,7 @@
     return (cost);
 }
 
-/* Returns the congestion cost of using this rr_node, *ignoring* 
+/* Returns the congestion cost of using this rr_node, *ignoring*
  * non-configurable edges */
 static float get_single_rr_cong_cost(int inode) {
     auto& device_ctx = g_vpr_ctx.device();
@@ -1110,7 +1110,7 @@
      * the FPGA if necessary.  The bounding box returned by this routine
      * are different from the ones used by the placer in that they are
      * clipped to lie within (0,0) and (device_ctx.grid.width()-1,device_ctx.grid.height()-1)
-     * rather than (1,1) and (device_ctx.grid.width()-1,device_ctx.grid.height()-1).                                                            
+     * rather than (1,1) and (device_ctx.grid.width()-1,device_ctx.grid.height()-1).
      */
     auto& cluster_ctx = g_vpr_ctx.clustering();
     auto& device_ctx = g_vpr_ctx.device();
@@ -1897,3 +1897,20 @@
 
     return true;
 }
+
+// True if router will use a lookahead.
+//
+// This controls whether the router lookahead cache will be primed outside of
+// the router ScopedStartFinishTimer.
+bool router_needs_lookahead(enum e_router_algorithm router_algorithm) {
+    switch (router_algorithm) {
+        case BREADTH_FIRST:
+        case NO_TIMING:
+            return false;
+        case TIMING_DRIVEN:
+            return true;
+        default:
+            VPR_FATAL_ERROR(VPR_ERROR_ROUTE, "Unknown routing algorithm %d",
+                            router_algorithm);
+    }
+}
diff --git a/vpr/src/route/route_common.h b/vpr/src/route/route_common.h
index 0c2c90a..ea9ed19 100644
--- a/vpr/src/route/route_common.h
+++ b/vpr/src/route/route_common.h
@@ -126,3 +126,5 @@
 
 t_trace* alloc_trace_data();
 void free_trace_data(t_trace* trace);
+
+bool router_needs_lookahead(enum e_router_algorithm router_algorithm);