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

Task Execution Related Problem

irisshinra308
Beginner
258 Views
Hi~

I have some questions about the task execution.
Does all the tasks in the deque or the mailbox could be executed interchangeably?
I want to steal the task in other's mailbox and execute it right away under some special circumstances.
Is there anything I should aware of?

I find out that the task's execute() methods are only called in the wait_for_all().
Does that mean only the wait_for_all methods could make the task been executed?
I am trying to keep track of all the currently running tasks and record their affinity_ids.
So I want to record affinity_ids manually right before they are executed.
If there are some other ways could do this more easier, plz let me know.

I also find out there is a variable named "innermost_running_task" in GenericScheduler.
I am wondering that would TBB execute more than one task on a thread?
If not, what the purpose of "innermost" is?

Another question is, does all the tasks in the mailbox has the same affinity ID in current TBB implementation?
If not, could you give me some examples?

I am also curious about the purpose of the set_is_idle method of mail_inbox.

Sorry for asking so many questions.

Any help would be grateful!

Dennis
0 Kudos
3 Replies
robert-reed
Valued Contributor II
258 Views
Quoting - irisshinra308
I have some questions about the task execution.
Does all the tasks in the deque or the mailbox could be executed interchangeably?
I want to steal the task in other's mailbox and execute it right away under some special circumstances.
Is there anything I should aware of?

I find out that the task's execute() methods are only called in the wait_for_all().
Does that mean only the wait_for_all methods could make the task been executed?
I am trying to keep track of all the currently running tasks and record their affinity_ids.
So I want to record affinity_ids manually right before they are executed.
If there are some other ways could do this more easier, plz let me know.

I also find out there is a variable named "innermost_running_task" in GenericScheduler.
I am wondering that would TBB execute more than one task on a thread?
If not, what the purpose of "innermost" is?

Another question is, does all the tasks in the mailbox has the same affinity ID in current TBB implementation?
If not, could you give me some examples?

I am also curious about the purpose of the set_is_idle method of mail_inbox.
The questions you ask are very broad and so could bethe answers, depending on what it is you're trying to do. In the deque or in a mailbox, a task is a task and should be able to be run on any of the threads. What might be your purpose in stealing a task from another thread's mailbox? The only reason tasks go into a mailbox is because they have a thread affinity that suggests they mightbe more efficiently run on a specific thread. This is just a suggestion so putting a task in a mailbox is no guarantee that the intended thread will actually execute it. From your description it sounds like you have lots of other plans for affinity IDs and mailboxes.
0 Kudos
irisshinra308
Beginner
258 Views
Thanks for replying.

I am trying to do some research about the sharing data scheduling issues, so I need to steal the tasks with specific affinty from their mailbox.

I know that the affinity information is only a hint for the scheduler to make a better choice.
The tasks with same affinity id have some sharing data which could be reused in the private cache.
Am I right?

So in the spawn(), it would send the task_proxy to the mailbox of affinity thread, but also it would put this task into the deque of current thread. Whoever takes the task first would execute it. Is this correct?

Sorry for bothering you for so many questions

Dennis
0 Kudos
Alexey-Kukanov
Employee
258 Views
Quoting - irisshinra308
I am trying to do some research about the sharing data scheduling issues, so I need to steal the tasks with specific affinty from their mailbox.

I know that the affinity information is only a hint for the scheduler to make a better choice. The tasks with same affinity id have some sharing data which could be reused in the private cache. Am I right?

So in the spawn(), it would send the task_proxy to the mailbox of affinity thread, but also it would put this task into the deque of current thread. Whoever takes the task first would execute it. Is this correct?

Yes this is correct.
0 Kudos
Reply