I have a direct acyclic graph, in my audio C++ project. Firstly, I verify that the graph…
- User
I have a direct acyclic graph, in my audio C++ project. Firstly, I verify that the graph is acyclic, then I sort it using Kahn's algorithm. Then, each node needs to work a buffer, so I introduce a greedy allocation such that:
- if a node has only one incoming edge the same buffer can be re-used;
- if a node has more outgoing edges, copies of buffer are created;
- if a node has more incoming edges, a new copy is done and the content of the buffers is merged inside it. Here my question: I know that other advanced strategies are possible, like liveness analysis or graph coloring, but I think the complexity is too high than the actual scenario to try that solutions. However, once my graph is created then it is "static". For this reason, I am wondering if starting from the actual greed allocation some improvement can be done using this consideration, while not pushing too much with the complexity of the solution. Please provide any feedback.
- Assistant
- User
Let's me parse your answers.
- I am already doing the proposed re-usage.
- Yes, I am considering to introduce a lifetime analysis.
- Yes, you are right and I considered with option. I am stuck to the analysis about the consolidation.
- Same as before, already considered and stuck.
- Not considered yet. Basically, what is not clear to me is if I have to analyze twice the full graph or these actions can be done while allocating the buffers the first time. Consider the Lifetime Analysis and the Minimal Copies. What it is not clear to me is if these actions are supposed to happen when I parse allocate the buffers the first time, or if I have to do a first analysis, then take a look of that, for instance to understand any possible optimization, apply the optimization and then "finally" allocated definitely the buffers. Please provide feedback.
- Assistant
- User
Try to break down a proposal.
- I can first of all traverse my graph and apply to a temporary graph my greedy allocation.
- I can apply on this data the lifetime analysis. Basically, for each buffer I need the start and the end.
- I apply the optimized greedy allocation, that knows from the lifetime analysis if a buffer can be labelled as re-usable and before to create a new buffer it looks if any re-usable buffers are present.
I think the complex part if the lifetime analysis itself. Are you able to provide me some hints about how to carry this task? Additionally, is there any necessary information that I do not provided you yet?
- Assistant
- User
I am stuck with the following compiler error. I have an interface class, IAudioBuffer with default copy constructor, then in AudioBuffer the copy constructor is defined private because I have a class BufferManager to use copy constructor in a fine-controlled way. Now, in BufferManager inside the method for copying it I pass as argument a std::shared_ptr. The compiler complains because there is no matching function for AudioBuffer(IAudioBuffer). Here I am stuck: indeed, I would use IAudioBuffer as argument, however the compiler is right. Moreover, I am concern because the full syntax for copy constructor is AudioBuffer(const AudioBuffer &other, size_t newId) because the copy constructor is not trivial. For this reason, I do not know if I can operate to the interface definition. Please provide any feedback about this issue.
- Assistant