tags:

views:

47

answers:

1

Does anyone know how to modify the thread scheduling (specifically affinity) when using TBB? Doing a high level analysis on a simple parallel-for application, it seems like TBB is specifying the underlying threads' affinity in a way that reduces performance. Specifically, the cores I'm running on have hyper-threading enabled, and it looks like TBB is affinitizing threads to the same core even if there is a different core left completely unloaded.

FWIW, I realize it's likely that TBB is doing the "right thing" and that changing the threads' affinity will only reduce performance. I'd just like to experiment with it to see if that's really the case.

+1  A: 

TBB 2.1 added an affinity partitioner which assigns tasks to threads based on cache affinity. Using this partitioner instead of the default one might help out. You can also dive into individual tasks and use tbb::task::set_affinity (documentation here). The scheduler can notify you if the task happens to run on a thread other than the one indicated by its affinity if your subclass of tbb::task implements the note_affinity() callback.

Matt J