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

TBB, classes, memory

Sorin_Goldenberg
Beginner
427 Views

I fail to understand how should I use TBB for my needs.

My code is (obviously) divided among several classes. Such a class has inputs, outputs, internal memory and (at least) one member function that processes the input using some of the internal memory. 

Would like to create a pipeline using flow graph (to be able to generalize in the future) something like A->B. 

Suppose A 's output is a pointer to float array of length N. B processes this array using an internal array of length N.

I create the classes, connect the nodes. I do not understand what happens when it runs. Are new instances of objects for A and B created, depending on the concurrency? If not - what should I do to enable parallel access to different segments of memory?

Thank you,

 

Sorin

 

0 Kudos
3 Replies
RafSchietekat
Valued Contributor III
427 Views

If you're talking about a node's Body, there's one operational instance for the node, copied at construction time, and it is accessed concurrently. That means that you are responsible for synchronising access to any shared internal state. You can also use TLS if it does not matter that the number of parallel states may exceed the concurrency level of the node.

0 Kudos
Sorin_Goldenberg
Beginner
427 Views

Raf Schietekat wrote:

If you're talking about a node's Body, there's one operational instance for the node, copied at construction time, and it is accessed concurrently. That means that you are responsible for synchronising access to any shared internal state. You can also use TLS if it does not matter that the number of parallel states may exceed the concurrency level of the node.

So does this mean that if I need such a node to be operated n times in parallel I should generate n nodes and operate each one serially?

What TLS stands for?

Thanks

Sorin

0 Kudos
Sorin_Goldenberg
Beginner
427 Views

Raf Schietekat wrote:

If you're talking about a node's Body, there's one operational instance for the node, copied at construction time, and it is accessed concurrently. That means that you are responsible for synchronising access to any shared internal state. You can also use TLS if it does not matter that the number of parallel states may exceed the concurrency level of the node.

Does this mean that if a class has internal memory that is used for r/w I need to create a new object for each concurrent usage ?

Thank you 

 

Sorin

0 Kudos
Reply