@@ -86,6 +86,8 @@ struct SampleRegion {
86
86
87
87
template <typename Entry>
88
88
static std::pair<float , int > run_dijkstra (int start_node_ind,
89
+ std::vector<bool >* node_expanded,
90
+ std::vector<util::Search_Path>* paths,
89
91
RoutingCosts* routing_costs);
90
92
91
93
static std::vector<SampleRegion> find_sample_regions (int num_segments);
@@ -495,7 +497,7 @@ float ConnectionBoxMapLookahead::get_map_cost(int from_node_ind,
495
497
template <typename Entry>
496
498
static bool add_paths (int start_node_ind,
497
499
Entry current,
498
- std::unordered_map< int , util::Search_Path>* paths,
500
+ const std::vector< util::Search_Path>& paths,
499
501
RoutingCosts* routing_costs) {
500
502
auto & device_ctx = g_vpr_ctx.device ();
501
503
ConnectionBoxId box_id;
@@ -511,7 +513,8 @@ static bool add_paths(int start_node_ind,
511
513
512
514
// reconstruct the path
513
515
std::vector<int > path;
514
- for (int i = (*paths)[node_ind].parent ; i != start_node_ind; i = (*paths)[i].parent ) {
516
+ for (int i = paths[node_ind].parent ; i != start_node_ind; i = paths[i].parent ) {
517
+ VTR_ASSERT (i != -1 );
515
518
path.push_back (i);
516
519
}
517
520
path.push_back (start_node_ind);
@@ -538,7 +541,7 @@ static bool add_paths(int start_node_ind,
538
541
539
542
if (*it != start_node_ind) {
540
543
auto & parent_node = device_ctx.rr_nodes [parent];
541
- start_to_here = Entry (*it, parent_node.edge_switch ((* paths) [*it].edge ), &start_to_here);
544
+ start_to_here = Entry (*it, parent_node.edge_switch (paths[*it].edge ), &start_to_here);
542
545
parent = *it;
543
546
}
544
547
@@ -573,6 +576,8 @@ static bool add_paths(int start_node_ind,
573
576
* the number of paths from start_node_ind stored. */
574
577
template <typename Entry>
575
578
static std::pair<float , int > run_dijkstra (int start_node_ind,
579
+ std::vector<bool >* node_expanded,
580
+ std::vector<util::Search_Path>* paths,
576
581
RoutingCosts* routing_costs) {
577
582
auto & device_ctx = g_vpr_ctx.device ();
578
583
int path_count = 0 ;
@@ -584,12 +589,12 @@ static std::pair<float, int> run_dijkstra(int start_node_ind,
584
589
585
590
/* a list of boolean flags (one for each rr node) to figure out if a
586
591
* certain node has already been expanded */
587
- std::vector< bool > node_expanded (device_ctx. rr_nodes . size (), false );
592
+ std::fill (node_expanded-> begin (), node_expanded-> end (), false );
588
593
/* For each node keep a list of the cost with which that node has been
589
594
* visited (used to determine whether to push a candidate node onto the
590
595
* expansion queue.
591
596
* Also store the parent node so we can reconstruct a specific path. */
592
- std::unordered_map< int , util::Search_Path> paths ;
597
+ std::fill (paths-> begin (), paths-> end (), util::Search_Path{std::numeric_limits< float >:: infinity (), - 1 , - 1 }) ;
593
598
/* a priority queue for expansion */
594
599
std::priority_queue<Entry, std::vector<Entry>, std::greater<Entry>> pq;
595
600
@@ -607,7 +612,7 @@ static std::pair<float, int> run_dijkstra(int start_node_ind,
607
612
int node_ind = current.rr_node_ind ;
608
613
609
614
/* check that we haven't already expanded from this node */
610
- if (node_expanded[node_ind]) {
615
+ if ((* node_expanded) [node_ind]) {
611
616
continue ;
612
617
}
613
618
@@ -617,11 +622,11 @@ static std::pair<float, int> run_dijkstra(int start_node_ind,
617
622
max_cost = current.cost ();
618
623
619
624
path_count++;
620
- add_paths<Entry>(start_node_ind, current, & paths, routing_costs);
625
+ add_paths<Entry>(start_node_ind, current, * paths, routing_costs);
621
626
} else {
622
627
util::expand_dijkstra_neighbours (device_ctx.rr_nodes ,
623
- current, paths, node_expanded, pq);
624
- node_expanded[node_ind] = true ;
628
+ current, paths, node_expanded, & pq);
629
+ (* node_expanded) [node_ind] = true ;
625
630
}
626
631
}
627
632
return std::make_pair (max_cost, path_count);
@@ -658,6 +663,8 @@ void ConnectionBoxMapLookahead::compute(const std::vector<t_segment_inf>& segmen
658
663
RoutingCosts delay_costs;
659
664
RoutingCosts base_costs;
660
665
int total_path_count = 0 ;
666
+ std::vector<bool > node_expanded (device_ctx.rr_nodes .size ());
667
+ std::vector<util::Search_Path> paths (device_ctx.rr_nodes .size ());
661
668
662
669
for (auto & point : region.points ) {
663
670
// statistics
@@ -667,12 +674,12 @@ void ConnectionBoxMapLookahead::compute(const std::vector<t_segment_inf>& segmen
667
674
int path_count = 0 ;
668
675
for (auto node_ind : point.nodes ) {
669
676
{
670
- auto result = run_dijkstra<util::PQ_Entry_Delay>(node_ind, &delay_costs);
677
+ auto result = run_dijkstra<util::PQ_Entry_Delay>(node_ind, &node_expanded, &paths, & delay_costs);
671
678
max_delay_cost = std::max (max_delay_cost, result.first );
672
679
path_count += result.second ;
673
680
}
674
681
{
675
- auto result = run_dijkstra<util::PQ_Entry_Base_Cost>(node_ind, &base_costs);
682
+ auto result = run_dijkstra<util::PQ_Entry_Base_Cost>(node_ind, &node_expanded, &paths, & base_costs);
676
683
max_base_cost = std::max (max_base_cost, result.first );
677
684
path_count += result.second ;
678
685
}
0 commit comments