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. :)
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.