Skip to content

Commit e4af5f5

Browse files
[ParallelRouter] Added Timing Code for SSSP
Added code to measure the time that is spent in the SSSP loop. The overhead added by this code should be quite small and should provide data on how much time we are actually saving.
1 parent 414088c commit e4af5f5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

vpr/src/route/parallel_connection_router.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "parallel_connection_router.h"
22
#include <algorithm>
3+
#include <chrono>
34
#include <tuple>
45
#include "router_lookahead.h"
56
#include "rr_graph.h"
@@ -338,6 +339,9 @@ void ParallelConnectionRouter::timing_driven_route_connection_from_heap(RRNodeId
338339
this->cost_params_ = const_cast<t_conn_cost_params*>(&cost_params);
339340
this->bounding_box_ = const_cast<t_bb*>(&bounding_box);
340341

342+
// Start measuring time before the barrier
343+
std::chrono::steady_clock::time_point begin_time = std::chrono::steady_clock::now();
344+
341345
thread_barrier_.wait();
342346
this->timing_driven_route_connection_from_heap_thread_func(*this->sink_node_, *this->cost_params_, *this->bounding_box_, 0);
343347
thread_barrier_.wait();
@@ -348,6 +352,10 @@ void ParallelConnectionRouter::timing_driven_route_connection_from_heap(RRNodeId
348352
// Reset the heap for the next connection
349353
heap_.reset();
350354

355+
// Stop measuring time after the barrier and the heap is reset.
356+
std::chrono::steady_clock::time_point end_time = std::chrono::steady_clock::now();
357+
this->sssp_total_time += std::chrono::duration_cast<std::chrono::microseconds>(end_time - begin_time);
358+
351359
// if (router_debug_) {
352360
// //Update known path costs for nodes pushed but not popped, useful for debugging
353361
// empty_heap_annotating_node_route_inf();

vpr/src/route/parallel_connection_router.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef _PARALLEL_CONNECTION_ROUTER_H
22
#define _PARALLEL_CONNECTION_ROUTER_H
33

4+
#include <chrono>
45
#include "connection_router_interface.h"
56
#include "rr_graph_storage.h"
67
#include "route_common.h"
@@ -162,6 +163,8 @@ class ParallelConnectionRouter : public ConnectionRouterInterface {
162163
~ParallelConnectionRouter() {
163164
is_router_destroying_ = true;
164165
thread_barrier_.wait();
166+
167+
VTR_LOG("Parallel Connection Router is being destroyed. Time spent computing SSSP: %g seconds\n.", this->sssp_total_time.count() / 1000000.0);
165168
}
166169

167170
// Clear's the modified list. Should be called after reset_path_costs
@@ -418,6 +421,9 @@ class ParallelConnectionRouter : public ConnectionRouterInterface {
418421
std::atomic<RRNodeId*> sink_node_;
419422
std::atomic<t_conn_cost_params*> cost_params_;
420423
std::atomic<t_bb*> bounding_box_;
424+
425+
// Timing
426+
std::chrono::microseconds sssp_total_time{0};
421427
};
422428

423429
#endif /* _PARALLEL_CONNECTION_ROUTER_H */

0 commit comments

Comments
 (0)