Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
2485 Discussions

Flow graph: how to create ordered pairs without consuming both elements

Stefanos
Beginner
1,099 Views

Hello,

Perhaps, it is a newbie question.

Here is the question:

I have N integers from 0..N-1. The integers arrive without order.

A sequencer node can put them in order.
Then, I would like to create pairs as follows:

(0,1), (1,2), (2,3), ..., (N-2, N-1) .

 

How could this implemented with the flow graph?

 

I cannot make it work with a join node as I tried to feedback the output to one of the inputs but it does not even start the graph.

 

I tried to create my own multifunction node which implements this pairwise behavior, but it either stops to early or gets stuck in an infinite loop.

Is there an example with this behavior that I am not aware of? 

 

Thank you

0 Kudos
3 Replies
NoorjahanSk_Intel
Moderator
1,036 Views

Hi,

 

Thanks for posting in Intel Communities.

 

You can use function_node to generate integers from 0 to N-2.

We can create a user-defined body on incoming messages that create a pair and pass this class to function_node.

 

Please refer to the below link for more details:

https://spec.oneapi.io/versions/latest/elements/oneTBB/source/flow_graph/func_node_cls.html

 

We can also use join_node by creating two function_nodes and combine into pairs of consecutive integers using join_node.

 

Refer to the below link for more details:

https://spec.oneapi.io/versions/latest/elements/oneTBB/source/flow_graph.html

 

Thanks & Regards,

Noorjahan.


0 Kudos
NoorjahanSk_Intel
Moderator
1,008 Views

Hi,


We haven't heard back from you. Could you please provide an update on your issue?


Thanks & Regards,

Noorjahan.


0 Kudos
NoorjahanSk_Intel
Moderator
945 Views

Hi,


I have not heard back from you, so I will close this inquiry now. If you need further assistance, please post a new question.


Thanks & Regards,

Noorjahan.


0 Kudos
Reply