开发者

How does one modify the thread scheduling behavior when using Threading Building Blocks (TBB)?

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 thi开发者_如何转开发ng" 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜