vtr-verilog-to-routing
vtr-verilog-to-routing copied to clipboard
Switching of RRGraphView's Routing Resource Graph
One of the use cases of adding an API to VPR for the routing resource graph was to be able to alter the way the RRGraph
was represented and still use it throughout VPR.
I have been working on folding the RRGraph
to reduce the size it takes up in memory, especially when it grows very large. I have implemented an abstract class so that the RRGraphView
object can make use of several different RRGraph
classes. RRGraphView
has a pointer to an interface class (RRGraphViewInterface
) which several different types of RRGraph
classes inherit from. Whenever one wants to change the RRGraph
in use, they simply change where the RRGraphViewInterface
pointer is pointing.
This method has allowed me to dynamically select which RRGraph
to use, but it has come at a cost. VPR runs more slowly after adding in this interface class and methodology. I believe this may be due to the vtable lookups which occur for every function call to the RRGraph
derived classes. The lookup should be minimal, but because there are so many calls to the RRGraph
functions, I think this is where the issue is.
Does anyone know of a better way to be doing this? The only way I have thought of so far involves inheritance, but I am hoping there's a better way. Essentially, I just need to be able to change which class the RRGraphView
uses to call the RRGraph
access functions.
@ethanroj23 Would you mind providing some code examples? I can better understand the scenario.
Sure thing. Here are some of the files in question. RRGraphViewInterface RRGraphView
Specifically, the RRGraphView has a pointer to the interface class that it uses to access functions.
RRGraphViewInterface* primary_rr_graph_;
I think this abstract class pointer may be preventing inlining the function calls that RRGraphView makes.