Reputation: 6521
I have a data processing model which is made of many chains of algorithms processing data chunks. Each chain is a graph of algorithms, which I implemented with the TBB graph class.
Now I would like to have something like a "pool of graphs", i.e. a pool of tasks, each of them containing a tbb::graph. In this way I could run the chains of algorithms in parallel over the data chunks.
Could you point any TBB example of something similar to a "pool of graphs", or might you suggest and hints to implement it?
Upvotes: 5
Views: 530
Reputation: 36
I'm not sure I fully understand what exactly you try to achieve, but let's try :). It seems that only thing you need is the proper source_node (https://www.threadingbuildingblocks.org/docs/help/reference/flow_graph/source_node_cls.htm ) to throw new data chunks into flow graph for processing. Flow graph instance can be treated as the algorithm (like e.g. tbb::parallel_pipeline) written in a bit different way. It should not be treated as the data structure like list or vector. So most likely you do not need pool of graphs :)
Upvotes: 0
Reputation: 928
My suggestion would be that you use tbb::concurrent_queue or tbb::concurrent_vector , the advantage of it is that you can resize it during multiple accesses. My personal hint to this, create a lock / graph object so that you never modify an object in parallel.
http://threadingbuildingblocks.org/wiki/index.php?title=Concurrent_Vector
An example for the queue can be found here: https://sites.google.com/site/samplecodesproject/tbb/containers-3/concurrent_queue
Upvotes: 1