Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
39 Views

Signal processing filters

Hi,

I need to write a signal processing software with TBB. I am trying to use tbb::flow for that. I have:

- One producer P0

- Two consumers C0, C1

In order to communicate, the producer writes chunks of data to a std::vector<float> called pool. The size of this vector is nb_chunks * chunk_size. To get an idea, chunk_size is about 100 and nb_chunks is about 10.

When the producer first receives a signal from the acquisition device, it writes 100 element to the pool and sends a signal to the 2 consumers C0 and C1, so that it can read the data. The producer might receive another signal from the acquisition device, write 100 elements to the next memory chunk and sends a signal to the consumers C0 and C1. When they are done with the data, C0 and C1 needs to send a signal back to P0 telling it that the chunk of data is available for the producer to write to it.

As a consequence, P0 is connected to C0 and C0 is connected to P0. When P0 receives the message from C0 that a buffer chunk is released, it usually won't fill it right away and ship it back to the consumers. As a consequence, I don't want him to send it a signal right away. It seems to me that it does not fit with the way TBB is designed. 

So I don't know how to design this workflow. Any help would be appreciated.

0 Kudos
3 Replies
Highlighted
39 Views

Hi,

Please consider connecting join_node as a successor of consumer and device acquisition nodes so that join_node waits the signals to come from all of its inputs and only after that send it to producer. In addition, instead of simply signaling that the work is available for processing you can pass useful information between those nodes, e.g. subrange of preallocated vector, to be filled by producer and then read by consumers.

Regards, Aleksei

0 Kudos
Highlighted
Beginner
39 Views

Hi Aleksei,

I was expecting to send this kind of information, but I am looking for a way that the consumers C0 and C1 could communicate back to the producer P0 that the chunk of data has been read and could be used again by the producer to write to it.

0 Kudos
Highlighted
39 Views

Hi,

Sorry for the long reply.

If the problem is that the types do not correspond, then additional (multi)function_node could be used between join_node and P0, which will extract necessary/single chunk from the join_node's message and pass it to P0. Please keep in mind that in this case to pair corresponding chunks in the join_node key_matching/tag_matching policy should be used.

Please let me know if I still have not gotten the idea of your design correctly.

Regards, Aleksei

0 Kudos