I would like to write parallel code for Intel Xeon Phi using Intel TBB and Cilk Plus but i have a problem with thread affinity. I want to bind one thread to one logical core. Is is possible to set affinity like in OpenMP? I mean KMP_AFFINITY="compact". Thank you in advance. :)
Asked
Active
Viewed 457 times
3
-
What problem are you trying to solve if you *must* have fine grain controlled thread affinity. TBB doesn't have proper thread affinity, only task level affinity. `tbb::affinity_partitioner` will already try to preserve cache coherency. – BlamKiwi Feb 09 '15 at 00:48
1 Answers
3
Yes, it's possible and moreover it is recommended in conjunction with affinity_partitioner on Xeon Phi. Please see the blog for details. Here is a short code snippet to give you idea how does it look like:
class pinning_observer: public tbb::task_scheduler_observer {
public:
pinning_observer();
/*override*/ void on_scheduler_entry( bool );
~pinning_observer();
};
pinning_observer pinner;
pinner.observe( true );
There are no any special means for doing so in Cilk Plus.

Anton
- 6,349
- 1
- 25
- 53
-
This is what I'm looking for. Thanks. What about affinity in Intel Cilk Plus? – JudgeDeath Feb 09 '15 at 13:35