使用线程构建块 (TBB) 时如何修改线程调度行为?

发布于 2024-08-24 07:48:21 字数 205 浏览 2 评论 0原文

有谁知道使用TBB时如何修改线程调度(特别是亲和力)?对简单的并行应用程序进行高级分析后,TBB 似乎以降低性能的方式指定底层线程的关联性。具体来说,我运行的核心启用了超线程,并且看起来 TBB 正在将线程关联到同一核心,即使有一个完全卸载的不同核心。

FWIW,我意识到 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 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

謌踐踏愛綪 2024-08-31 07:48:21

TBB 2.1 添加了一个关联分区器,它根据缓存关联将任务分配给线程。使用此分区程序而不是默认分区程序可能会有所帮助。您还可以深入研究各个任务并使用 tbb::task::set_affinity (文档 此处)。如果您的 tbb::task 子类实现了 note_affinity() 回调,那么如果任务碰巧在其亲和力指示的线程以外的线程上运行,调度程序可以通知您。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文