- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi. I'm novice at parallel programming.
I would like to know if there is some possibility to set on which fixed cores of multi-core processor I want to execute my program?
I have problems then try to use less threads than logical cores are at Intel Xeon X5550, for example 5 threads. Execution time depend dramatically of on which cores OS run program. And will be good if I in some way can control it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi. I'm novice at parallel programming.
I would like to know if there is some possibility to set on which fixed cores of multi-core processor I want to execute my program?
In order to setup TBB to use only 5 worker threads, pass 5 to task_scheduler_init constructor.
Then create your task_scheduler_observer and setup required affinity for worker threads in task_scheduler_observer::on_scheduler_entry(). You need to use platform specific affinity API (SetThreadAffinityMask(), pthread_setaffinity_np()).
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi. I'm novice at parallel programming.
I would like to know if there is some possibility to set on which fixed cores of multi-core processor I want to execute my program?
In order to setup TBB to use only 5 worker threads, pass 5 to task_scheduler_init constructor.
Then create your task_scheduler_observer and setup required affinity for worker threads in task_scheduler_observer::on_scheduler_entry(). You need to use platform specific affinity API (SetThreadAffinityMask(), pthread_setaffinity_np()).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Then create your task_scheduler_observer and setup required affinity for worker threads in task_scheduler_observer::on_scheduler_entry(). You need to use platform specific affinity API (SetThreadAffinityMask(), pthread_setaffinity_np()).
Thank you. This works good.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Problem was closed.
I declared time counter in procedure which are run parallel and forgot about it. This leads to increase single thread execution time into 2 times and lose in speed up, when I use many threads.
Sorry for trouble.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In order to setup TBB to use only 5 worker threads, pass 5 to task_scheduler_init constructor.
Then create your task_scheduler_observer and setup required affinity for worker threads in task_scheduler_observer::on_scheduler_entry(). You need to use platform specific affinity API (SetThreadAffinityMask(), pthread_setaffinity_np()).
Hello
Dmitriy, may be you, or somebody else, can help me again. I should run specific different tasks on specific cores. But from within task_scheduler_observer::on_scheduler_entry() I can't determine to which task current thread correspond. I can determine threadId, but this is first time then thread have this Id (right?) and I can't set correspondence between task and threadId before observer.
I try to don't use observer and do code from its into begin of operator() of correspondent task, but I lose 50% of speed. (Actually this is will be intresting for me too - why observer work faster).
So, can somebody help me with such problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I had a somewhat similar requirement. You can find the related thread at
http://software.intel.com/en-us/forums/showthread.php?t=68135
As far as I know there is no direct way of binding a task to a core. You can use the affinity as a hint for the scheduler, but because of work stealing it doesn't guarantee that a particular task will get executed on a particular core. Till a particular task is actually executed, there is always a possibility of it being stolen by some other thread. So, as Robert said in the post that i referred, getting a particular task to run on a particular HW thread might be challenging; perhaps easier would be to have the dispatched task identify which HW thread it is and dispatch to a particular function once the task is executed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I had a somewhat similar requirement. You can find the related thread at
http://software.intel.com/en-us/forums/showthread.php?t=68135
As far as I know there is no direct way of binding a task to a core. You can use the affinity as a hint for the scheduler, but because of work stealing it doesn't guarantee that a particular task will get executed on a particular core. Till a particular task is actually executed, there is always a possibility of it being stolen by some other thread. So, as Robert said in the post that i referred, getting a particular task to run on a particular HW thread might be challenging; perhaps easier would be to have the dispatched task identify which HW thread it is and dispatch to a particular function once the task is executed.
Thanks for link!
Task stealing is not a problem for me - I run only one task for one thread, so tasks not wait in pool.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Though it may appeartrivial to write P tasks that each do 1/P of the work, it is not so on modern machines, because of page faults, cache misses, OS interruptions etc. It's like sharing an apple. Don't try to cut it into equal pieces. Make applesauce.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page